/* ===================================================
   PULSE CHAT v2.0 — Chat Styles (Telegram Desktop Match)
   =================================================== */

/* ===== CHAT LIST ITEMS ===== */
.chat-item {
  display: flex;
  align-items: center;
  height: var(--dialog-h);
  padding: var(--dialog-padding);
  gap: var(--space-2);
  cursor: pointer;
  transition: background-color var(--dur-150) var(--easing-standard), transform var(--dur-100) var(--easing-standard);
  position: relative;
  margin: 2px 6px;
  border-radius: 12px;
}
.chat-item:hover { background: var(--bg-hover); }
.chat-item:active { transform: scale(calc(1 - (0.02 * var(--motion-level)))); }
.chat-item.active { background: var(--bg-active); }
.chat-item.active .chat-item-name { color: var(--active-name); }
.chat-item.active .chat-item-preview { color: var(--active-text); }
.chat-item.active .chat-item-time { color: var(--active-date) !important; }
.chat-item.active .chat-item-preview .sender { color: var(--active-text); }
.chat-item.active .badge { background: rgba(255,255,255,0.3); }

.chat-item-avatar {
  width: var(--dialog-photo);
  height: var(--dialog-photo);
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  position: relative;
  overflow: visible;
}
.chat-item-avatar > div { border-radius: 50%; overflow: hidden; }

.avatar-online {
  position: absolute;
  bottom: 0; right: 0;
  width: var(--online-size);
  height: var(--online-size);
  background: var(--online);
  border: var(--online-stroke) solid var(--bg-1);
  border-radius: 50%;
  z-index: 1;
}

.chat-item-body {
  flex: 1;
  min-width: 0;
  padding: var(--space-1) 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-1);
}

.chat-item-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.chat-item-name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  color: var(--text-0);
  line-height: 1.25;
}

.chat-item-time {
  font-size: var(--font-size-xs);
  color: var(--text-date);
  flex-shrink: 0;
  margin-left: 8px;
  line-height: 1.25;
}
.chat-item.unread .chat-item-time { color: var(--accent); font-weight: 500; }

.chat-item-bottom {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.chat-item-preview {
  font-size: var(--font-size);
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  line-height: 1.3;
}
.chat-item-preview .sender { color: var(--accent); font-weight: 500; }

.chat-item-meta {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
  margin-left: var(--space-2);
}

/* ===== DATE SEPARATOR ===== */
.date-separator {
  display: flex;
  justify-content: center;
  padding: var(--space-2) 0;
}
.date-separator span {
  background: rgba(0,0,0,0.3);
  color: #fff;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius);
  font-size: var(--font-size);
  font-weight: 500;
}
[data-theme="light"] .date-separator span {
  background: rgba(0,0,0,0.12);
  color: #fff;
  background: #517da2;
}

/* ===== MESSAGE ROWS ===== */
.msg-row {
  display: flex;
  margin-bottom: 2px;
  max-width: var(--msg-max-w);
  animation: msgIn var(--dur-200) var(--easing-standard);
  padding: 0 var(--msg-margin-left);
}
.msg-row.own { align-self: flex-end; }
.msg-row.other { align-self: flex-start; }
.msg-row.own + .msg-row.other,
.msg-row.other + .msg-row.own { margin-top: var(--space-2); }

/* ===== MESSAGE BUBBLE ===== */
.msg-bubble {
  padding: var(--msg-padding);
  border-radius: var(--radius-bubble-lg);
  position: relative;
  max-width: 100%;
  min-width: var(--msg-min-w);
  word-wrap: break-word;
  line-height: 1.35;
  transition: background-color var(--dur-200) var(--easing-standard), transform var(--dur-150) var(--easing-standard), box-shadow var(--dur-200) var(--easing-standard);
}
.msg-row.own .msg-bubble {
  background: var(--bubble-own);
  border-bottom-right-radius: var(--radius-bubble-sm);
}
.msg-row.other .msg-bubble {
  background: var(--bubble-other);
  border-bottom-left-radius: var(--radius-bubble-sm);
}
[data-theme="light"] .msg-row.other .msg-bubble {
  border: 1px solid var(--divider);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

/* Sender name in groups */
.msg-sender {
  font-size: var(--font-size);
  font-weight: 600;
  margin-bottom: 2px;
}

/* Message text */
.msg-text {
  font-size: var(--font-size);
  line-height: 1.35;
  white-space: pre-wrap;
}

/* Footer: time + status */
.msg-footer {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  margin-left: 10px;
  float: right;
  position: relative;
  top: 5px;
}
.msg-time {
  font-size: var(--font-size-xs);
  color: var(--text-3);
}
.msg-status { font-size: var(--font-size-sm); }
.msg-status.read { color: var(--accent); }

/* Reply in bubble */
.msg-reply {
  background: var(--surface);
  border-left: 2px solid var(--reply-bar);
  border-radius: 4px;
  padding: var(--space-1) var(--space-2);
  margin-bottom: var(--space-1);
  cursor: pointer;
}
.msg-reply-name { font-size: var(--font-size-sm); font-weight: 600; color: var(--accent); }
.msg-reply-text { font-size: var(--font-size); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Forwarded */
.msg-forwarded { font-size: var(--font-size-sm); color: var(--accent); font-weight: 500; margin-bottom: 3px; font-style: italic; }

/* ===== REACTIONS ===== */
.msg-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reaction-chip { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; border-radius: 12px; font-size: 14px; background: var(--surface); border: 1px solid var(--divider); cursor: pointer; transition: all 0.15s; user-select: none; }
.reaction-chip { transition: background-color var(--dur-150) var(--easing-standard), border-color var(--dur-150) var(--easing-standard), transform var(--dur-150) var(--easing-standard); }
.reaction-chip:hover { background: var(--surface-hover); }
.reaction-chip:active { transform: scale(calc(1 - (0.03 * var(--motion-level)))); }
.reaction-chip.my { background: var(--accent-soft); border-color: var(--accent); }
.reaction-picker { position: fixed; display: flex; gap: 2px; padding: 6px 10px; background: var(--bg-2); border: 1px solid var(--divider); border-radius: 24px; box-shadow: var(--shadow); z-index: 300; animation: fadeScale var(--dur-150) var(--easing-standard); }
.reaction-pick-btn { font-size: 22px; cursor: pointer; padding: var(--space-1); border-radius: var(--space-2); transition: background-color var(--dur-100) var(--easing-standard), transform var(--dur-100) var(--easing-standard); }
.reaction-pick-btn:hover { background: var(--surface-hover); transform: scale(1.2); }

/* ===== PINNED BAR (TG-style) ===== */
.pinned-bar {
  display: flex;
  align-items: center;
  padding: 7px var(--space-3);
  background: var(--bg-1);
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  z-index: 2;
  position: relative;
  transition: background-color var(--dur-150) var(--easing-standard);
  gap: 10px;
  animation: slideDown var(--dur-200) var(--easing-standard);
}
.pinned-bar:hover { background: var(--bg-hover); }
.pinned-bar-accent {
  width: 3px;
  height: 34px;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
}
.pinned-bar-content { flex: 1; min-width: 0; }
.pinned-bar-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 1px;
}
.pinned-bar-text {
  font-size: 13px;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== SCROLL TO BOTTOM ===== */
.scroll-to-bottom { position: absolute; bottom: 70px; right: var(--space-4); width: 40px; height: 40px; border-radius: 50%; background: var(--bg-1); border: 1px solid var(--divider); display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 3; opacity: 0; pointer-events: none; transition: opacity var(--dur-200) var(--easing-standard), transform var(--dur-200) var(--easing-standard); transform: translateY(10px); box-shadow: var(--shadow-sm); }
.scroll-to-bottom.visible { opacity: 1; pointer-events: auto; transform: translateY(0); }
.scroll-to-bottom i { font-size: 16px; color: var(--text-2); }
.scroll-badge { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--accent); color: #fff; font-size: var(--font-size-xs); font-weight: 600; display: flex; align-items: center; justify-content: center; padding: 0 4px; }

/* ===== SEARCH IN CHAT ===== */
.chat-search-panel { display: flex; align-items: center; gap: var(--space-2); padding: 6px var(--space-3); background: var(--bg-1); border-bottom: 1px solid var(--divider); z-index: 2; animation: slideDown var(--dur-200) var(--easing-standard); }
.chat-search-panel input { flex: 1; height: 35px; background: var(--input-bg); border: 1px solid var(--input-border); border-radius: var(--radius-input); padding: 0 14px; font-size: var(--font-size); color: var(--text-0); }
.chat-search-panel input:focus { border-color: var(--accent); }
.chat-search-panel input:focus-visible { box-shadow: var(--focus-ring); }
.chat-search-panel input::placeholder { color: var(--text-2); }

/* ===== EMOJI PICKER ===== */
.emoji-picker-panel { padding: var(--space-2) var(--space-3); background: var(--bg-1); border-top: 1px solid var(--divider); z-index: 2; }
.emoji-grid { display: flex; flex-wrap: wrap; gap: 2px; justify-content: center; }
.emoji-grid span { width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; font-size: 22px; cursor: pointer; border-radius: 10px; transition: background var(--dur-100) var(--easing-standard), transform var(--dur-100) var(--easing-standard); }
.emoji-grid span:hover { background: var(--surface-hover); transform: scale(1.15); }

/* ===== INFO PANEL (TG-style right panel) ===== */
.info-panel-overlay {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: 380px;
  z-index: 30;
  background: var(--bg-1);
  transform: translateX(100%);
  transition: transform var(--transition-slow);
  overflow-y: auto;
  border-left: 1px solid var(--divider);
  box-shadow: -2px 0 16px rgba(0,0,0,0.15);
}
.info-panel-overlay.active { transform: translateX(0); }

@media (max-width: 1024px) {
  .info-panel-overlay {
    width: min(380px, 92vw);
  }
}

@media (max-width: 768px) {
  .info-panel-overlay {
    width: 100%;
    max-width: 100%;
    border-left: none;
  }
}

.info-panel-avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 24px 20px;
  background: var(--bg-1);
}
.info-panel-avatar {
  width: 120px; height: 120px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 42px; font-weight: 700;
  margin-bottom: 16px;
}
.info-panel-name {
  font-size: 20px; font-weight: 700;
  text-align: center;
}
.info-panel-status {
  font-size: 14px; color: var(--text-2);
  margin-top: 4px;
}
.info-panel-status.online { color: var(--online); }

/* Info rows (like TG profile) */
.info-row {
  display: flex;
  align-items: center;
  padding: 12px 24px;
  gap: 24px;
  cursor: pointer;
  transition: background 0.12s;
}
.info-row:hover { background: var(--bg-hover); }
.info-row-icon {
  width: 24px;
  text-align: center;
  color: var(--text-2);
  font-size: 20px;
  flex-shrink: 0;
}
.info-row-content { flex: 1; min-width: 0; }
.info-row-value {
  font-size: 15px;
  color: var(--text-0);
}
.info-row-label {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 1px;
}

/* ===== Liquid glass pass ===== */
.msg-bubble {
  border: 1px solid var(--glass-border);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: var(--liquid-inner-shadow);
  overflow: hidden;
}

.msg-bubble::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: var(--liquid-sheen);
  opacity: 0.35;
}

.pinned-bar,
.chat-search-panel,
.reaction-picker,
.scroll-to-bottom {
  -webkit-backdrop-filter: var(--glass-blur-sm);
  backdrop-filter: var(--glass-blur-sm);
  background: var(--glass-bg-menu);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

/* ===== MEDIA IN MESSAGES ===== */
.msg-media {
  margin-bottom: 2px;
  border-radius: 12px;
  overflow: hidden;
  max-width: 340px;
  position: relative;
}
.msg-media img {
  display: block;
  width: 100%;
  max-height: 400px;
  border-radius: 12px;
  cursor: pointer;
  transition: opacity 0.15s;
  object-fit: cover;
}
.msg-media img:hover { opacity: 0.9; }
.msg-media video {
  max-width: 100%;
  max-height: 400px;
  border-radius: 12px;
}
/* TG-style time overlay on images */
.msg-media-time {
  position: absolute;
  bottom: 6px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  background: rgba(0,0,0,0.45);
  border-radius: 10px;
  font-size: 11px;
  color: #fff;
  pointer-events: none;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.msg-media-time .msg-status { font-size: 11px; color: rgba(255,255,255,0.7); }
.msg-media-time .msg-status.read { color: #fff; }

/* Image-only bubble (no text, no padding) */
.msg-bubble.media-only {
  padding: 0;
  background: transparent !important;
  border: none !important;
  min-width: auto;
  box-shadow: none;
}
.msg-bubble.media-only .msg-media { margin-bottom: 0; }

/* File card in bubble */
.msg-file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border-radius: 8px;
  margin-bottom: 4px;
  cursor: pointer;
  transition: background 0.12s;
  text-decoration: none;
  color: inherit;
}
.msg-file-card:hover { background: var(--surface-hover); }
.msg-file-card > i:first-child {
  font-size: 28px;
  color: var(--accent);
  flex-shrink: 0;
  width: 32px;
  text-align: center;
}
.msg-file-info { flex: 1; min-width: 0; }
.msg-file-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-file-size {
  font-size: 12px;
  color: var(--accent);
}

/* Media preview bar (before sending) */
.media-preview {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-1);
  border-top: 1px solid var(--divider);
  gap: 8px;
  z-index: 2;
}
.media-preview-content {
  flex: 1;
  display: flex;
  align-items: center;
  min-width: 0;
}
.media-preview-content img {
  border-radius: 6px;
  flex-shrink: 0;
}

/* Lightbox overlay */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  animation: fadeScale 0.2s ease;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.lightbox-img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  object-fit: contain;
}
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}
.lightbox-close:hover { background: rgba(255,255,255,0.2); }

/* ===== FORWARD MODAL ===== */
.forward-list { max-height: 300px; overflow-y: auto; margin: 16px 0; }
.forward-chat-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius); cursor: pointer; transition: background 0.12s; }
.forward-chat-item:hover { background: var(--bg-hover); }

@media (max-width: 768px) {
  .msg-row { max-width: 88%; padding: 0 8px; }
  .info-panel-overlay { width: 100% !important; }
}

/* ===== VOICE RECORDING BAR ===== */
.voice-record-bar {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  padding-bottom: calc(8px + var(--safe-bottom));
  background: var(--bg-1);
  border-top: 1px solid var(--divider);
  gap: 12px;
  z-index: 2;
  animation: slideDown 0.15s ease;
}
.voice-record-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}
.voice-record-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--danger);
  animation: voicePulse 1s ease-in-out infinite;
}
@keyframes voicePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}
.voice-record-timer {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 36px;
  color: var(--danger);
}
.voice-record-slide {
  flex: 1;
  text-align: center;
  font-size: 13px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  animation: slideHint 1.5s ease-in-out infinite;
}
@keyframes slideHint {
  0%, 100% { opacity: 0.5; transform: translateX(0); }
  50% { opacity: 1; transform: translateX(-8px); }
}
.voice-record-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  border: none;
  cursor: pointer;
  transition: transform 0.1s;
}
.voice-record-send:active { transform: scale(0.9); }
.voice-record-cancel {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: none;
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  border: none;
  cursor: pointer;
  transition: background 0.12s;
}
.voice-record-cancel:hover { background: rgba(229,87,87,0.1); }

/* ===== VOICE PLAYER (in bubble) ===== */
.voice-player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  min-width: 200px;
  max-width: 280px;
}
.voice-play-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  border: none;
  cursor: pointer;
  transition: transform 0.1s, background 0.12s;
}
.voice-play-btn:hover { background: var(--accent-dark); }
.voice-play-btn:active { transform: scale(0.9); }

.voice-wave {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 28px;
  min-width: 0;
}
.voice-bar {
  width: 3px;
  min-height: 3px;
  border-radius: 2px;
  background: var(--text-3);
  transition: background 0.15s, height 0.1s;
  flex-shrink: 0;
}
.voice-bar.active {
  background: var(--accent);
}
/* Own bubble bars */
.msg-row.own .voice-bar {
  background: rgba(255,255,255,0.3);
}
.msg-row.own .voice-bar.active {
  background: rgba(255,255,255,0.85);
}
.msg-row.own .voice-play-btn {
  background: rgba(255,255,255,0.2);
}
.msg-row.own .voice-play-btn:hover {
  background: rgba(255,255,255,0.3);
}

.voice-duration {
  font-size: 12px;
  color: var(--text-2);
  flex-shrink: 0;
  min-width: 32px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.msg-row.own .voice-duration {
  color: rgba(255,255,255,0.6);
}

/* ===== POLLS ===== */
.poll-container {
  min-width: 240px;
  max-width: 320px;
  padding: 4px 0;
}
.poll-question {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 10px;
  line-height: 1.35;
}
.poll-option {
  position: relative;
  padding: 10px 12px;
  margin-bottom: 6px;
  border-radius: 8px;
  border: 1px solid var(--divider);
  cursor: pointer;
  transition: all 0.2s;
  overflow: hidden;
  display: flex;
  align-items: center;
}
.poll-option:hover { border-color: var(--accent); }
.poll-option-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: var(--accent-soft);
  border-radius: 8px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 0;
}
.poll-option.voted .poll-option-fill { background: var(--accent-soft); }
.poll-option-text {
  position: relative;
  z-index: 1;
  font-size: 14px;
  flex: 1;
}
.poll-option-pct {
  position: relative;
  z-index: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  margin-left: 8px;
  min-width: 36px;
  text-align: right;
}
.poll-option-check {
  position: relative;
  z-index: 1;
  font-size: 12px;
  color: var(--accent);
  margin-left: 6px;
}
.poll-option.voted {
  border-color: var(--accent);
}
.poll-footer {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--divider);
}
.msg-row.own .poll-option { border-color: rgba(255,255,255,0.15); }
.msg-row.own .poll-option:hover { border-color: rgba(255,255,255,0.4); }
.msg-row.own .poll-option-fill { background: rgba(255,255,255,0.12); }
.msg-row.own .poll-option-pct { color: rgba(255,255,255,0.8); }
.msg-row.own .poll-option-check { color: rgba(255,255,255,0.8); }
.msg-row.own .poll-footer { border-top-color: rgba(255,255,255,0.1); color: rgba(255,255,255,0.5); }

/* ===== LINK PREVIEW ===== */
.link-preview-slot { margin-top: 6px; }
.link-preview-card {
  display: block;
  border: 1px solid var(--divider);
  border-radius: 10px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: background 0.12s;
  border-left: 3px solid var(--accent);
}
.link-preview-card:hover { background: var(--surface-hover); }
.link-preview-img img {
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  display: block;
}
.link-preview-body { padding: 8px 10px; }
.link-preview-site {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 2px;
}
.link-preview-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.link-preview-desc {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.msg-row.own .link-preview-card { border-color: rgba(255,255,255,0.15); border-left-color: rgba(255,255,255,0.5); }
.msg-row.own .link-preview-site { color: rgba(255,255,255,0.7); }

/* ===== @MENTIONS DROPDOWN ===== */
.mention-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: var(--bg-2);
  border: 1px solid var(--divider);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow);
  z-index: 50;
  max-height: 220px;
  overflow-y: auto;
  display: none;
}
.mention-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.1s;
}
.mention-item:hover, .mention-item.active {
  background: var(--bg-hover);
}
.mention-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; color: #fff;
  flex-shrink: 0;
}
.mention-name { font-size: 14px; font-weight: 600; }
.mention-username { font-size: 13px; color: var(--text-2); }

/* Highlighted @mention in message text */
.msg-mention {
  color: var(--accent);
  font-weight: 500;
  cursor: pointer;
}
.msg-mention:hover { text-decoration: underline; }

/* ===== ATTACH MENU ===== */
.attach-menu {
  position: fixed;
  background: var(--bg-2);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px 0;
  z-index: 200;
  min-width: 200px;
  animation: fadeScale 0.15s ease;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}
.attach-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.1s;
}
.attach-menu-item:hover { background: var(--bg-hover); }
.attach-menu-item i { width: 22px; text-align: center; font-size: 18px; }

/* ===== GLOBAL MEDIA PLAYER BAR ===== */
.global-player {
  display: none;
  align-items: center;
  height: 46px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--divider);
  padding: 0 8px;
  gap: 4px;
  flex-shrink: 0;
  z-index: 15;
  position: relative;
  width: 100%;
}
.gp-progress-track {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: var(--divider);
  cursor: pointer;
}
.gp-progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.2s linear;
  border-radius: 0 2px 2px 0;
}
.gp-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--text-2);
  border: none; background: none; cursor: pointer;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}
.gp-btn:hover { background: var(--bg-hover); color: var(--text-0); }
.gp-play {
  font-size: 16px;
  color: var(--accent);
}
.gp-info {
  flex: 1; min-width: 0;
  padding: 0 4px;
}
.gp-title {
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gp-artist {
  font-size: 11px; color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gp-time {
  font-size: 12px; color: var(--text-2);
  font-variant-numeric: tabular-nums;
  min-width: 32px; text-align: right;
  flex-shrink: 0;
}

/* ===== AUDIO CARD IN BUBBLE ===== */
.msg-audio-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  cursor: pointer;
  min-width: 200px;
  max-width: 280px;
  border-radius: 8px;
  transition: background 0.12s;
}
.msg-audio-card:hover { background: var(--surface-hover); }

/* ===== CUSTOM VIDEO PLAYER ===== */
.custom-video {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  max-width: 340px;
  background: #000;
}
.custom-video video {
  display: block;
  width: 100%;
  max-height: 400px;
  cursor: pointer;
}
.cv-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.25);
  transition: opacity 0.2s;
}
.cv-play {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  border: none; cursor: pointer;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  transition: transform 0.15s;
}
.cv-play:hover { transform: scale(1.08); }
.cv-controls {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: linear-gradient(transparent, rgba(0,0,0,0.6));
}
.cv-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: #fff;
  border: none; background: none; cursor: pointer;
  flex-shrink: 0;
}
.cv-btn:hover { background: rgba(255,255,255,0.15); }
.cv-progress {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.25);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
}
.cv-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  transition: width 0.15s linear;
}
.cv-time {
  font-size: 11px;
  color: rgba(255,255,255,0.8);
  font-variant-numeric: tabular-nums;
  min-width: 28px;
  text-align: right;
}

/* ===== CALL SCREEN ===== */
.call-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-0);
  z-index: 9999;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  animation: fadeScale 0.25s ease;
}
.call-info {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.call-avatar {
  width: 96px; height: 96px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 36px; font-weight: 600;
  margin-bottom: 8px;
}
.call-screen[data-state="ringing"] .call-avatar {
  animation: callPulse 1.5s ease-in-out infinite;
}
@keyframes callPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(106,178,242,0.4); }
  50% { box-shadow: 0 0 0 20px rgba(106,178,242,0); }
}
.call-name {
  font-size: 22px;
  font-weight: 600;
}
.call-status {
  font-size: 15px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.call-type {
  font-size: 13px;
  color: var(--accent);
}
.call-controls {
  display: flex;
  gap: 20px;
  margin-top: 32px;
}
.call-btn {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-0);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  border: none; cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.call-btn:hover { background: var(--bg-hover); }
.call-btn:active { transform: scale(0.92); }
.call-btn-active {
  background: var(--accent) !important;
  color: #fff !important;
}
.call-btn-end {
  background: var(--danger);
  color: #fff;
}
.call-btn-end:hover { background: #c0392b; }
.call-btn-reject {
  background: var(--danger);
  color: #fff;
}
.call-btn-accept {
  background: #27ae60;
  color: #fff;
}
.call-btn-accept:hover { background: #219a52; }

/* Local video (PiP style) */
#callLocalVideo {
  position: fixed;
  bottom: 100px; right: 20px;
  width: 140px;
  border-radius: 12px;
  z-index: 10000;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  cursor: move;
}

/* Call buttons in header */
.call-header-btn { color: var(--accent) !important; }
.call-header-btn:hover { background: var(--accent-soft) !important; }
