/* ── Reset & Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-base:      #0d0f14;
  --bg-surface:   #161a23;
  --bg-raised:    #1e2330;
  --bg-hover:     #252b3b;
  --border:       #2a3044;

  --text-primary: #e8eaf2;
  --text-secondary: #7c849e;
  --text-muted:   #4a5170;

  --accent:       #7c6af7;
  --accent-dim:   #3d3578;
  --accent-glow:  rgba(124, 106, 247, 0.18);

  --blue:         #4f8ef7;
  --green:        #3ecf8e;
  --red:          #f75f5f;

  --bubble-mine:  #2a2060;
  --bubble-theirs:#1e2330;

  --radius-sm:    6px;
  --radius-md:    12px;
  --radius-lg:    18px;
  --radius-xl:    24px;

  --font: "Inter", system-ui, -apple-system, sans-serif;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

html, body {
  height: 100%;
  height: var(--vh, 100vh);
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
  overflow-x: hidden !important;
  position: fixed;
  inset: 0;
  width: 100%;
}

/* ── Screen transitions ───────────────────────────────────────────── */
.screen {
  display: none;
  height: 100%;
  width: 100%;
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.screen.active { display: flex; }

/* ── Login ────────────────────────────────────────────────────────── */
#login-screen {
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, #1a1440 0%, var(--bg-base) 70%);
  padding: 16px;
}

.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 44px 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow), 0 0 0 1px rgba(124,106,247,0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.login-logo {
  margin-bottom: 8px;
  filter: drop-shadow(0 0 12px rgba(124,106,247,0.4));
}

.login-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.login-sub {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  text-align: center;
}

.field { width: 100%; }

#password-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#password-input::placeholder { color: var(--text-muted); }
#password-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.error-msg {
  font-size: 0.8rem;
  color: var(--red);
  min-height: 18px;
  text-align: center;
  width: 100%;
}

#login-btn {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  margin-top: 4px;
}
#login-btn:hover  { background: #8f7ef9; }
#login-btn:active { transform: scale(0.98); }
#login-btn:disabled { opacity: 0.55; cursor: not-allowed; }

#login-form { width: 100%; display: flex; flex-direction: column; gap: 12px; }

/* ── Chat layout ──────────────────────────────────────────────────── */
#chat-screen { background: var(--bg-base); }

.chat-layout {
  display: flex;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

/* ── Sidebar backdrop (mobile) ────────────────────────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 90;
  opacity: 0;
  transition: opacity 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}
.sidebar-backdrop.active {
  opacity: 1;
}

/* ── Sidebar ──────────────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: max(20px, env(safe-area-inset-top, 20px)) max(16px, env(safe-area-inset-right, 16px)) max(20px, env(safe-area-inset-bottom, 20px)) max(16px, env(safe-area-inset-left, 16px));
  gap: 16px;
  z-index: 100;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: 0;
}

.sidebar-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-section { flex: 1; }

.sidebar-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.online-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.online-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.online-list li::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(62,207,142,0.6);
}

/* ── Clear chat button ────────────────────────────────────────────── */
.clear-chat-btn {
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: var(--font, 'Inter', sans-serif);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 9px 14px;
  border-radius: var(--radius-md, 10px);
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  width: 100%;
}
.clear-chat-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}
.clear-chat-btn:active {
  transform: translateY(0);
}
.clear-chat-btn svg { flex-shrink: 0; }

.logout-btn {
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: var(--font, 'Inter', sans-serif);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 9px 14px;
  border-radius: var(--radius-md, 10px);
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: left;
  min-height: 42px;
  width: 100%;
}
.logout-btn:hover {
  background: rgba(247, 95, 95, 0.1);
  color: var(--red, #f87171);
  border-color: rgba(247, 95, 95, 0.35);
  transform: translateY(-1px);
}
.logout-btn:active {
  transform: translateY(0);
}

/* ── Chat main ────────────────────────────────────────────────────── */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.chat-header {
  position: relative;
  z-index: 200;
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: max(16px, env(safe-area-inset-left, 16px));
  padding-right: max(16px, env(safe-area-inset-right, 16px));
  height: calc(56px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  background: var(--bg-surface);
  box-sizing: border-box;
}

/* ── Hamburger ────────────────────────────────────────────────────── */
.hamburger-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.hamburger-btn:hover { background: var(--bg-hover); }

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-room-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transition: background 0.3s;
}
.status-dot.online  { background: var(--green); box-shadow: 0 0 5px rgba(62,207,142,0.5); }
.status-dot.offline { background: var(--text-muted); }

/* ── Messages ─────────────────────────────────────────────────────── */
.messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden !important;
  padding: 20px max(16px, env(safe-area-inset-right, 16px)) 8px max(16px, env(safe-area-inset-left, 16px));
  display: flex;
  flex-direction: column;
  gap: 2px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  contain: content;
}

.messages::-webkit-scrollbar { width: 4px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Date divider */
.date-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 8px;
  color: var(--text-muted);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}
.date-divider::before,
.date-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Message row */
.msg-row {
  display: flex;
  flex-direction: column;
  max-width: 68%;
  margin-bottom: 2px;
}
.msg-row.mine  { align-self: flex-end; align-items: flex-end; }
.msg-row.theirs { align-self: flex-start; align-items: flex-start; }

/* Group consecutive messages — hide sender name if same sender continues */
.msg-row.mine  + .msg-row.mine  .msg-sender,
.msg-row.theirs + .msg-row.theirs .msg-sender { display: none; }

.msg-sender {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  padding: 0 4px;
}

.msg-bubble {
  padding: 8px 13px;
  border-radius: var(--radius-lg);
  word-break: break-word;
  white-space: pre-wrap;
  line-height: 1.52;
  font-size: 0.9rem;
  position: relative;
}

.mine  .msg-bubble {
  background: var(--bubble-mine);
  border-bottom-right-radius: var(--radius-sm);
  color: #d8d4ff;
}
.theirs .msg-bubble {
  background: var(--bubble-theirs);
  border: 1px solid var(--border);
  border-bottom-left-radius: var(--radius-sm);
  color: var(--text-primary);
}

/* Consecutive bubble rounding */
.msg-row.mine  + .msg-row.mine  .msg-bubble { border-top-right-radius: var(--radius-sm); }
.msg-row.theirs + .msg-row.theirs .msg-bubble { border-top-left-radius: var(--radius-sm); }

/* Chat Video Player */
.chat-video {
  max-width: 100%;
  max-height: 320px;
  border-radius: 10px;
  display: block;
  background: #000;
  outline: none;
}
.video-preview.direct-video {
  margin: 6px 0;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}
.video-load-error {
  padding: 8px 12px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  font-size: 0.78rem;
  color: #fca5a5;
  display: flex;
  align-items: center;
  gap: 8px;
}
.video-load-error a {
  color: #93c5fd;
  text-decoration: underline;
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 3px;
  padding: 0 4px;
  font-size: 0.68rem;
  color: var(--text-muted);
}
.mine .msg-meta {
  justify-content: flex-end;
}
.theirs .msg-meta {
  justify-content: flex-start;
}
.msg-time {
  font-size: inherit;
  color: inherit;
}
.app-logo-img {
  border-radius: var(--radius-md);
  object-fit: cover;
  box-shadow: 0 0 16px rgba(124, 106, 247, 0.4);
}

.msg-seen-status {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.68rem;
  color: var(--text-muted);
  transition: color 0.2s ease;
  margin-left: 2px;
}
.msg-seen-status.delivered {
  color: var(--text-muted);
}
.msg-seen-status.seen {
  color: var(--blue);
  font-weight: 500;
}
.msg-seen-status svg {
  flex-shrink: 0;
  vertical-align: middle;
}
.msg-seen-status.seen svg {
  stroke: var(--blue);
}
.seen-time-text {
  font-size: 0.68rem;
  line-height: 1;
}

/* System / status messages */
.sys-msg {
  align-self: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 4px 14px;
  margin: 8px 0;
}

/* Unread New Messages Divider */
.unread-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 14px 0;
  position: relative;
  width: 100%;
}
.unread-divider::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(124, 106, 247, 0.5), transparent);
  z-index: 1;
}
.unread-divider span {
  position: relative;
  z-index: 2;
  background: var(--accent-dim);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 4px 14px;
  border-radius: 12px;
  box-shadow: 0 0 10px rgba(124, 106, 247, 0.4);
}

/* ── Typing Indicator ──────────────────────────────────────────────── */
.typing-indicator-container {
  padding: 0 16px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
  height: 0;
  opacity: 0;
  overflow: hidden;
  transition: opacity 0.2s ease, transform 0.2s ease;
  transform: translateY(4px);
  will-change: opacity, transform;
  background: var(--bg-base);
  flex-shrink: 0;
}
.typing-indicator-container.active {
  padding: 8px 16px 10px;
  height: 34px;
  opacity: 1;
  transform: translateY(0);
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.typing-dots span {
  width: 5px;
  height: 5px;
  background-color: var(--text-secondary);
  border-radius: 50%;
  opacity: 0.4;
  animation: typingPulse 1.4s infinite both;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingPulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* ── Emoji Panel ──────────────────────────────────────────────────── */
.emoji-panel {
  display: none;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  max-height: 280px;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
  animation: emojiSlideUp 0.2s ease;
}
.emoji-panel.active { display: flex; }

@keyframes emojiSlideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.emoji-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-raised);
  gap: 8px;
}

.emoji-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 0;
}
.emoji-tabs::-webkit-scrollbar { display: none; }

.emoji-tab-btn {
  background: none;
  border: none;
  font-size: 1.15rem;
  padding: 6px 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  min-width: 38px;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.emoji-tab-btn:hover { background: var(--bg-hover); }
.emoji-tab-btn.active { background: var(--accent-dim); box-shadow: 0 0 0 1px var(--accent); }

.emoji-panel-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0 8px;
  line-height: 1;
  border-radius: 50%;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.emoji-panel-close:hover { color: var(--text-primary); }

.emoji-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  -webkit-overflow-scrolling: touch;
}
.emoji-panel-content::-webkit-scrollbar { width: 4px; }
.emoji-panel-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.emoji-category-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 8px 4px 4px;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: 3px;
}

.emoji-grid button {
  background: none;
  border: none;
  font-size: 1.35rem;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  line-height: 1;
  transition: background 0.1s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-width: 38px;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.emoji-grid button:hover { background: var(--bg-hover); transform: scale(1.15); }
.emoji-grid button:active { background: var(--accent-dim); transform: scale(0.95); }

/* ── Footer / Input ───────────────────────────────────────────────── */
.chat-footer {
  padding-top: 10px;
  padding-left: max(12px, env(safe-area-inset-left, 12px));
  padding-right: max(12px, env(safe-area-inset-right, 12px));
  padding-bottom: max(10px, env(safe-area-inset-bottom, 10px));
  border-top: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-surface);
  flex-shrink: 0;
}

.emoji-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.emoji-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.emoji-btn.active { background: var(--accent-dim); color: var(--accent); }

.msg-input {
  flex: 1;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.95rem;
  resize: none;
  outline: none;
  max-height: 140px;
  overflow-y: auto;
  line-height: 1.5;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-height: 42px;
  -webkit-appearance: none;
  touch-action: manipulation;
  transform: translateZ(0);
}
.msg-input::placeholder { color: var(--text-muted); }
.msg-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.msg-input::-webkit-scrollbar { width: 3px; }
.msg-input::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.send-btn:hover  { background: #8f7ef9; }
.send-btn:active { transform: scale(0.92); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .msg-input, #password-input {
    font-size: 16px !important;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 270px;
    padding-top: max(20px, env(safe-area-inset-top, 20px));
    padding-bottom: max(20px, env(safe-area-inset-bottom, 20px));
    padding-left: max(16px, env(safe-area-inset-left, 16px));
    padding-right: max(16px, env(safe-area-inset-right, 16px));
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.4);
  }

  .sidebar-backdrop {
    display: block;
    pointer-events: none;
  }
  .sidebar-backdrop.active {
    pointer-events: auto;
  }

  .hamburger-btn { display: flex; }

  .chat-main { width: 100%; }
  .msg-row { max-width: 88%; }

  .login-card {
    padding: 32px 24px;
  }

  .emoji-panel {
    max-height: 180px;
  }

  .confirm-card {
    margin: 16px;
    max-width: calc(100vw - 32px);
  }

  .toast-container {
    left: 16px;
    right: 16px;
    bottom: 16px;
    align-items: stretch;
  }
}

/* ── Confirm Modal ────────────────────────────────────────────────── */
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  -webkit-tap-highlight-color: transparent;
  padding: 16px;
  box-sizing: border-box;
}
.confirm-overlay.active {
  display: flex;
  opacity: 1;
}

.confirm-card {
  background: linear-gradient(180deg, #1e2230 0%, #151822 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-xl, 20px);
  padding: 28px 24px 22px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
  animation: confirmSlide 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

@keyframes confirmSlide {
  from { transform: scale(0.92) translateY(12px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.confirm-icon-wrapper {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  flex-shrink: 0;
}

.confirm-icon-wrapper.danger {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #f87171;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
}

.confirm-icon-wrapper.primary {
  background: rgba(124, 106, 247, 0.15);
  border: 1px solid rgba(124, 106, 247, 0.35);
  color: #a78bfa;
  box-shadow: 0 0 20px rgba(124, 106, 247, 0.2);
}

.confirm-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary, #e8eaf2);
  margin-bottom: 8px;
  letter-spacing: -0.2px;
}

.confirm-msg {
  font-size: 0.88rem;
  color: var(--text-secondary, #7c849e);
  line-height: 1.5;
  margin-bottom: 22px;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  width: 100%;
}

.confirm-btn {
  flex: 1;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-md, 10px);
  font-family: var(--font, 'Inter', sans-serif);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.confirm-btn:active { transform: scale(0.97); }

.confirm-btn.cancel {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-secondary, #9aa2bc);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.confirm-btn.cancel:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary, #ffffff);
}

.confirm-btn.ok {
  background: var(--accent, #7c6af7);
  color: #fff;
  box-shadow: 0 4px 14px rgba(124, 106, 247, 0.35);
}
.confirm-btn.ok:hover {
  background: #8b79fa;
  box-shadow: 0 6px 18px rgba(124, 106, 247, 0.5);
}

.confirm-btn.ok.danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
}
.confirm-btn.ok.danger:hover {
  background: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.55);
}

/* ── Toast Notifications ──────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom, 24px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 10px 20px;
  border-radius: 99px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  pointer-events: auto;
  animation: toastIn 0.3s ease forwards;
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast.out {
  animation: toastOut 0.25s ease forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-8px) scale(0.95); }
}

/* ── Online Status Badge ─────────────────────────────────────────── */
.online-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
  padding: 4px 10px 4px 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 99px;
  font-size: 0.72rem;
  white-space: nowrap;
  transition: opacity 0.25s, transform 0.25s;
  flex-shrink: 0;
  max-width: 180px;
}

.online-badge.hidden {
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
}
.online-badge:not(.hidden) {
  opacity: 1;
  transform: scale(1);
  animation: badgePopIn 0.28s ease;
}
@keyframes badgePopIn {
  from { opacity: 0; transform: scale(0.75); }
  to   { opacity: 1; transform: scale(1); }
}

/* Dot — green when online, grey when offline */
.online-badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.3s;
}
.online-badge.badge-online .online-badge-dot {
  background: var(--green, #3ecf8e);
  box-shadow: 0 0 6px rgba(62, 207, 142, 0.55);
  animation: badgePulse 2s ease-in-out infinite;
}
.online-badge.badge-offline .online-badge-dot {
  background: rgba(255,255,255,0.22);
  box-shadow: none;
}
@keyframes badgePulse {
  0%, 100% { box-shadow: 0 0 4px rgba(62,207,142,0.4); }
  50%      { box-shadow: 0 0 10px rgba(62,207,142,0.8); }
}

/* Name + status stacked */
.online-badge-name {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
}
.online-badge-name .badge-name {
  font-weight: 600;
  font-size: 0.72rem;
  color: var(--text-primary, #e2e4ef);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.online-badge-name .badge-status {
  font-size: 0.65rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.badge-status.online-now {
  color: var(--green, #3ecf8e);
}
.badge-status.offline-time {
  color: rgba(255,255,255,0.38);
}

/* ── Utility ──────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ═══════════════════════════════════════════════════════════════════
   REPLY-TO-MESSAGE FEATURE
   ═══════════════════════════════════════════════════════════════════ */

/* ── Reply Preview Bar (above input) ─────────────────────────────── */
.reply-preview {
  display: none;
  align-items: center;
  gap: 0;
  padding: 8px 12px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  animation: replySlideUp 0.2s ease;
}
.reply-preview.active {
  display: flex;
}

@keyframes replySlideUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.reply-preview-bar {
  width: 3px;
  align-self: stretch;
  min-height: 32px;
  background: var(--accent);
  border-radius: 3px;
  flex-shrink: 0;
  margin-right: 10px;
}

.reply-preview-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  overflow: hidden;
}

.reply-preview-sender {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-preview-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-width: 100%;
}

.reply-cancel-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
  margin-left: 4px;
}
.reply-cancel-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ── Quoted Reply Inside Message Bubble ───────────────────────────── */
.reply-quote {
  display: flex;
  gap: 0;
  padding: 8px 12px;
  margin-bottom: 6px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s;
  overflow: hidden;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.mine .reply-quote {
  background: rgba(124, 106, 247, 0.15);
}
.theirs .reply-quote {
  background: rgba(255, 255, 255, 0.05);
}

.reply-quote:hover {
  filter: brightness(1.15);
}

.reply-quote-bar {
  width: 3px;
  align-self: stretch;
  min-height: 24px;
  background: var(--accent);
  border-radius: 3px;
  flex-shrink: 0;
  margin-right: 8px;
}

.reply-quote-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  overflow: hidden;
}

.reply-quote-sender {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-quote-text {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-width: 100%;
}

/* ── Hover Action Buttons (Desktop & Touch) ──────────────────────── */
.msg-row {
  position: relative;
}

.msg-row.msg-deleting {
  opacity: 0;
  transform: scale(0.9) translateY(-10px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.msg-actions {
  position: absolute;
  top: 50%;
  transform: translateY(-50%) scale(0.85);
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s cubic-bezier(0.4, 0, 0.2, 1), transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10;
  -webkit-tap-highlight-color: transparent;
}

/* Position: for mine (right-aligned) messages, put actions on the left side */
.msg-row.mine .msg-actions {
  right: 100%;
  left: auto;
  margin-right: 6px;
}
/* For theirs (left-aligned) messages, put actions on the right side */
.msg-row.theirs .msg-actions {
  left: 100%;
  right: auto;
  margin-left: 6px;
}

.msg-row:hover .msg-actions {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) scale(1);
}

.msg-action-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  -webkit-tap-highlight-color: transparent;
}

.msg-action-btn:active {
  transform: scale(0.9);
}

.msg-reply-btn:hover {
  background: var(--bg-hover);
  color: var(--accent);
  border-color: var(--accent-dim);
}

.msg-delete-btn:hover {
  background: rgba(247, 95, 95, 0.15);
  color: var(--red);
  border-color: rgba(247, 95, 95, 0.4);
}

/* ── Swipe-to-Reply Visual Feedback (Mobile) ─────────────────────── */
.msg-row {
  touch-action: pan-y;
  transition: none;
}
.msg-row.swiping {
  transition: none !important;
}

.msg-swipe-indicator {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 4;
}

/* For "mine" rows, swipe goes left, so indicator appears on the left */
.msg-row.mine .msg-swipe-indicator {
  left: -8px;
}
/* For "theirs" rows, swipe goes right, so indicator appears on the right */
.msg-row.theirs .msg-swipe-indicator {
  right: -8px;
}

.msg-swipe-indicator.visible {
  opacity: 1;
}

/* Highlight effect when reply is triggered by swipe */
.msg-row.reply-triggered {
  animation: replyTriggerPulse 0.3s ease;
}

@keyframes replyTriggerPulse {
  0% { background: transparent; }
  50% { background: var(--accent-glow); }
  100% { background: transparent; }
}

/* ── Scroll-to-reply highlight ───────────────────────────────────── */
.msg-row.reply-highlight {
  animation: replyHighlight 1.2s ease;
}

@keyframes replyHighlight {
  0% { background: var(--accent-glow); }
  100% { background: transparent; }
}

/* ── Mobile: Hide hover button, rely on swipe ────────────────────── */
@media (max-width: 640px) {
  .msg-reply-btn {
    display: none !important;
  }
}

/* ── Desktop: Hide swipe indicator ───────────────────────────────── */
@media (min-width: 641px) {
  .msg-swipe-indicator {
    display: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   DESKTOP UI POLISH  (≥ 641px only — mobile is NOT affected)
   ═══════════════════════════════════════════════════════════════════ */
@media (min-width: 641px) {

  /* ── Overall background ─────────────────────────────────────────── */
  #chat-screen {
    background: linear-gradient(135deg, #0a0c12 0%, #0d0f14 40%, #10121a 100%);
  }

  /* ── Sidebar polish ─────────────────────────────────────────────── */
  .sidebar {
    width: 250px;
    background: linear-gradient(180deg, #141825 0%, #111520 100%);
    border-right: 1px solid rgba(124, 106, 247, 0.08);
    padding: 24px 18px;
    gap: 12px;
  }

  .sidebar-header {
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
  }

  .avatar {
    width: 40px;
    height: 40px;
    font-size: 0.9rem;
    box-shadow: 0 0 16px rgba(124, 106, 247, 0.25);
  }

  .sidebar-name {
    font-size: 0.95rem;
  }

  .sidebar-label {
    font-size: 0.7rem;
    margin-bottom: 12px;
    color: var(--text-muted);
    letter-spacing: 0.1em;
  }

  .online-list {
    gap: 10px;
  }

  .online-list li {
    font-size: 0.9rem;
    color: var(--text-secondary);
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
  }

  .online-list li:hover {
    background: var(--bg-hover);
  }

  /* Sidebar buttons spacing */
  .clear-chat-btn,
  .logout-btn {
    font-size: 0.88rem;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.1s;
  }

  .clear-chat-btn:hover,
  .logout-btn:hover {
    transform: translateX(2px);
  }

  .clear-chat-btn {
    margin-top: auto;
  }

  /* ── Chat header polish ─────────────────────────────────────────── */
  .chat-header {
    height: 60px;
    padding: 0 24px;
    background: linear-gradient(180deg, var(--bg-surface) 0%, rgba(22, 26, 35, 0.95) 100%);
    border-bottom: 1px solid rgba(124, 106, 247, 0.08);
    backdrop-filter: blur(8px);
  }

  .chat-room-name {
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -0.2px;
  }

  /* ── Online badge ───────────────────────────────────────────────── */
  .online-badge {
    padding: 5px 14px;
    font-size: 0.76rem;
  }

  /* ── Messages area polish ───────────────────────────────────────── */
  .messages {
    padding: 24px 32px 12px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
  }

  /* Better scrollbar on desktop */
  .messages::-webkit-scrollbar {
    width: 6px;
  }
  .messages::-webkit-scrollbar-track {
    background: transparent;
    margin: 8px 0;
  }
  .messages::-webkit-scrollbar-thumb {
    background: rgba(124, 106, 247, 0.2);
    border-radius: 6px;
  }
  .messages::-webkit-scrollbar-thumb:hover {
    background: rgba(124, 106, 247, 0.35);
  }

  /* ── Message bubbles – desktop refinement ───────────────────────── */
  .msg-row {
    max-width: 60%;
    margin-bottom: 3px;
  }

  .msg-bubble {
    padding: 10px 16px;
    font-size: 0.94rem;
    line-height: 1.6;
    transition: box-shadow 0.2s;
  }

  .msg-row:hover .msg-bubble {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
  }

  .mine .msg-bubble {
    background: linear-gradient(135deg, #2a2060 0%, #2d2468 100%);
  }

  .theirs .msg-bubble {
    background: linear-gradient(135deg, #1e2330 0%, #1c2130 100%);
  }

  .msg-sender {
    font-size: 0.78rem;
    margin-bottom: 5px;
  }

  .msg-meta {
    font-size: 0.72rem;
    margin-top: 4px;
  }

  /* ── Date divider – desktop ─────────────────────────────────────── */
  .date-divider {
    margin: 20px auto 12px;
    max-width: 500px;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
  }

  .date-divider::before,
  .date-divider::after {
    background: linear-gradient(
      to right,
      transparent,
      var(--border),
      transparent
    );
  }

  /* ── Typing indicator ───────────────────────────────────────────── */
  .typing-indicator-container {
    padding-left: 32px;
    font-size: 0.84rem;
  }
  .typing-indicator-container.active {
    padding: 10px 32px 12px;
  }

  /* ── Emoji panel – desktop ──────────────────────────────────────── */
  .emoji-panel {
    max-height: 260px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(124, 106, 247, 0.12);
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
  }

  .emoji-grid {
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 3px;
  }

  .emoji-grid button {
    font-size: 1.4rem;
    min-width: 40px;
    min-height: 40px;
    border-radius: var(--radius-sm);
    transition: background 0.15s, transform 0.1s;
  }

  .emoji-grid button:hover {
    background: var(--bg-hover);
    transform: scale(1.15);
  }

  /* ── Reply preview – desktop ────────────────────────────────────── */
  .reply-preview {
    padding: 10px 32px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
  }

  /* ── Chat footer / input – desktop ──────────────────────────────── */
  .chat-footer {
    padding: 12px 24px;
    padding-bottom: 16px;
    gap: 10px;
    background: linear-gradient(180deg, rgba(22, 26, 35, 0.95) 0%, var(--bg-surface) 100%);
    border-top: 1px solid rgba(124, 106, 247, 0.08);
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
  }

  .msg-input {
    padding: 11px 16px;
    font-size: 0.95rem;
    border-radius: var(--radius-lg);
  }

  .emoji-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    transition: background 0.2s, transform 0.1s, color 0.2s;
  }

  .emoji-btn:hover {
    transform: scale(1.08);
  }

  .send-btn {
    width: 44px;
    height: 44px;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    box-shadow: 0 2px 12px rgba(124, 106, 247, 0.3);
  }

  .send-btn:hover {
    background: #8f7ef9;
    box-shadow: 0 4px 20px rgba(124, 106, 247, 0.5);
    transform: scale(1.06);
  }

  .send-btn:active {
    transform: scale(0.94);
  }

  /* ── Reply button – better desktop hover ────────────────────────── */
  .msg-reply-btn {
    width: 30px;
    height: 30px;
    transition: opacity 0.15s cubic-bezier(0.4, 0, 0.2, 1), transform 0.15s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s, color 0.2s, box-shadow 0.2s;
  }

  .msg-reply-btn:hover {
    box-shadow: 0 2px 10px rgba(124, 106, 247, 0.3);
    transform: translateY(-50%) scale(1.1);
  }

  /* ── Reply quote in bubbles – desktop ───────────────────────────── */
  .reply-quote {
    padding: 7px 12px;
    margin-bottom: 8px;
    border-radius: 8px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .reply-quote-sender {
    font-size: 0.73rem;
  }

  .reply-quote-text {
    font-size: 0.82rem;
  }

  /* ── System messages – desktop ──────────────────────────────────── */
  .sys-msg {
    font-size: 0.78rem;
    padding: 5px 18px;
  }
}

/* ── Emoji-Only Messages Styling ──────────────────────────────────── */
.msg-row.emoji-only .msg-bubble {
  background: none !important;
  border: none !important;
  padding: 4px 0 !important;
  box-shadow: none !important;
}
.msg-row.emoji-only.mine .msg-bubble {
  color: var(--text-primary) !important;
}

.msg-row.emoji-only-1 .msg-bubble {
  font-size: 3.5rem !important;
  line-height: 1.1;
}

.msg-row.emoji-only-2 .msg-bubble {
  font-size: 2.8rem !important;
  line-height: 1.15;
}

.msg-row.emoji-only-3 .msg-bubble {
  font-size: 2.2rem !important;
  line-height: 1.2;
}

/* ── Image Attachment Button & Upload Preview ────────────────────── */
.image-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.image-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.image-btn.active { background: var(--accent-dim); color: var(--accent); }

@media (min-width: 641px) {
  .image-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
  }
  .image-btn:hover {
    transform: scale(1.08);
  }
}

.upload-preview {
  display: none;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  flex-shrink: 0;
  animation: replySlideUp 0.2s ease;
}
.upload-preview.active {
  display: block;
}
.upload-preview-list {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.upload-preview-list::-webkit-scrollbar { height: 4px; }
.upload-preview-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.upload-preview-item {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
}
.upload-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.upload-preview-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.15s;
}
.upload-preview-remove:hover {
  background: var(--red);
}

@media (min-width: 641px) {
  .upload-preview {
    padding: 12px 32px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
  }
}

/* ── Message Image Grid Layout ────────────────────────────────────── */
.msg-images-grid {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  width: 100%;
  max-width: 320px;
}
.msg-images-grid.cols-1 {
  grid-template-columns: 1fr;
}
.msg-images-grid.cols-2 {
  grid-template-columns: 1fr 1fr;
}
.msg-images-grid.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}
.msg-image {
  width: 100%;
  height: auto;
  max-height: 200px;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: opacity 0.25s, transform 0.2s;
}
.msg-image:hover {
  opacity: 0.9;
  transform: scale(0.99);
}

/* ── Lightbox Image Modal ─────────────────────────────────────────── */
.lightbox-modal {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(10, 12, 18, 0.95);
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.lightbox-modal.active {
  display: flex;
  opacity: 1;
}
.lightbox-content {
  margin: auto;
  display: block;
  max-width: 90%;
  max-height: 85%;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
  animation: lightboxZoom 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes lightboxZoom {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.lightbox-close {
  position: absolute;
  top: 24px;
  right: 24px;
  color: var(--text-secondary);
  font-size: 40px;
  font-weight: 300;
  cursor: pointer;
  transition: color 0.15s, transform 0.1s;
  background: none;
  border: none;
  outline: none;
}
.lightbox-close:hover {
  color: var(--text-primary);
  transform: scale(1.1);
}
.lightbox-close:active {
  transform: scale(0.9);
}

/* ── Linkify & Video Embeds ───────────────────────────────────────── */
.chat-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px dashed var(--accent);
  transition: color 0.15s, border-color 0.15s;
}
.chat-link:hover {
  color: #8f7ef9;
  border-bottom-style: solid;
}

.video-preview {
  margin-top: 8px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-base);
  max-width: 380px;
  width: 100%;
  aspect-ratio: 16 / 9;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
.video-preview iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
.video-preview video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

/* ─── Instagram Reel Preview ─────────────────────────────────────── */
.video-preview.instagram-reel-preview {
  aspect-ratio: auto;
  max-width: 320px;
  width: 100%;
  border-radius: 14px;
  background: #0d1017;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
}

.instagram-reel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: linear-gradient(180deg, rgba(26, 30, 42, 0.95), rgba(18, 21, 30, 0.9));
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.instagram-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.instagram-icon-badge {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(220, 39, 67, 0.35);
}

.instagram-title-text {
  font-size: 0.78rem;
  font-weight: 600;
  color: #f1f5f9;
  letter-spacing: -0.01em;
}

.instagram-open-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 500;
  color: #a5b4fc;
  text-decoration: none;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.25);
  transition: all 0.18s ease;
}

.instagram-open-link:hover {
  background: rgba(99, 102, 241, 0.25);
  color: #ffffff;
  border-color: rgba(99, 102, 241, 0.45);
  text-decoration: none;
  transform: translateY(-1px);
}

.instagram-frame-wrapper {
  position: relative;
  width: 100%;
  height: 460px;
  background: #000000;
  overflow: hidden;
}

.instagram-frame-wrapper iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

@media (max-width: 480px) {
  .video-preview.instagram-reel-preview {
    max-width: 100%;
  }
  .instagram-frame-wrapper {
    height: 420px;
  }
}

/* Spinner Animation */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
.spinner {
  animation: spin 0.8s linear infinite;
  display: inline-block;
  transform-origin: center;
}

/* ─── Image-Only Bubble ───────────────────────────────────────── */
.image-only-bubble {
  padding: 4px !important;
  background: transparent !important;
  box-shadow: none !important;
}
.image-only-bubble .msg-images-grid {
  margin-top: 0 !important;
}

/* ─── Context Menu Popper ──────────────────────────────────────── */
.ctx-menu {
  position: fixed;
  z-index: 9999;
  background: var(--bg-surface, #1e2030);
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.35), 0 2px 8px rgba(0,0,0,0.2);
  min-width: 164px;
  display: none;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  transform: scale(0.92);
  transform-origin: top left;
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.ctx-menu.active {
  display: flex;
  opacity: 1;
  transform: scale(1);
  animation: ctx-pop 0.15s ease forwards;
}
@keyframes ctx-pop {
  0% { opacity: 0; transform: scale(0.88); }
  100% { opacity: 1; transform: scale(1); }
}
.ctx-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: none;
  background: transparent;
  color: var(--text, #e2e4ef);
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
  white-space: nowrap;
}
.ctx-menu-item:hover {
  background: rgba(255,255,255,0.06);
}
.ctx-menu-item-danger { color: #f87171; }
.ctx-menu-item-danger:hover { background: rgba(239, 68, 68, 0.1); }
.ctx-menu-divider {
  height: 1px;
  background: var(--border, rgba(255,255,255,0.06));
  margin: 4px 6px;
}



/* ─── Lock Control Button & Dropdown ───────────────────────────── */
.lock-control-wrapper {
  position: relative;
  display: inline-block;
  z-index: 205;
}
.lock-menu-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border, #2a3044);
  color: var(--text-primary, #e8eaf2);
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 99px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, color 0.15s;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.lock-menu-btn:hover {
  background: var(--bg-hover, #252b3b);
  border-color: var(--accent-dim, #3d3578);
}
.lock-menu-btn.paused {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fbbf24;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.2);
}
.lock-chevron {
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  opacity: 0.65;
  flex-shrink: 0;
}
.lock-menu-btn[aria-expanded="true"] .lock-chevron,
.lock-dropdown.active ~ .lock-menu-btn .lock-chevron {
  transform: rotate(180deg);
  opacity: 1;
}
.lock-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 1000;
  background: rgba(22, 26, 35, 0.96);
  border: 1px solid var(--border, #2a3044);
  border-radius: var(--radius-md, 12px);
  padding: 8px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.06);
  min-width: 250px;
  flex-direction: column;
  gap: 3px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.lock-dropdown.active {
  display: flex;
  animation: lockDropIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes lockDropIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.lock-dropdown-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted, #4a5170);
  padding: 4px 8px 6px;
}
.lock-opt-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  background: none;
  border: none;
  border-radius: var(--radius-sm, 6px);
  color: var(--text-secondary, #7c849e);
  font-family: var(--font);
  font-size: 0.82rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, color 0.12s;
  user-select: none;
}
.lock-opt-btn .opt-icon {
  font-size: 0.95rem;
  line-height: 1;
}
.lock-opt-btn .opt-text {
  flex: 1;
}
.lock-opt-btn .opt-check {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent, #7c6af7);
  opacity: 0;
  transition: opacity 0.12s ease;
  margin-left: 6px;
}
.lock-opt-btn:hover {
  background: var(--bg-hover, #252b3b);
  color: var(--text-primary, #e8eaf2);
}
.lock-opt-btn.active {
  background: var(--accent-dim, #3d3578);
  color: #ffffff;
  font-weight: 600;
}
.lock-opt-btn.active .opt-check {
  opacity: 1;
  color: #ffffff;
}

/* ─── Mobile tweaks ────────────────────────────────────────────── */
@media (max-width: 640px) {
  .chat-header {
    height: calc(52px + env(safe-area-inset-top, 0px));
    padding: 0 10px;
    padding-top: env(safe-area-inset-top, 0px);
    gap: 6px;
    justify-content: space-between;
  }
  .chat-header-info {
    gap: 6px;
    min-width: 0;
    flex-shrink: 1;
  }
  .chat-room-name {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 85px;
  }
  .msg-row { max-width: 85%; }
  .ctx-menu { min-width: 150px; font-size: 13px; }
  .lock-menu-btn { font-size: 0.72rem; padding: 4px 8px; gap: 4px; flex-shrink: 0; }
  .lock-btn-text { display: none; }
  .lock-dropdown { left: auto; right: 0; min-width: 210px; }
  .online-badge {
    padding: 3px 8px;
    gap: 5px;
    max-width: 120px;
    font-size: 0.7rem;
    flex-shrink: 0;
    margin-left: 0;
  }
  .online-badge-name .badge-name {
    font-size: 0.7rem;
    max-width: 75px;
  }
  .online-badge-name .badge-status {
    font-size: 0.62rem;
  }
  /* Tighten footer for small screens */
  .chat-footer {
    padding-left: max(8px, env(safe-area-inset-left, 8px));
    padding-right: max(8px, env(safe-area-inset-right, 8px));
    gap: 6px;
  }
  .emoji-btn,
  .image-btn {
    width: 38px;
    height: 38px;
  }
  .send-btn {
    width: 38px;
    height: 38px;
  }
  .msg-input {
    padding: 9px 12px;
  }
}

@media (max-width: 400px) {
  .chat-room-name {
    display: none;
  }
}

/* ─── Image Library & Relationship Sidebar Buttons ─────────────────────────────── */
.gallery-btn {
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: rgba(124, 106, 247, 0.09);
  border: 1px solid rgba(124, 106, 247, 0.22);
  border-radius: var(--radius-md, 12px);
  color: var(--text-primary, #e8eaf2);
  font-family: var(--font, 'Inter', sans-serif);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  margin-top: 10px;
  transition: all 0.2s ease;
  min-height: 42px;
  box-sizing: border-box;
}

.gallery-btn:hover {
  background: rgba(124, 106, 247, 0.2);
  border-color: rgba(124, 106, 247, 0.45);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(124, 106, 247, 0.2);
}

.gallery-btn:active {
  transform: translateY(0);
}

.gallery-count-badge {
  margin-left: auto;
  background: var(--accent, #7c6af7);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  min-width: 20px;
  text-align: center;
}

.relationship-btn {
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.28);
  border-radius: var(--radius-md, 12px);
  color: #ffe4e6;
  font-family: var(--font, 'Inter', sans-serif);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  margin-top: 6px;
  transition: all 0.2s ease;
  min-height: 42px;
  box-sizing: border-box;
}

.relationship-btn svg {
  color: #f43f5e;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.relationship-btn:hover {
  background: rgba(244, 63, 94, 0.22);
  border-color: rgba(244, 63, 94, 0.55);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(244, 63, 94, 0.25);
}

.relationship-btn:hover svg {
  transform: scale(1.18);
}

.relationship-btn:active {
  transform: translateY(0);
}

/* ─── Image Library Overlay & Modal ─────────────────────────────── */
.library-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(8, 10, 15, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  padding: 20px;
  box-sizing: border-box;
}

.library-overlay.active {
  opacity: 1;
  visibility: visible;
}

.library-card {
  background: var(--bg-surface, #161a23);
  border: 1px solid rgba(124, 106, 247, 0.2);
  border-radius: 16px;
  width: 100%;
  max-width: 820px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 30px rgba(124, 106, 247, 0.1);
  overflow: hidden;
  transform: scale(0.94) translateY(10px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.library-overlay.active .library-card {
  transform: scale(1) translateY(0);
}

.library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(124, 106, 247, 0.12);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, transparent 100%);
  gap: 12px;
}

.library-title-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.library-title-wrapper svg {
  color: var(--accent, #7c6af7);
}

.library-title-wrapper h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary, #e8eaf2);
}

.library-count {
  font-size: 0.78rem;
  color: var(--text-muted, #7c849e);
  background: rgba(124, 106, 247, 0.1);
  padding: 3px 8px;
  border-radius: 10px;
}

.library-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.download-zip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #7c6af7 0%, #6352e8 100%);
  color: #ffffff;
  border: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-family: var(--font, 'Inter', sans-serif);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(124, 106, 247, 0.3);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.download-zip-btn:hover {
  background: linear-gradient(135deg, #8a79f9 0%, #6e5df0 100%);
  box-shadow: 0 6px 16px rgba(124, 106, 247, 0.45);
  transform: translateY(-1px);
}

.download-zip-btn:active {
  transform: translateY(0);
}

.download-zip-btn.downloading {
  opacity: 0.7;
  pointer-events: none;
  cursor: wait;
}

.clear-library-btn {
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.38);
  color: #fca5a5;
  padding: 8px 13px;
  border-radius: 8px;
  font-family: var(--font, 'Inter', sans-serif);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  box-sizing: border-box;
}

.clear-library-btn:hover {
  background: rgba(239, 68, 68, 0.32);
  color: #ffffff;
  border-color: #ef4444;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35);
  transform: translateY(-1px);
}

.clear-library-btn:active {
  transform: translateY(0);
}

.library-close-btn {
  background: none;
  border: none;
  color: var(--text-muted, #7c849e);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.library-close-btn:hover {
  color: var(--text-primary, #ffffff);
  background: rgba(255, 255, 255, 0.1);
}

/* ─── Library Body & Grid ───────────────────────────────────────── */
.library-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  min-height: 200px;
}

.library-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted, #7c849e);
  text-align: center;
  gap: 12px;
}

.library-empty svg {
  opacity: 0.4;
  color: var(--accent, #7c6af7);
}

.library-empty p {
  font-size: 0.92rem;
  margin: 0;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}

.library-item {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 1;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(124, 106, 247, 0.12);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.library-item:hover {
  transform: scale(1.03);
  border-color: rgba(124, 106, 247, 0.4);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.library-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.library-item:hover img {
  transform: scale(1.06);
}

.library-item-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.2) 50%, transparent 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 8px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.library-item:hover .library-item-overlay,
.library-item:focus-within .library-item-overlay {
  opacity: 1;
}

.library-item-sender {
  align-self: flex-start;
  font-size: 0.68rem;
  font-weight: 600;
  background: rgba(124, 106, 247, 0.85);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  backdrop-filter: blur(4px);
}

.library-item-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.library-item-date {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.85);
}

.library-item-dl-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #ffffff;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}

.library-item-dl-btn:hover {
  background: var(--accent, #7c6af7);
}

.library-item-btns {
  display: flex;
  align-items: center;
  gap: 6px;
}

.library-item-del-btn {
  background: rgba(239, 68, 68, 0.3);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #ff6b6b;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.library-item-del-btn:hover {
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

.library-item-video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-play-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: transform 0.2s ease, background 0.2s ease;
}

.library-item:hover .video-play-badge {
  transform: translate(-50%, -50%) scale(1.12);
  background: var(--accent, #7c6af7);
  border-color: #ffffff;
}

/* ─── In-Chat Video Player ───────────────────────────────────────── */
.chat-video {
  max-width: 100%;
  max-height: 340px;
  border-radius: 12px;
  display: block;
  margin-top: 4px;
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

/* ─── In-Chat Background Upload Progress Card ────────────────────── */
.upload-progress-row {
  margin-bottom: 10px;
}

.upload-progress-bubble {
  min-width: 240px;
  max-width: 320px;
  background: rgba(22, 26, 35, 0.95);
  border: 1px solid rgba(124, 106, 247, 0.3);
  padding: 12px 14px;
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.upload-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.upload-file-details {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary, #e8eaf2);
  overflow: hidden;
  white-space: nowrap;
}

.upload-video-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.upload-filename {
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-filesize {
  font-size: 0.74rem;
  color: var(--text-muted, #7c849e);
  flex-shrink: 0;
}

.upload-cancel-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text-muted, #7c849e);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.upload-cancel-btn:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #ff6b6b;
}

.upload-progress-bar-container {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}

.upload-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #7c6af7 0%, #a78bfa 100%);
  border-radius: 3px;
  transition: width 0.15s ease;
}

.upload-progress-status {
  display: flex;
  justify-content: flex-end;
}

.upload-progress-text {
  font-size: 0.72rem;
  color: var(--text-muted, #7c849e);
}

/* ─── Video Upload Preview Item ──────────────────────────────────── */
.upload-preview-video-item {
  width: 110px !important;
  height: 64px !important;
  background: rgba(124, 106, 247, 0.15);
  border: 1px dashed rgba(124, 106, 247, 0.4);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  box-sizing: border-box;
}

.video-preview-thumb {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-align: center;
  width: 100%;
  overflow: hidden;
}

.video-preview-thumb .vid-icon {
  font-size: 1.1rem;
}

.video-preview-thumb .vid-name {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-primary, #e8eaf2);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-preview-thumb .vid-size {
  font-size: 0.62rem;
  color: var(--text-muted, #7c849e);
}

/* ─── Lightbox Video Player ─────────────────────────────────────── */
.lightbox-video {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  outline: none;
  background: #000;
}

/* ═══════════════════════════════════════════════════════════════════
   RELATIONSHIP STATUS & ACTIVITY MODAL STYLING
   ═══════════════════════════════════════════════════════════════════ */
.rel-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(8, 10, 15, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 20px;
  box-sizing: border-box;
}

.rel-overlay.active {
  opacity: 1;
  visibility: visible;
}

.rel-card {
  background: linear-gradient(180deg, #181b26 0%, #12151e 100%);
  border: 1px solid rgba(244, 63, 94, 0.25);
  border-radius: 20px;
  width: 100%;
  max-width: 600px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6), 0 0 35px rgba(244, 63, 94, 0.12);
  overflow: hidden;
  box-sizing: border-box;
  transform: scale(0.94) translateY(12px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.rel-overlay.active .rel-card {
  transform: scale(1) translateY(0);
}

.rel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, transparent 100%);
  flex-shrink: 0;
  box-sizing: border-box;
}

.rel-title-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.rel-icon-badge {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid rgba(244, 63, 94, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: 0 0 16px rgba(244, 63, 94, 0.2);
}

.rel-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary, #e8eaf2);
  letter-spacing: -0.2px;
}

.rel-subtitle {
  font-size: 0.74rem;
  color: var(--text-muted, #7c849e);
  margin: 0;
}

.rel-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rel-refresh-btn,
.rel-close-btn {
  background: none;
  border: none;
  color: var(--text-muted, #7c849e);
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.rel-refresh-btn {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.rel-refresh-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary, #ffffff);
}
.rel-refresh-btn.rotating svg {
  animation: spin 0.8s linear infinite;
}

.rel-close-btn {
  font-size: 1.6rem;
  line-height: 1;
  padding: 4px 8px;
}
.rel-close-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.rel-body {
  padding: 16px 20px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1 1 auto;
  min-height: 0;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(244, 63, 94, 0.3) transparent;
}

/* Ensure cards inside relationship modal never get squashed or clipped */
.rel-body > * {
  flex-shrink: 0;
}

.rel-body::-webkit-scrollbar {
  width: 5px;
}

.rel-body::-webkit-scrollbar-track {
  background: transparent;
}

.rel-body::-webkit-scrollbar-thumb {
  background: rgba(244, 63, 94, 0.25);
  border-radius: 99px;
}

.rel-body::-webkit-scrollbar-thumb:hover {
  background: rgba(244, 63, 94, 0.5);
}

/* ── Timeframe Filter Bar ── */
.rel-filter-bar {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
}

.rel-filter-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted, #7c849e);
  padding: 8px 10px;
  border-radius: 8px;
  font-family: var(--font, 'Inter', sans-serif);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: center;
  white-space: nowrap;
}

.rel-filter-btn:hover {
  color: var(--text-primary, #ffffff);
  background: rgba(255, 255, 255, 0.06);
}

.rel-filter-btn.active {
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.85) 0%, rgba(225, 29, 72, 0.95) 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(244, 63, 94, 0.35);
}

/* ── Highlight Card: Together Time ── */
.rel-highlight-card {
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.15) 0%, rgba(124, 106, 247, 0.15) 100%);
  border: 1px solid rgba(244, 63, 94, 0.3);
  border-radius: 16px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 8px 24px rgba(244, 63, 94, 0.08);
}

.rel-highlight-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.rel-highlight-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #fca5a5;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f43f5e;
  box-shadow: 0 0 8px #f43f5e;
  animation: badgePulse 2s ease-in-out infinite;
}

.rel-live-badge {
  font-size: 0.72rem;
  font-weight: 600;
  color: #34d399;
  background: rgba(52, 211, 153, 0.15);
  border: 1px solid rgba(52, 211, 153, 0.3);
  padding: 3px 8px;
  border-radius: 12px;
}

.rel-live-badge.hidden { display: none; }

.rel-highlight-main {
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
}

.rel-highlight-val-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  flex: 1;
  min-width: 0;
}

.rel-highlight-label {
  font-size: 0.74rem;
  color: var(--text-muted, #9aa2bc);
  margin-bottom: 2px;
}

.rel-highlight-value {
  font-size: 1.65rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.5px;
  text-shadow: 0 0 16px rgba(244, 63, 94, 0.4);
}

.rel-highlight-value-sub {
  font-size: 1.35rem;
  font-weight: 600;
  color: #cbd5e1;
}

.rel-highlight-divider {
  width: 1px;
  height: 36px;
  background: rgba(255, 255, 255, 0.12);
}

/* ── Love Countdowner Card ── */
.love-countdown-card {
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.16) 0%, rgba(124, 106, 247, 0.2) 50%, rgba(236, 72, 153, 0.14) 100%);
  border: 1px solid rgba(244, 63, 94, 0.35);
  border-radius: 16px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 10px 30px -5px rgba(244, 63, 94, 0.18), 0 0 20px rgba(124, 106, 247, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
  width: 100%;
  flex-shrink: 0;
  min-height: fit-content;
}

.love-countdown-card::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at center, rgba(244, 63, 94, 0.08) 0%, transparent 60%);
  pointer-events: none;
}

.love-countdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
  box-sizing: border-box;
}

.love-countdown-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(244, 63, 94, 0.18);
  border: 1px solid rgba(244, 63, 94, 0.35);
  padding: 5px 12px;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #fda4af;
  box-shadow: 0 0 12px rgba(244, 63, 94, 0.2);
  line-height: 1.25;
  flex-shrink: 0;
}

.love-pulse-heart {
  display: inline-block;
  animation: loveHeartBeat 1.3s infinite ease-in-out;
  transform-origin: center;
}

@keyframes loveHeartBeat {
  0%, 100% { transform: scale(1); }
  25% { transform: scale(1.22); }
  40% { transform: scale(1.05); }
  60% { transform: scale(1.28); }
}

.love-anniv-tag {
  font-size: 0.74rem;
  color: #fda4af;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.06);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  line-height: 1.25;
  flex-shrink: 0;
}

.love-countdown-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.love-countdown-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.love-countdown-sub {
  font-size: 0.76rem;
  color: #cbd5e1;
  margin: 0;
  opacity: 0.9;
}

.love-timer-boxes {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  justify-content: center;
  gap: 3px;
  margin: 4px 0;
  width: 100%;
  box-sizing: border-box;
}

.love-box {
  min-width: 0;
  width: 100%;
  background: rgba(15, 18, 26, 0.78);
  border: 1px solid rgba(244, 63, 94, 0.25);
  border-radius: 8px;
  padding: 6px 2px 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 4px 12px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease, border-color 0.15s ease;
  overflow: hidden;
}

.love-box:hover {
  transform: translateY(-2px);
  border-color: rgba(244, 63, 94, 0.5);
}

.love-val {
  font-size: clamp(0.92rem, 3.2vw, 1.35rem);
  font-weight: 700;
  font-family: var(--font);
  color: #ffffff;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 10px rgba(244, 63, 94, 0.4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-align: center;
}

.love-lbl {
  font-size: clamp(0.48rem, 1.6vw, 0.62rem);
  font-weight: 700;
  color: #fda4af;
  letter-spacing: 0.04em;
  margin-top: 2px;
  text-transform: uppercase;
  white-space: nowrap;
}

.love-sep {
  font-size: clamp(0.85rem, 2.6vw, 1.2rem);
  font-weight: 800;
  color: #f43f5e;
  line-height: 1;
  margin: 0;
  padding: 0 1px;
  animation: sepPulse 1s infinite alternate ease-in-out;
  user-select: none;
  flex-shrink: 0;
}

@keyframes sepPulse {
  0% { opacity: 0.4; transform: scale(0.9); }
  100% { opacity: 1; transform: scale(1.1); }
}

.love-countdown-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.74rem;
  color: #fda4af;
  font-weight: 500;
  text-align: center;
  margin-top: 2px;
  background: rgba(244, 63, 94, 0.08);
  border-radius: 8px;
  padding: 6px 10px;
  border: 1px solid rgba(244, 63, 94, 0.15);
}

.love-footer-sparkle {
  color: #fbbf24;
  animation: sparkleRotate 2.5s infinite linear;
  display: inline-block;
}

@keyframes sparkleRotate {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.2); }
  100% { transform: rotate(360deg) scale(1); }
}

/* ── Relationship Harmony & Chemistry Card ── */
.rel-harmony-card {
  background: linear-gradient(135deg, rgba(124, 106, 247, 0.12) 0%, rgba(244, 63, 94, 0.08) 100%);
  border: 1px solid rgba(124, 106, 247, 0.22);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rel-harmony-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.rel-chemistry-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid rgba(244, 63, 94, 0.3);
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 0.76rem;
  font-weight: 600;
  color: #fda4af;
}

.rel-journey-tag {
  font-size: 0.72rem;
  color: var(--text-muted, #7c849e);
  font-weight: 500;
}

.rel-balance-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rel-balance-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.74rem;
}

.rel-balance-label {
  color: var(--text-secondary, #9aa2bc);
  font-weight: 500;
}

.rel-balance-detail {
  font-weight: 600;
  color: var(--text-primary, #e8eaf2);
}

.rel-balance-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  overflow: hidden;
  display: flex;
}

.rel-balance-fill-r {
  height: 100%;
  background: linear-gradient(90deg, #7c6af7, #a78bfa);
  transition: width 0.3s ease;
}

.rel-balance-fill-a {
  height: 100%;
  background: linear-gradient(90deg, #f43f5e, #fb7185);
  transition: width 0.3s ease;
}

.rel-balance-legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted, #7c849e);
}

.rel-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.legend-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.legend-dot.r { background: #a78bfa; }
.legend-dot.a { background: #fb7185; }

.rel-patience-tag {
  font-size: 0.68rem;
  color: #a78bfa;
  font-weight: 500;
}

/* ── Section Header ── */
.rel-section-header {
  display: flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted, #7c849e);
  margin-top: 2px;
}

/* ── User Comparison Cards Grid ── */
.rel-comparison-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.rel-user-card {
  background: var(--bg-surface, #161a23);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
}

.rel-user-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rel-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent, #7c6af7), #4f8ef7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.rel-user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.rel-user-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary, #e8eaf2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rel-user-status {
  font-size: 0.68rem;
  font-weight: 500;
}
.rel-user-status.online { color: var(--green, #3ecf8e); }
.rel-user-status.offline { color: var(--text-muted, #7c849e); }

.rel-stat-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rel-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
}

.rel-stat-label {
  color: var(--text-secondary, #7c849e);
}

.rel-stat-val {
  font-weight: 600;
  color: var(--text-primary, #e8eaf2);
}

.rel-stat-val.accent {
  color: #a78bfa;
}

.rel-stat-val.rose {
  color: #fb7185;
}

/* ── Milestones Card ── */
.rel-milestones-card {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 12px 14px;
}

.rel-milestone-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.milestone-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

.milestone-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.milestone-label {
  font-size: 0.68rem;
  color: var(--text-muted, #7c849e);
  white-space: nowrap;
}

.milestone-value {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary, #e8eaf2);
}

/* ─── Mobile Bottom Sheet Responsiveness for Modals ───────────── */
@media (max-width: 640px) {
  .library-overlay,
  .rel-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .library-card,
  .rel-card {
    max-height: 90vh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    transform: translateY(100%);
  }

  .library-overlay.active .library-card,
  .rel-overlay.active .rel-card {
    transform: translateY(0);
  }

  .library-header,
  .rel-header {
    padding: 14px 16px;
  }

  .library-title-wrapper h2,
  .rel-header h2 {
    font-size: 1rem;
  }

  .library-header-actions {
    gap: 6px;
  }

  .download-zip-btn,
  .clear-library-btn {
    padding: 6px 10px;
    font-size: 0.74rem;
    gap: 4px;
  }

  .library-grid {
    grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
    gap: 8px;
  }

  .library-item-overlay {
    opacity: 1;
    background: linear-gradient(0deg, rgba(0,0,0,0.75) 0%, transparent 60%);
  }

  .rel-comparison-grid {
    grid-template-columns: 1fr;
  }

  .rel-milestones-card {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .rel-milestones-card .rel-milestone-item:nth-child(3) {
    grid-column: span 2;
  }

  .rel-body {
    padding: 12px 14px 20px;
    gap: 12px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1 1 auto;
    min-height: 0;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
  }

  .rel-body > * {
    flex-shrink: 0;
  }

  .love-countdown-card {
    padding: 12px;
    gap: 10px;
    flex-shrink: 0;
    min-height: fit-content;
  }

  .love-timer-boxes {
    gap: 2px;
  }

  .love-box {
    padding: 5px 1px 4px;
    border-radius: 6px;
  }

  .love-val {
    font-size: clamp(0.82rem, 3.1vw, 1.05rem);
  }

  .love-lbl {
    font-size: 0.5rem;
    letter-spacing: 0.02em;
  }

  .love-sep {
    font-size: 0.8rem;
    padding: 0;
  }

  .love-anniv-tag {
    font-size: 0.68rem;
    padding: 2px 6px;
  }

  .rel-highlight-value {
    font-size: 1.4rem;
  }

  .rel-highlight-value-sub {
    font-size: 1.15rem;
  }

  /* GPU Acceleration on Chat Rows */
  .msg-row {
    contain: content;
  }
}

/* ── Global Typing Indicator ───────────────────────────────────────── */
.typing-indicator-container {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  font-size: 0.8rem;
  color: var(--text-secondary, #9aa2bc);
  background: rgba(22, 26, 35, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 12px;
  margin: 4px 16px 8px;
  align-self: flex-start;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  animation: fadeInTyping 0.2s ease;
  width: fit-content;
  z-index: 10;
}

.typing-indicator-container.active {
  display: flex;
}

@keyframes fadeInTyping {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
}

.typing-dots span {
  width: 5px;
  height: 5px;
  background: var(--accent, #7c6af7);
  border-radius: 50%;
  display: inline-block;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }
.typing-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.35; }
  40% { transform: scale(1.15); opacity: 1; }
}

/* ── Workspace Presence & Sidebar User Meta ───────────────────────── */
.sidebar-user-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.my-presence-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: #4ade80;
  font-weight: 500;
}

.my-presence-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.6);
  flex-shrink: 0;
}

.my-last-online-row {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  color: var(--text-muted, #7c849e);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.9;
  margin-top: 1px;
}

.my-last-online-row svg {
  flex-shrink: 0;
  stroke: var(--text-muted, #7c849e);
}

.users-presence-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
  margin-bottom: 8px;
}

.user-presence-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: all 0.2s ease;
}

.user-presence-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(124, 106, 247, 0.2);
  transform: translateY(-1px);
}

.user-presence-card.is-self {
  border-left: 3px solid var(--accent, #7c6af7);
}

.user-presence-card.is-online {
  border-color: rgba(74, 222, 128, 0.2);
}

.u-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(124, 106, 247, 0.7), rgba(99, 82, 232, 0.4));
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.u-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  gap: 2px;
}

.u-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.u-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary, #e8eaf2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.u-self-tag {
  font-size: 0.65rem;
  color: var(--accent, #7c6af7);
  background: rgba(124, 106, 247, 0.14);
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 4px;
  font-weight: 600;
}

.u-status-tag {
  font-size: 0.68rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.u-status-tag.online {
  color: #4ade80;
}

.u-status-tag.offline {
  color: var(--text-muted, #7c849e);
}

.u-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.u-dot.online {
  background: #4ade80;
  box-shadow: 0 0 5px rgba(74, 222, 128, 0.6);
}

.u-dot.offline {
  background: #64748b;
}

.u-meta-row {
  font-size: 0.68rem;
  color: var(--text-muted, #7c849e);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Device Limit Restriction Alert (Login) ────────────────────────── */
.error-msg.device-limit {
  min-height: auto;
  text-align: left;
  margin-top: 4px;
}

.device-limit-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 10px;
  padding: 10px 12px;
  color: #fca5a5;
  font-size: 0.82rem;
  line-height: 1.4;
  animation: shakeError 0.3s ease-in-out;
}

@keyframes shakeError {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

.device-limit-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
  line-height: 1;
}

.device-limit-text strong {
  display: block;
  font-weight: 700;
  color: #ef4444;
  margin-bottom: 2px;
  font-size: 0.85rem;
}

.device-limit-text p {
  margin: 0;
  font-size: 0.78rem;
  opacity: 0.95;
}

/* ── Header Online/Offline Badge Polish ───────────────────────────── */
.online-badge.badge-offline {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.online-badge.badge-offline .online-badge-dot {
  background: #64748b;
  box-shadow: none;
}

.online-badge.badge-offline .badge-status.offline-time {
  color: var(--text-muted, #94a3b8);
  font-size: 0.7rem;
}
