* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #f3f4f6;
  color: #111827;
}

body.overlay-open {
  overflow: hidden;
}

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

.sidebar {
  width: 320px;
  background: #ffffff;
  border-right: 1px solid #e5e7eb;
  padding: 16px;
}

.brand {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 16px;
}

.card {
  background: #fafafa;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 16px;
}

.card h3 {
  margin-top: 0;
  margin-bottom: 10px;
}

input, button {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 10px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  font-size: 14px;
}

button {
  cursor: pointer;
  background: #111827;
  color: white;
  border: none;
}

button:hover {
  opacity: 0.92;
}

.muted {
  color: #6b7280;
  font-size: 14px;
}

.hidden {
  display: none !important;
}

.users-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-item {
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: white;
  cursor: pointer;
}

.user-item:hover {
  background: #f9fafb;
}

.user-item.active {
  border-color: #111827;
  background: #eef2ff;
}

.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-main {
  min-width: 0;
  flex: 1;
}

.user-name {
  font-weight: 700;
}

.user-meta {
  font-size: 12px;
  color: #6b7280;
  margin-top: 4px;
}

.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: white;
  border-bottom: 1px solid #e5e7eb;
  gap: 12px;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.chat-user-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.chat-user-block {
  min-width: 0;
}

.chat-title {
  font-size: 24px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-subtitle {
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.message {
  max-width: 70%;
  padding: 10px 12px;
  border-radius: 14px;
  margin-bottom: 10px;
  word-break: break-word;
}

.message.outgoing {
  margin-left: auto;
  background: #111827;
  color: white;
}

.message.incoming {
  margin-right: auto;
  background: white;
  border: 1px solid #e5e7eb;
}

.message-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 11px;
  margin-top: 6px;
  opacity: 0.85;
}

.checks {
  margin-left: 6px;
  font-weight: 700;
  font-size: 12px;
}

.checks.sent {
  color: #9ca3af;
}

.checks.delivered {
  color: #9ca3af;
}

.checks.read {
  color: #f97316;
}

.composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #e5e7eb;
  background: white;
  position: sticky;
  bottom: 0;
}

.composer-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.composer-row-top input {
  width: 100%;
  margin-bottom: 0;
}

.composer-row-bottom {
  align-items: stretch;
}

.composer-row-bottom button {
  margin-bottom: 0;
}

#recordBtn,
#videoRecordBtn,
#sendBtn {
  width: 140px;
}

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

.dialog-badge {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: #f97316;
  color: white;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.section-head h3 {
  margin: 0;
}

.small-btn {
  width: auto;
  margin-bottom: 0;
  padding: 8px 12px;
  font-size: 13px;
}

.collapsed {
  display: none;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.auth-tab.active {
  background: #f97316;
}

.back-btn {
  display: none;
  width: auto;
  margin-bottom: 0;
  padding: 8px 12px;
  font-size: 14px;
}

.hidden-file-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.attach-btn {
  width: auto;
  margin-bottom: 0;
  padding: 10px 14px;
  white-space: nowrap;
}

.file-name {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  background: #fff;
  color: #6b7280;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.danger-btn {
  background: #dc2626;
}

.danger-btn:hover {
  background: #b91c1c;
}

.profile-form {
  margin-top: 12px;
}

.profile-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.avatar {
  border-radius: 999px;
  object-fit: cover;
  flex-shrink: 0;
  background: #e5e7eb;
  border: 1px solid #d1d5db;
}

.avatar-small,
.avatar-medium {
  width: 42px;
  height: 42px;
}

.avatar-large {
  width: 64px;
  height: 64px;
}

.video-circle-wrap {
  width: 220px;
  height: 220px;
  border-radius: 999px;
  overflow: hidden;
  background: #000;
}

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

.video-preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: 20px;
  pointer-events: auto;
}

.video-preview-card {
  width: min(92vw, 360px);
  background: #111827;
  border-radius: 24px;
  padding: 16px;
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
  position: relative;
  pointer-events: auto;
}

.video-preview-el {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 999px;
  object-fit: cover;
  background: #000;
  display: block;
}

.video-preview-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.video-preview-actions button {
  margin-bottom: 0;
  touch-action: manipulation;
}

@media (max-width: 900px) {
  .app {
    flex-direction: column;
    min-height: 100vh;
  }

  .sidebar {
    width: 100%;
    min-width: 0;
    border-right: none;
    border-bottom: 1px solid #e5e7eb;
    padding: 12px;
  }

  .chat-area {
    width: 100%;
    min-width: 0;
    min-height: 55vh;
  }

  .messages {
    padding: 14px;
  }

  .message {
    max-width: 88%;
  }

  .composer {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  }

  .composer-row-bottom {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .attach-btn {
    grid-column: 1 / 2;
  }

  .file-name {
    grid-column: 2 / 3;
  }

  #recordBtn {
    grid-column: 1 / 2;
    width: 100%;
  }

  #videoRecordBtn {
    grid-column: 2 / 3;
    width: 100%;
  }

  #sendBtn {
    grid-column: 1 / 3;
    width: 100%;
  }

  .brand {
    font-size: 24px;
  }

  .chat-title {
    font-size: 22px;
    max-width: 180px;
  }

  .app.chat-open .sidebar {
    display: none;
  }

  .app.chat-open .chat-area {
    display: flex;
    width: 100%;
    min-height: 100vh;
  }

  .back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  #selectedUserBox {
    max-width: 180px;
  }
}

#videoTimerEl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 84px;
  margin: 12px auto 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
  backdrop-filter: blur(6px);
}

#videoTimerEl::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #ef4444;
  margin-right: 8px;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.9);
}

.video-preview-card {
  text-align: center;
}

.video-preview-actions {
  margin-top: 12px;
}

@media (max-width: 900px) {
  #videoTimerEl {
    font-size: 17px;
    min-width: 78px;
    padding: 7px 12px;
  }
}

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

#enableNotificationsBtn {
  width: auto;
  margin-bottom: 0;
}
.reply-box {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-left: 4px solid #f97316;
  border-radius: 12px;
  background: #fff7ed;
}

.reply-box-content {
  min-width: 0;
  flex: 1;
}

.reply-box-title {
  font-size: 12px;
  font-weight: 700;
  color: #c2410c;
  margin-bottom: 4px;
}

.reply-box-text {
  font-size: 13px;
  color: #374151;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-cancel-btn {
  width: auto;
  min-width: 42px;
  margin-bottom: 0;
  padding: 8px 10px;
  background: #111827;
}
.message-reply {
  margin-bottom: 8px;
  padding: 8px 10px;
  border-left: 3px solid #f97316;
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
}

.message.incoming .message-reply {
  background: #f9fafb;
}

.message-reply-label {
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 3px;
  color: #f97316;
}

.message-reply-text {
  font-size: 12px;
  opacity: 0.9;
}
