/* ============================================================
   ByteHub Chat Engine v2 – Premium UI
   ============================================================ */

/* ── Overlay ────────────────────────────────────────────────── */
.chat-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 9990;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.4s ease,
    visibility 0.4s ease;
}
.chat-drawer-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ── Drawer shell ───────────────────────────────────────────── */
.chat-drawer {
  position: fixed;
  top: 12px;
  right: -500px;
  bottom: 12px;
  width: 420px;
  max-width: calc(100vw - 24px);
  background: linear-gradient(
    160deg,
    rgba(18, 18, 28, 0.97) 0%,
    rgba(12, 12, 20, 0.99) 100%
  );
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 26px;
  box-shadow:
    0 40px 80px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: right 0.45s cubic-bezier(0.16, 1, 0.3, 1);
  font-family:
    "Poppins",
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  color: #fff;
}
.chat-drawer.active {
  right: 12px;
}

/* ── Header ─────────────────────────────────────────────────── */
.chat-header {
  height: 72px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.03);
  flex-shrink: 0;
}

.chat-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  flex: 1;
  background: linear-gradient(135deg, #fff 40%, #a0a0be 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-header .back-btn,
.chat-header .close-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.2rem;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.chat-header .back-btn:hover,
.chat-header .close-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  transform: scale(1.06);
}

/* ── Target user info in header ─────────────────────────────── */
.chat-target-info {
  display: none;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.chat-target-info img {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  object-fit: cover;
  border: 2px solid rgba(108, 99, 255, 0.5);
  flex-shrink: 0;
}

.chat-target-details {
  min-width: 0;
}

.chat-target-details .name {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.chat-target-details .status {
  font-size: 0.75rem;
  color: #777;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}
.chat-target-details .status.online {
  color: #4ade80;
  font-weight: 600;
}
.chat-target-details .status .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
  flex-shrink: 0;
}

/* ── View container (holds roster + active views) ────────────── */
.chat-view-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
}

/* ── Roster view ─────────────────────────────────────────────── */
.chat-roster-view {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  transform: translateX(0);
  transition: transform 0.38s cubic-bezier(0.16, 1, 0.3, 1);
  background: transparent;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}
.chat-roster-view::-webkit-scrollbar {
  width: 4px;
}
.chat-roster-view::-webkit-scrollbar-track {
  background: transparent;
}
.chat-roster-view::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

/* Search bar on roster */
.chat-search-bar {
  padding: 14px 18px 8px;
  position: sticky;
  top: 0;
  background: rgba(12, 12, 20, 0.95);
  backdrop-filter: blur(20px);
  z-index: 1;
}
.chat-search-bar input {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 10px 16px 10px 38px;
  color: #fff;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: all 0.2s ease;
}
.chat-search-bar input:focus {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(108, 99, 255, 0.5);
}
.chat-search-bar input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}
.chat-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255, 255, 255, 0.3);
  font-size: 1rem;
  pointer-events: none;
}
.chat-search-wrap {
  position: relative;
}

/* Roster item */
.roster-item {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  gap: 14px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition:
    background 0.2s ease,
    transform 0.2s ease;
  position: relative;
  overflow: hidden;
}
.roster-item::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(108, 99, 255, 0.06),
    transparent
  );
  opacity: 0;
  transition: opacity 0.3s ease;
}
.roster-item:hover::before {
  opacity: 1;
}
.roster-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.roster-avatar {
  position: relative;
  flex-shrink: 0;
}
.roster-avatar img {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.05);
}

.roster-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: linear-gradient(135deg, #ea4353, #c0392b);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid rgba(12, 12, 20, 1);
  box-shadow: 0 2px 8px rgba(234, 67, 83, 0.6);
}

.roster-online-dot {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #4ade80;
  border: 2px solid rgba(12, 12, 20, 1);
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.7);
}

.roster-content {
  flex: 1;
  min-width: 0;
}
.roster-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.roster-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.roster-time {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.3);
  white-space: nowrap;
  flex-shrink: 0;
}
.roster-preview {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 3px;
}
.roster-preview.unread {
  color: rgba(255, 255, 255, 0.85);
  font-weight: 600;
}
.roster-preview i {
  font-size: 0.9rem;
  vertical-align: middle;
  margin-right: 2px;
  color: rgba(255, 255, 255, 0.55);
}
.roster-preview.unread i {
  color: rgba(255, 255, 255, 0.8);
}

/* ── Active chat view ────────────────────────────────────────── */
.chat-active-view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.38s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

/* Message list */
.chat-history {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.08) transparent;
}
.chat-history::-webkit-scrollbar {
  width: 4px;
}
.chat-history::-webkit-scrollbar-track {
  background: transparent;
}
.chat-history::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
}

/* Date separator */
.chat-date-sep {
  text-align: center;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 10px 0;
  display: flex;
  align-items: center;
  gap: 12px;
}
.chat-date-sep::before,
.chat-date-sep::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.07);
}

/* Message wrapper */
.message-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 78%;
  margin-bottom: 2px;
  animation: msgPop 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

.message-wrapper.me {
  align-self: flex-end;
  align-items: flex-end;
}
.message-wrapper.them {
  align-self: flex-start;
  align-items: flex-start;
}

/* Consecutive messages get less gap */
.message-wrapper.me + .message-wrapper.me,
.message-wrapper.them + .message-wrapper.them {
  margin-top: -4px;
}

.message-bubble {
  padding: 11px 16px;
  font-size: 0.93rem;
  line-height: 1.55;
  word-break: break-word;
  max-width: 100%;
  position: relative;
}

.message-wrapper.me .message-bubble {
  background: linear-gradient(135deg, #7f56da 0%, #4b44d1 100%);
  border-radius: 18px 18px 4px 18px;
  color: #fff;
}

.message-wrapper.them .message-bubble {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 18px 18px 18px 4px;
  color: #ddd;
}

.message-time {
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.28);
  margin-top: 4px;
  letter-spacing: 0.03em;
}

/* Status tick (me side) */
.message-status {
  font-size: 0.75rem;
  margin-left: 4px;
  vertical-align: middle;
}
.message-status.sent {
  color: rgba(255, 255, 255, 0.4);
}
.message-status.read {
  color: #4ade80;
}

/* New icon-based tick system */
.msg-tick {
  font-size: 0.85rem;
  vertical-align: middle;
}
.tick-clock {
  color: rgba(255, 255, 255, 0.35);
}
.tick-sent {
  color: rgba(255, 255, 255, 0.45);
}
.tick-read {
  color: var(--primary-color, #7b5ea7);
}

/* Typing indicator bubble */
.typing-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px !important;
  min-width: 54px;
}
.typing-bubble span {
  width: 8px;
  height: 8px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-bubble span:nth-child(2) {
  animation-delay: 0.2s;
}
.typing-bubble span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  40% {
    transform: translateY(-7px);
    opacity: 1;
  }
}

/* File attachment bubble */
.message-file {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  min-width: 200px;
  max-width: 280px;
}
.message-file:hover {
  background: rgba(255, 255, 255, 0.09);
}
.message-file > i {
  font-size: 1.6rem;
  color: #7f56da;
  flex-shrink: 0;
}
.message-file-info {
  flex: 1;
  min-width: 0;
}
.message-file-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.message-file-size {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.4);
  margin-top: 2px;
}

/* Three-dot file menu */
.file-menu-wrap {
  position: relative;
  flex-shrink: 0;
}
.file-menu-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.18s;
}
.file-menu-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}
.file-menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: rgba(16, 16, 26, 0.98);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 6px;
  min-width: 130px;
  z-index: 200;
  display: none;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
}
.file-menu-dropdown.open {
  display: flex;
}
.file-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-family: inherit;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background 0.15s;
}
.file-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.file-menu-item i {
  font-size: 1rem;
  color: #7f56da;
  flex-shrink: 0;
}

/* Audio message */
.message-audio {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 14px;
  min-width: 220px;
}
.message-wrapper.me .message-audio {
  background: rgba(255, 255, 255, 0.12);
}
.message-wrapper.them .message-audio {
  background: rgba(255, 255, 255, 0.05);
}
.audio-play-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(108, 99, 255, 0.8);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  flex-shrink: 0;
  transition: all 0.2s;
}
.audio-play-btn:hover {
  background: rgba(108, 99, 255, 1);
  transform: scale(1.1);
}
.audio-waveform {
  flex: 1;
  height: 28px;
  display: flex;
  align-items: center;
  gap: 2px;
  overflow: hidden;
}
.audio-waveform span {
  display: inline-block;
  width: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.3);
  transition: background 0.2s;
  /* Height set inline per bar */
}

/* When playing — bars bounce like WhatsApp */
@keyframes barBounce {
  0%,
  100% {
    transform: scaleY(0.4);
  }
  50% {
    transform: scaleY(1.2);
  }
}

.audio-waveform.playing span {
  background: rgba(255, 255, 255, 0.9);
  animation: barBounce 0.7s ease-in-out infinite;
  transform-origin: bottom;
}
.audio-waveform.playing span:nth-child(1) {
  animation-delay: 0s;
}
.audio-waveform.playing span:nth-child(2) {
  animation-delay: 0.07s;
}
.audio-waveform.playing span:nth-child(3) {
  animation-delay: 0.14s;
}
.audio-waveform.playing span:nth-child(4) {
  animation-delay: 0.21s;
}
.audio-waveform.playing span:nth-child(5) {
  animation-delay: 0.28s;
}
.audio-waveform.playing span:nth-child(6) {
  animation-delay: 0.35s;
}
.audio-waveform.playing span:nth-child(7) {
  animation-delay: 0.14s;
}
.audio-waveform.playing span:nth-child(8) {
  animation-delay: 0.07s;
}
.audio-waveform.playing span:nth-child(9) {
  animation-delay: 0.21s;
}
.audio-waveform.playing span:nth-child(10) {
  animation-delay: 0s;
}
.audio-waveform.playing span:nth-child(11) {
  animation-delay: 0.35s;
}
.audio-waveform.playing span:nth-child(12) {
  animation-delay: 0.28s;
}
.audio-waveform.playing span:nth-child(13) {
  animation-delay: 0.14s;
}
.audio-waveform.playing span:nth-child(14) {
  animation-delay: 0.07s;
}
.audio-waveform.playing span:nth-child(15) {
  animation-delay: 0s;
}

.audio-duration {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.45);
}

/* ── Typing indicator ────────────────────────────────────────── */
.typing-indicator {
  display: none;
  align-self: flex-start;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 18px 18px 18px 4px;
  margin-bottom: 4px;
}
.typing-indicator.visible {
  display: flex;
}
.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  animation: typingBounce 1.2s infinite;
}
.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}
.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes typingBounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* ── Skeleton loader ─────────────────────────────────────────── */
@keyframes shimmer {
  0% {
    background-position: -400px 0;
  }
  100% {
    background-position: 400px 0;
  }
}

.skeleton-block {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.04) 25%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0.04) 75%
  );
  background-size: 800px 100%;
  animation: shimmer 1.6s infinite linear;
  border-radius: 10px;
}

/* Roster skeleton */
.skeleton-roster-item {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  gap: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.skeleton-avatar {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  flex-shrink: 0;
}
.skeleton-lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.skeleton-line {
  height: 12px;
}
.skeleton-line-short {
  width: 55%;
}
.skeleton-line-long {
  width: 80%;
}
.skeleton-line-tiny {
  width: 30%;
  height: 9px;
}

/* Message skeleton */
.skeleton-msg-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.skeleton-msg-wrap.right {
  align-items: flex-end;
}
.skeleton-msg-wrap.left {
  align-items: flex-start;
}
.skeleton-bubble {
  height: 40px;
  border-radius: 16px;
}
.skeleton-bubble.wide {
  width: 65%;
}
.skeleton-bubble.narrow {
  width: 40%;
}
.skeleton-time {
  width: 50px;
  height: 8px;
  margin-top: 2px;
}

/* ── Input area ──────────────────────────────────────────────── */
.chat-input-area {
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.02);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
}

/* Attachment + mic buttons */
.chat-attach-btn,
.chat-mic-btn {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  flex-shrink: 0;
  transition: all 0.2s ease;
}
.chat-attach-btn:hover,
.chat-mic-btn:hover {
  background: rgba(108, 99, 255, 0.2);
  border-color: rgba(108, 99, 255, 0.4);
  color: #fff;
}
.chat-mic-btn.recording {
  background: rgba(234, 67, 83, 0.2);
  border-color: rgba(234, 67, 83, 0.5);
  color: #ea4353;
  animation: micPulse 1s infinite;
}
@keyframes micPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(234, 67, 83, 0.4);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(234, 67, 83, 0);
  }
}

/* Input wrapper */
.chat-input-wrapper {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  min-height: 46px;
  transition: all 0.25s ease;
}
.chat-input-wrapper:focus-within {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(108, 99, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.12);
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  color: #fff;
  font-family: inherit;
  font-size: 0.93rem;
  outline: none;
  padding: 12px 0;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.5;
}
.chat-input::placeholder {
  color: rgba(255, 255, 255, 0.28);
}

/* Send button */
.chat-send-btn {
  width: 46px;
  height: 46px;
  border-radius: 15px;
  background: linear-gradient(135deg, #7f56da 0%, #4b44d1 100%);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.18s ease;
}
.chat-send-btn:hover {
  opacity: 0.85;
}
.chat-send-btn:active {
  opacity: 0.7;
  transform: scale(0.96);
}

/* Recording timer */
.chat-record-timer {
  font-size: 0.8rem;
  color: #ea4353;
  font-weight: 700;
  text-align: center;
  padding: 4px 0 0;
  display: none;
  letter-spacing: 0.05em;
}
.chat-record-timer.visible {
  display: block;
}

/* File preview strip */
.chat-file-preview {
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}
.chat-file-preview.visible {
  display: flex;
}
.file-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(108, 99, 255, 0.15);
  border: 1px solid rgba(108, 99, 255, 0.3);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.8rem;
  color: #c5c2ff;
  max-width: 160px;
}
.file-chip i {
  font-size: 1rem;
  flex-shrink: 0;
}
.file-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-chip-remove {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.7rem;
  flex-shrink: 0;
  margin-left: 2px;
  transition: background 0.2s;
}
.file-chip-remove:hover {
  background: rgba(234, 67, 83, 0.4);
  color: #fff;
}

/* ── Unread counter on sidebar (globalChatBadge) ─────────────── */
#globalChatBadge {
  display: inline-flex !important;
  visibility: hidden;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ea4353, #c0392b);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  padding: 0 4px;
  box-shadow: 0 2px 8px rgba(234, 67, 83, 0.6);
  position: absolute;
  top: -6px;
  right: -10px;
}
#globalChatBadge.has-unread {
  visibility: visible;
}

/* ── Scroll lock when chat is open ───────────────────────────── */
body.chat-open {
  overflow: hidden !important;
}

/* ── Mobile ──────────────────────────────────────────────────── */
@media (max-width: 500px) {
  .chat-drawer {
    top: 0;
    right: -100vw;
    bottom: 0;
    width: 100vw;
    max-width: 100vw;
    border-radius: 0;
    border: none;
  }
  .chat-drawer.active {
    right: 0;
  }
  .chat-header {
    height: 64px;
    padding: 0 16px;
  }
  .chat-history {
    padding: 16px 14px;
  }
  .chat-input-area {
    padding: 8px 8px;
    gap: 4px;
    width: 100vw;
    box-sizing: border-box;
  }
  .chat-attach-btn,
  .chat-mic-btn {
    width: 36px;
    height: 36px;
    font-size: 1rem;
    flex-shrink: 0;
  }
  .chat-send-btn {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
  }
  .chat-input-wrapper {
    min-height: 40px;
    padding: 0 10px;
    flex: 1 1 0%;
    min-width: 0;
  }
  .chat-input {
    font-size: 0.88rem;
    padding: 10px 0;
  }
  .chat-roster-view {
    width: 100%;
  }
}
