* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0f172a;
  color: #e5e7eb;
}

.app {
  display: flex;
  height: 100vh;
}

.sidebar {
  width: 360px;
  background: #111827;
  border-right: 1px solid #253044;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 16px;
}

.sidebar-header h1 {
  margin: 0 0 12px;
  font-size: 24px;
}

#searchInput {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #374151;
  background: #020617;
  color: white;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 0 16px 12px;
}

.tab {
  border: 0;
  background: #1f2937;
  color: #cbd5e1;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.tab.active {
  background: #2563eb;
  color: white;
}

.dialogs {
  overflow-y: auto;
  flex: 1;
}

.dialog {
  padding: 12px 16px;
  border-bottom: 1px solid #1f2937;
  cursor: pointer;
}

.dialog:hover,
.dialog.active {
  background: #1e293b;
}

.dialog-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.dialog-meta {
  font-size: 12px;
  color: #94a3b8;
  margin-bottom: 4px;
}

.dialog-preview {
  font-size: 14px;
  color: #cbd5e1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #0b1120;
}

.chat-header {
  height: 64px;
  padding: 14px 20px;
  border-bottom: 1px solid #253044;
  background: #111827;
  display: flex;
  align-items: center;
  font-weight: 700;
}

.placeholder {
  color: #94a3b8;
}

.messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

.message {
  max-width: 760px;
  margin-bottom: 14px;
}

.message-author {
  font-size: 13px;
  color: #93c5fd;
  margin-bottom: 4px;
}

.bubble {
  display: inline-block;
  background: #1f2937;
  padding: 10px 12px;
  border-radius: 14px;
  white-space: normal;
  line-height: 1.35;
}

.message-text {

  white-space: pre-wrap;

}

.message-time {
  font-size: 11px;
  color: #64748b;
  margin-top: 4px;
}

.media {
  margin-top: 8px;
  max-width: 420px;
  border-radius: 12px;
  overflow: hidden;
}

.media img,
.media video {
  max-width: 100%;
  border-radius: 12px;
}

.file-link {
  display: inline-block;
  margin-top: 8px;
  color: #93c5fd;
  text-decoration: none;
}

.message-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 48px;
  margin-top: 18px;
}

.avatar-fallback {
  background: #334155;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.message {
  max-width: 760px;
  margin-bottom: 0;
}

.dialog {
  display: flex;
  gap: 12px;
  align-items: center;
}

.dialog-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 48px;
}

.dialog-avatar-fallback {
  background: #334155;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.dialog-body {
  min-width: 0;
  flex: 1;
}

.dialog {
  display: flex;
  gap: 12px;
  align-items: center;
}

.dialog-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 52px;
}

.dialog-avatar-fallback {
  background: #334155;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.dialog-body {
  min-width: 0;
  flex: 1;
}

.avatar {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
}

.message-author {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}

.message-name {
  font-size: 15px;
  font-weight: 700;
  color: #dbeafe;
}

.message-username {
  font-size: 12px;
  color: #64748b;
  font-weight: 500;
}

.avatar-fallback {
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 20px;
}

.avatar-color-0 { background: #ef4444; }
.avatar-color-1 { background: #f97316; }
.avatar-color-2 { background: #eab308; }
.avatar-color-3 { background: #22c55e; }
.avatar-color-4 { background: #14b8a6; }
.avatar-color-5 { background: #3b82f6; }
.avatar-color-6 { background: #8b5cf6; }
.avatar-color-7 { background: #ec4899; }

.image-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  cursor: zoom-out;
}

.image-modal img {
  max-width: 90%;
  max-height: 90%;
  border-radius: 8px;
}

.clickable-avatar {
  cursor: zoom-in;
  transition: transform 0.15s ease;
}

.clickable-avatar:hover {
  transform: scale(1.05);
}

.chat-header {
  gap: 12px;
}

.header-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 52px;
}

.tg-audio-player {
  margin-top: 12px;
  width: 420px;
  max-width: 100%;
  height: 54px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #2b3442;
  border-radius: 999px;
  padding: 0 14px;
}

.tg-play-btn {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #ffffff;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tg-audio-time {
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  min-width: 38px;
  text-align: center;
}

.tg-audio-range {
  flex: 1;
  accent-color: #60a5fa;
  cursor: pointer;
}

.tg-voice {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 330px;
  max-width: 420px;
  padding: 4px 2px;
}

.tg-voice-play {
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: #39a7f7;
  color: #fff;
  font-size: 26px;
  cursor: pointer;
  flex: 0 0 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tg-voice-body {
  flex: 1;
  min-width: 0;
}

.tg-waveform {
  height: 34px;
  display: flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
}

.tg-waveform span {
  width: 3px;
  border-radius: 999px;
  background: #9ca3af;
  opacity: 0.8;
}

.tg-waveform span.active {
  background: #39a7f7;
  opacity: 1;
}

.tg-voice-time {
  margin-top: 2px;
  color: #9ca3af;
  font-size: 18px;
  line-height: 1;
}

.sticker {
  margin-top: 6px;
  width: 160px;
  height: 160px;
}

.sticker img,
.sticker video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.sticky-date {
  position: sticky;
  top: 10px;
  z-index: 10;
  margin: 0 auto 12px;
  width: fit-content;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(71, 85, 105, 0.85);
  color: #e5e7eb;
  font-size: 14px;
  font-weight: 700;
  backdrop-filter: blur(8px);
  display: none;
}

.date-separator {
  margin: 18px auto;
  width: fit-content;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(71, 85, 105, 0.85);
  color: #e5e7eb;
  font-size: 14px;
  font-weight: 700;
}

.new-message {
  animation: newMessageFlash 2.5s ease;
}

@keyframes newMessageFlash {
  0% {
    background: rgba(59, 130, 246, 0.25);
    border-radius: 14px;
  }
  100% {
    background: transparent;
  }
}

.new-messages-badge {
  position: absolute;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  display: none;
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  background: #2563eb;
  color: white;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}

.chat {
  position: relative;
}

.dialog {
  position: relative;
}

.dialog-unread {
  position: absolute;
  right: 12px;
  top: 16px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: #2563eb;
  color: white;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}