* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: #dadbd3;
  height: 100vh;
  overflow: hidden;
}

/* ===== Auth Page ===== */
.auth-page {
  display: flex;
  justify-content: center;
  align-items: center;
  background: linear-gradient(180deg, #075e54 0%, #075e54 30%, #dadbd3 30%);
}

.auth-container {
  background: #fff;
  padding: 40px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
  width: 100%;
  max-width: 400px;
  text-align: center;
  margin: 0 16px;
}

.logo {
  color: #075e54;
  font-size: 32px;
  margin-bottom: 30px;
  font-weight: 700;
}

.auth-form h2 {
  color: #333;
  margin-bottom: 20px;
  font-size: 18px;
}

.auth-form input {
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}

.auth-form input:focus {
  border-color: #075e54;
}

.auth-form button {
  width: 100%;
  padding: 12px;
  background: #075e54;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  margin-top: 4px;
  transition: background 0.2s;
}

.auth-form button:hover {
  background: #064d44;
}

.switch-text {
  margin-top: 16px;
  font-size: 13px;
  color: #666;
}

.switch-text a {
  color: #075e54;
  text-decoration: none;
  font-weight: 600;
}

.error-msg {
  color: #e74c3c;
  font-size: 13px;
  margin-top: 12px;
}

.error-msg.small {
  margin: 4px 10px 0;
  font-size: 11px;
  text-align: left;
}

.success-msg {
  color: #25d366;
  font-size: 11px;
  margin: 4px 10px 0;
  text-align: left;
}

/* ===== Chat Page ===== */
.chat-page {
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #dadbd3;
}

.chat-container {
  display: flex;
  width: 100%;
  max-width: 1200px;
  height: 100vh;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
  position: relative;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 30%;
  min-width: 300px;
  background: #fff;
  border-right: 1px solid #ddd;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  background: #075e54;
  color: #fff;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

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

.sidebar-username {
  font-size: 15px;
  font-weight: 600;
}

.sidebar-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.sidebar-actions button {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.sidebar-actions button:hover {
  background: rgba(255,255,255,0.1);
}

/* ===== Avatars ===== */
.avatar-wrapper {
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
}

.avatar-wrapper:hover .avatar-edit-icon {
  opacity: 1;
}

.avatar-edit-icon {
  position: absolute;
  bottom: -2px;
  right: -2px;
  background: #25d366;
  color: #fff;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.avatar, .avatar-wrapper img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-initial {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
}

/* Contact-size avatars */
.avatar-contact {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.avatar-initial-contact {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #075e54;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}

/* Header-size avatars */
.avatar-header {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.avatar-initial-header {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
}

/* Small avatars (toasts) */
.avatar-small {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-initial-small {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #075e54;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}

/* Large avatars (contact info) */
.avatar-large {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-initial-large {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #075e54;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 700;
}

/* Add contact */
.add-contact {
  display: flex;
  padding: 10px;
  gap: 8px;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}

.add-contact input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 20px;
  font-size: 14px;
  outline: none;
  -webkit-appearance: none;
}

.add-contact input:focus {
  border-color: #075e54;
}

.add-contact button {
  background: #075e54;
  color: #fff;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.add-contact button:hover {
  background: #064d44;
}

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 2px solid #eee;
  flex-shrink: 0;
}

.tab {
  flex: 1;
  padding: 10px;
  background: none;
  border: none;
  font-size: 13px;
  font-weight: 600;
  color: #888;
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
}

.tab.active {
  color: #075e54;
  border-bottom: 2px solid #075e54;
  margin-bottom: -2px;
}

.tab:hover {
  color: #075e54;
}

.tab.flash {
  animation: flash-tab 0.5s ease-in-out 3;
}

@keyframes flash-tab {
  0%, 100% { background: transparent; }
  50% { background: #dcf8c6; }
}

.badge {
  background: #e74c3c;
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 4px;
  font-weight: 700;
}

.tab-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.empty-text {
  text-align: center;
  color: #aaa;
  font-size: 13px;
  padding: 20px;
}

/* Contacts */
.contacts-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.contact-item {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  gap: 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.contact-item:hover {
  background: #f5f5f5;
}

.contact-item:active {
  background: #ebebeb;
}

.contact-item.active {
  background: #ebebeb;
}

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

.contact-name {
  font-size: 15px;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-status-text {
  font-size: 11px;
  color: #999;
}

.contact-status-text.online {
  color: #25d366;
}

/* Friend Requests */
.requests-title {
  font-size: 12px;
  color: #888;
  text-transform: uppercase;
  padding: 12px 16px 6px;
  letter-spacing: 0.5px;
}

.request-item {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  gap: 10px;
  border-bottom: 1px solid #f0f0f0;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

.request-name {
  font-size: 14px;
  color: #333;
  font-weight: 500;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.request-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.btn-accept {
  background: #25d366;
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 600;
}

.btn-accept:hover {
  background: #1da851;
}

.btn-reject {
  background: #e74c3c;
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 600;
}

.btn-reject:hover {
  background: #c0392b;
}

.request-status {
  font-size: 12px;
  color: #f39c12;
  font-weight: 600;
}

/* ===== Chat Area ===== */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #ece5dd;
  min-width: 0;
}

.chat-header {
  background: #075e54;
  color: #fff;
  padding: 10px 16px;
  font-size: 16px;
  font-weight: 600;
  flex-shrink: 0;
}

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

.chat-header-text {
  flex: 1;
  cursor: pointer;
  min-width: 0;
}

.chat-header-name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-status {
  font-size: 11px;
  color: rgba(255,255,255,0.6);
}

.chat-header-status.online {
  color: #25d366;
}

/* Mobile back button - hidden on desktop */
.mobile-back-btn {
  display: none;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px;
  margin-right: 4px;
  flex-shrink: 0;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background-color: #ece5dd;
  -webkit-overflow-scrolling: touch;
}

.message {
  max-width: 75%;
  padding: 6px 10px;
  border-radius: 8px;
  position: relative;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message.sent {
  background: #dcf8c6;
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}

.message.received {
  background: #fff;
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}

.message-content {
  font-size: 14px;
  color: #333;
  line-height: 1.4;
}

.message-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  margin-top: 2px;
}

.message-time {
  font-size: 11px;
  color: #999;
}

/* ===== Message Status Icons ===== */
.msg-status {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  flex-shrink: 0;
}

/* ===== Deleted Message ===== */
.deleted-msg {
  color: #999 !important;
  font-style: italic;
}

/* Media in messages */
.msg-image {
  max-width: 100%;
  max-height: 300px;
  border-radius: 6px;
  cursor: pointer;
  display: block;
  margin-bottom: 4px;
}

.msg-video {
  max-width: 100%;
  max-height: 300px;
  border-radius: 6px;
  display: block;
  margin-bottom: 4px;
}

.media-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: pointer;
}

.media-fullscreen {
  max-width: 95%;
  max-height: 95%;
  border-radius: 4px;
}

/* File preview */
.file-preview {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  background: #e0e0e0;
  border-top: 1px solid #ccc;
  gap: 10px;
  flex-shrink: 0;
}

.file-preview-content { flex: 1; }

.preview-img {
  max-height: 120px;
  max-width: 200px;
  border-radius: 6px;
}

.preview-video {
  max-height: 120px;
  max-width: 200px;
  border-radius: 6px;
}

.file-preview-close {
  background: #e74c3c;
  color: #fff;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  font-weight: 700;
  flex-shrink: 0;
}

/* Message input */
.message-input {
  display: flex;
  padding: 8px 10px;
  gap: 6px;
  background: #f0f0f0;
  align-items: center;
  flex-shrink: 0;
}

.media-btn {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.media-btn:hover {
  background: #ddd;
  color: #075e54;
}

.message-input input[type="text"] {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 20px;
  font-size: 16px;
  outline: none;
  min-width: 0;
  -webkit-appearance: none;
}

.message-input #send-btn {
  background: #075e54;
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.message-input #send-btn:hover {
  background: #064d44;
}

.message-input #send-btn:disabled {
  background: #999;
  cursor: not-allowed;
}

/* ===== Toast Notifications ===== */
#toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: calc(100vw - 32px);
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border-left: 4px solid #075e54;
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  min-width: 240px;
  max-width: 360px;
  animation: toastIn 0.3s ease;
}

.toast-hide {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(60px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(60px); }
}

.toast-avatar {
  flex-shrink: 0;
}

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

.toast-sender {
  font-size: 13px;
  font-weight: 700;
  color: #333;
}

.toast-text {
  font-size: 12px;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Context Menu (Delete) ===== */
.context-menu {
  position: fixed;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: 500;
  overflow: hidden;
  min-width: 180px;
}

.context-menu button {
  display: block;
  width: 100%;
  padding: 14px 16px;
  background: none;
  border: none;
  text-align: left;
  font-size: 15px;
  color: #333;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.context-menu button:hover,
.context-menu button:active {
  background: #f5f5f5;
}

.context-menu button#ctx-delete-all {
  color: #e74c3c;
}

/* ===== Settings Panel ===== */
.settings-panel {
  position: absolute;
  top: 0;
  left: 0;
  width: 30%;
  min-width: 300px;
  height: 100%;
  background: #fff;
  z-index: 200;
  flex-direction: column;
  box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}

.settings-header {
  background: #075e54;
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  font-weight: 600;
  flex-shrink: 0;
}

.settings-back {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 4px;
  -webkit-tap-highlight-color: transparent;
}

.settings-back:hover {
  opacity: 0.8;
}

.settings-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

.settings-section {
  margin-bottom: 24px;
}

.settings-section h3 {
  font-size: 14px;
  color: #075e54;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.settings-section textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  resize: vertical;
  min-height: 60px;
  outline: none;
  font-family: inherit;
}

.settings-section textarea:focus {
  border-color: #075e54;
}

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

.settings-row span {
  font-size: 12px;
  color: #999;
}

.btn-save {
  background: #075e54;
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
}

.btn-save:hover {
  background: #064d44;
}

.btn-danger {
  background: #e74c3c;
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
}

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

.full-width {
  width: 100%;
}

/* Wallpaper Preview */
.wallpaper-preview {
  width: 100%;
  height: 80px;
  border: 1px solid #ddd;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #ece5dd;
  color: #999;
  font-size: 13px;
}

/* ===== Contact Info Panel ===== */
.contact-profile {
  text-align: center;
  padding: 24px 0;
}

.contact-profile-avatar {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.contact-profile h2 {
  font-size: 20px;
  color: #333;
  margin-bottom: 8px;
}

.contact-bio {
  font-size: 14px;
  color: #666;
  line-height: 1.4;
}

/* ===== Archived Items ===== */
.archived-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
}

.archived-item .contact-name {
  flex: 1;
  font-size: 14px;
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
  body {
    overflow: hidden;
  }

  .chat-container {
    max-width: 100%;
    width: 100%;
  }

  /* Default: show sidebar, hide chat */
  .sidebar {
    width: 100%;
    min-width: unset;
    height: 100vh;
  }

  .chat-area {
    display: none;
    width: 100%;
    height: 100vh;
  }

  /* When chat is open: hide sidebar, show chat */
  .chat-container.mobile-chat-open .sidebar {
    display: none;
  }

  .chat-container.mobile-chat-open .chat-area {
    display: flex;
    width: 100%;
  }

  /* Show back button on mobile */
  .mobile-back-btn {
    display: flex;
  }

  /* Settings panel full width */
  .settings-panel {
    width: 100% !important;
    min-width: unset !important;
  }

  /* Chat header */
  .chat-header {
    padding: 10px 12px;
  }

  .chat-header-info {
    gap: 8px;
  }

  /* Messages */
  .messages {
    padding: 10px;
  }

  .message {
    max-width: 85%;
  }

  /* Message input */
  .message-input {
    padding: 6px 8px;
    gap: 4px;
  }

  .message-input input[type="text"] {
    padding: 10px 14px;
    font-size: 16px;
  }

  .message-input #send-btn {
    padding: 10px 14px;
    font-size: 14px;
  }

  /* Media buttons smaller on mobile */
  .media-btn {
    padding: 6px;
  }

  .media-btn svg {
    width: 18px;
    height: 18px;
  }

  /* Context menu */
  .context-menu {
    min-width: 200px;
  }

  .context-menu button {
    padding: 16px;
    font-size: 16px;
  }

  /* Toast */
  #toast-container {
    top: 8px;
    right: 8px;
    left: 8px;
  }

  .toast {
    min-width: unset;
    max-width: 100%;
  }

  /* Contact items bigger touch targets */
  .contact-item {
    padding: 14px;
  }

  /* Request items */
  .request-item {
    padding: 12px 14px;
  }

  /* File preview */
  .preview-img,
  .preview-video {
    max-width: 150px;
    max-height: 100px;
  }

  /* Media overlay */
  .media-fullscreen {
    max-width: 100%;
    max-height: 100%;
  }

  /* Sidebar header compact */
  .sidebar-header {
    padding: 8px 10px;
  }

  /* Add contact */
  .add-contact {
    padding: 8px 10px;
  }
}

/* ===== Create Group ===== */
.create-group-area {
  padding: 10px;
  border-bottom: 1px solid #eee;
}

.create-group-btn {
  width: 100%;
  padding: 10px;
  background: #075e54;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.create-group-btn:hover {
  background: #064d44;
}

.groups-list {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 600;
  padding: 16px;
}

.modal {
  background: #fff;
  border-radius: 10px;
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}

.modal-header h3 {
  font-size: 18px;
  color: #333;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #999;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.modal-close:hover {
  color: #333;
}

.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

.modal-body h4 {
  font-size: 13px;
  color: #888;
  margin: 12px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.modal-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 15px;
  outline: none;
  -webkit-appearance: none;
}

.modal-input:focus {
  border-color: #075e54;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid #eee;
  flex-shrink: 0;
}

.modal-footer .btn-save {
  width: 100%;
  padding: 10px;
  font-size: 15px;
}

/* Group contacts checklist */
.group-contacts-list {
  max-height: 250px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.group-contact-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.group-contact-item:last-child {
  border-bottom: none;
}

.group-contact-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #075e54;
  flex-shrink: 0;
}

.group-contact-item span {
  font-size: 14px;
  color: #333;
}

/* ===== Group Info (members list) ===== */
.group-member-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
}

.group-member-item:last-child {
  border-bottom: none;
}

.group-member-name {
  flex: 1;
  font-size: 14px;
  color: #333;
}

.group-role {
  font-size: 11px;
  color: #fff;
  background: #075e54;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  flex-shrink: 0;
}

/* Group sender name in messages */
.msg-sender-name {
  font-size: 12px;
  font-weight: 700;
  color: #075e54;
  margin-bottom: 2px;
}

/* ===== Recording Bar ===== */
.recording-bar {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  background: #f0f0f0;
  gap: 12px;
  flex-shrink: 0;
}

.recording-indicator {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.recording-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e74c3c;
  animation: recordPulse 1s infinite;
}

@keyframes recordPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

#recording-time {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  font-variant-numeric: tabular-nums;
}

.recording-cancel {
  background: none;
  border: none;
  color: #e74c3c;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.recording-cancel:hover {
  background: rgba(231,76,60,0.1);
}

.recording-send {
  background: #075e54;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.recording-send:hover {
  background: #064d44;
}

/* ===== Sticker Picker ===== */
.sticker-picker {
  display: flex;
  flex-direction: column;
  background: #fff;
  border-top: 1px solid #ddd;
  height: 280px;
  flex-shrink: 0;
}

.sticker-picker-header {
  padding: 8px 10px;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}

.sticker-categories {
  display: flex;
  gap: 4px;
}

.sticker-cat-btn {
  background: none;
  border: none;
  font-size: 22px;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.sticker-cat-btn:hover {
  background: #f0f0f0;
}

.sticker-cat-btn.active {
  background: #e8f5e9;
}

.sticker-grid {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  align-content: start;
  -webkit-overflow-scrolling: touch;
}

.sticker-item {
  background: none;
  border: none;
  font-size: 32px;
  padding: 8px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
  text-align: center;
}

.sticker-item:hover {
  background: #f0f0f0;
  transform: scale(1.15);
}

.sticker-item:active {
  transform: scale(0.95);
}

/* Sticker button active state */
.media-btn.active {
  color: #075e54;
  background: #e8f5e9;
}

/* ===== Sticker Messages ===== */
.sticker-message {
  background: transparent !important;
  box-shadow: none !important;
  padding: 2px 10px !important;
}

.sticker-content {
  font-size: 72px;
  line-height: 1.1;
  text-align: center;
}

/* ===== Audio Messages ===== */
.msg-audio {
  max-width: 250px;
  width: 100%;
  height: 36px;
  margin-bottom: 4px;
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
  /* Recording bar */
  .recording-bar {
    padding: 8px 10px;
    gap: 8px;
  }

  /* Audio player */
  .msg-audio {
    max-width: 200px;
    height: 32px;
  }

  /* Modal */
  .modal {
    max-height: 90vh;
    margin: 0;
  }

  .modal-header {
    padding: 14px 16px;
  }

  .modal-body {
    padding: 14px 16px;
  }

  .modal-footer {
    padding: 10px 16px;
  }
}

/* Sticker picker mobile */
@media (max-width: 768px) {
  .sticker-picker {
    height: 240px;
  }

  .sticker-grid {
    grid-template-columns: repeat(5, 1fr);
  }

  .sticker-item {
    font-size: 28px;
    padding: 6px;
  }

  .sticker-content {
    font-size: 64px;
  }
}

/* ===== Profile Photo Fullscreen (anti-print) ===== */
.profile-photo-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
}

.profile-photo-img {
  max-width: 90%;
  max-height: 90%;
  border-radius: 8px;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  transition: filter 0.3s;
}

.profile-photo-img.blurred {
  filter: blur(30px);
}

.profile-photo-shield {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

/* ===== Call Header Buttons ===== */
.chat-header-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.header-call-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.header-call-btn:hover {
  background: rgba(255,255,255,0.25);
}

/* ===== Call Overlay ===== */
.call-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #1a1a2e;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.call-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

.call-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(0,0,0,0.3);
  z-index: 2;
}

.call-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.call-avatar {
  flex-shrink: 0;
}

.call-username {
  font-size: 18px;
  font-weight: 600;
  color: #fff;
}

.call-status {
  font-size: 13px;
  color: rgba(255,255,255,0.6);
}

.call-timer {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  font-variant-numeric: tabular-nums;
  background: rgba(255,255,255,0.1);
  padding: 4px 12px;
  border-radius: 20px;
}

.call-videos {
  flex: 1;
  position: relative;
  background: #0b0b1a;
  display: flex;
  align-items: center;
  justify-content: center;
}

.remote-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.local-video {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 140px;
  height: 105px;
  border-radius: 10px;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.3);
  z-index: 3;
}

.call-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px;
  background: rgba(0,0,0,0.3);
  z-index: 2;
}

.call-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.call-btn:hover {
  background: rgba(255,255,255,0.25);
}

.call-btn-active {
  background: #f39c12 !important;
  color: #fff;
}

.call-btn-end {
  background: #e74c3c !important;
}

.call-btn-end:hover {
  background: #c0392b !important;
}

.call-btn-accept {
  background: #25d366 !important;
}

.call-btn-accept:hover {
  background: #1da851 !important;
}

/* ===== Incoming Call Popup ===== */
.incoming-call {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.6);
  z-index: 1300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.incoming-call-card {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.3);
  animation: modalIn 0.3s ease;
  min-width: 280px;
}

.incoming-call-card .call-avatar {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.incoming-call-name {
  font-size: 20px;
  font-weight: 700;
  color: #333;
  margin-bottom: 4px;
}

.incoming-call-type {
  font-size: 14px;
  color: #888;
  margin-bottom: 24px;
}

.incoming-call-actions {
  display: flex;
  justify-content: center;
  gap: 24px;
}

/* ===== Call Mobile ===== */
@media (max-width: 768px) {
  .local-video {
    width: 100px;
    height: 75px;
    bottom: 10px;
    right: 10px;
  }

  .call-controls {
    gap: 12px;
    padding: 16px;
  }

  .call-btn {
    width: 48px;
    height: 48px;
  }
}

/* ===== Theme Toggle Button ===== */
.theme-toggle {
  position: fixed;
  bottom: 16px;
  left: 16px;
  z-index: 900;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: #075e54;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
  transition: background 0.2s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.theme-toggle:hover {
  background: #064d44;
  transform: scale(1.1);
}

.theme-toggle:active {
  transform: scale(0.95);
}

/* ===== Dark Theme ===== */
body.dark-theme {
  background-color: #0b141a;
}

body.dark-theme .chat-page {
  background-color: #0b141a;
}

body.dark-theme .chat-container {
  background: #111b21;
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}

/* Sidebar */
body.dark-theme .sidebar {
  background: #111b21;
  border-right-color: #2a3942;
}

body.dark-theme .sidebar-header {
  background: #1f2c34;
}

body.dark-theme .sidebar-actions button {
  border-color: rgba(255,255,255,0.15);
}

/* Avatars */
body.dark-theme .avatar-initial {
  background: rgba(255,255,255,0.1);
}

body.dark-theme .avatar-initial-contact {
  background: #2a3942;
}

body.dark-theme .avatar-initial-header {
  background: rgba(255,255,255,0.1);
}

body.dark-theme .avatar-initial-small {
  background: #2a3942;
}

body.dark-theme .avatar-initial-large {
  background: #2a3942;
}

/* Add contact */
body.dark-theme .add-contact {
  border-bottom-color: #2a3942;
}

body.dark-theme .add-contact input {
  background: #2a3942;
  border-color: #2a3942;
  color: #e9edef;
}

body.dark-theme .add-contact input:focus {
  border-color: #00a884;
}

body.dark-theme .add-contact input::placeholder {
  color: #8696a0;
}

body.dark-theme .add-contact button {
  background: #00a884;
}

body.dark-theme .add-contact button:hover {
  background: #06cf9c;
}

/* Tabs */
body.dark-theme .tabs {
  border-bottom-color: #2a3942;
}

body.dark-theme .tab {
  color: #8696a0;
}

body.dark-theme .tab.active {
  color: #00a884;
  border-bottom-color: #00a884;
}

body.dark-theme .tab:hover {
  color: #00a884;
}

@keyframes flash-tab-dark {
  0%, 100% { background: transparent; }
  50% { background: #0b3b2d; }
}

body.dark-theme .tab.flash {
  animation: flash-tab-dark 0.5s ease-in-out 3;
}

body.dark-theme .empty-text {
  color: #8696a0;
}

/* Contacts */
body.dark-theme .contact-item {
  border-bottom-color: #2a3942;
}

body.dark-theme .contact-item:hover {
  background: #2a3942;
}

body.dark-theme .contact-item:active,
body.dark-theme .contact-item.active {
  background: #2a3942;
}

body.dark-theme .contact-name {
  color: #e9edef;
}

body.dark-theme .contact-status-text {
  color: #8696a0;
}

/* Requests */
body.dark-theme .requests-title {
  color: #8696a0;
}

body.dark-theme .request-item {
  border-bottom-color: #2a3942;
}

body.dark-theme .request-name {
  color: #e9edef;
}

/* Chat Area */
body.dark-theme .chat-area {
  background: #0b141a;
}

body.dark-theme .chat-header {
  background: #1f2c34;
}

body.dark-theme .chat-header-status {
  color: rgba(255,255,255,0.45);
}

body.dark-theme .messages {
  background-color: #0b141a;
}

body.dark-theme .message.sent {
  background: #005c4b;
}

body.dark-theme .message.received {
  background: #1f2c34;
}

body.dark-theme .message-content {
  color: #e9edef;
}

body.dark-theme .message-time {
  color: rgba(255,255,255,0.45);
}

body.dark-theme .deleted-msg {
  color: rgba(255,255,255,0.45) !important;
}

body.dark-theme .msg-sender-name {
  color: #00a884;
}

/* Input area */
body.dark-theme .message-input {
  background: #1f2c34;
}

body.dark-theme .message-input input[type="text"] {
  background: #2a3942;
  color: #e9edef;
}

body.dark-theme .message-input input[type="text"]::placeholder {
  color: #8696a0;
}

body.dark-theme .message-input #send-btn {
  background: #00a884;
}

body.dark-theme .message-input #send-btn:hover {
  background: #06cf9c;
}

body.dark-theme .message-input #send-btn:disabled {
  background: #3b4a54;
}

body.dark-theme .media-btn {
  color: #8696a0;
}

body.dark-theme .media-btn:hover {
  background: #2a3942;
  color: #00a884;
}

body.dark-theme .media-btn.active {
  color: #00a884;
  background: #0b3b2d;
}

/* File preview */
body.dark-theme .file-preview {
  background: #1f2c34;
  border-top-color: #2a3942;
}

/* Recording bar */
body.dark-theme .recording-bar {
  background: #1f2c34;
}

body.dark-theme #recording-time {
  color: #e9edef;
}

body.dark-theme .recording-send {
  background: #00a884;
}

body.dark-theme .recording-send:hover {
  background: #06cf9c;
}

/* Sticker picker */
body.dark-theme .sticker-picker {
  background: #1f2c34;
  border-top-color: #2a3942;
}

body.dark-theme .sticker-picker-header {
  border-bottom-color: #2a3942;
}

body.dark-theme .sticker-cat-btn:hover {
  background: #2a3942;
}

body.dark-theme .sticker-cat-btn.active {
  background: #0b3b2d;
}

body.dark-theme .sticker-item:hover {
  background: #2a3942;
}

/* Toast */
body.dark-theme .toast {
  background: #1f2c34;
  border-left-color: #00a884;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

body.dark-theme .toast-sender {
  color: #e9edef;
}

body.dark-theme .toast-text {
  color: #8696a0;
}

/* Context menu */
body.dark-theme .context-menu {
  background: #233138;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

body.dark-theme .context-menu button {
  color: #e9edef;
}

body.dark-theme .context-menu button:hover,
body.dark-theme .context-menu button:active {
  background: #2a3942;
}

body.dark-theme .context-menu button#ctx-delete-all {
  color: #f15c6d;
}

/* Settings panel */
body.dark-theme .settings-panel {
  background: #111b21;
  box-shadow: 2px 0 10px rgba(0,0,0,0.3);
}

body.dark-theme .settings-header {
  background: #1f2c34;
}

body.dark-theme .settings-body {
  color: #e9edef;
}

body.dark-theme .settings-section h3 {
  color: #00a884;
}

body.dark-theme .settings-section textarea {
  background: #2a3942;
  border-color: #2a3942;
  color: #e9edef;
}

body.dark-theme .settings-section textarea:focus {
  border-color: #00a884;
}

body.dark-theme .settings-row span {
  color: #8696a0;
}

body.dark-theme .btn-save {
  background: #00a884;
}

body.dark-theme .btn-save:hover {
  background: #06cf9c;
}

body.dark-theme .wallpaper-preview {
  background-color: #0b141a;
  border-color: #2a3942;
  color: #8696a0;
}

/* Theme toggle dark */
body.dark-theme .theme-toggle {
  background: #00a884;
}

body.dark-theme .theme-toggle:hover {
  background: #06cf9c;
}

/* Contact info */
body.dark-theme .contact-profile h2 {
  color: #e9edef;
}

body.dark-theme .contact-bio {
  color: #8696a0;
}

/* Archived */
body.dark-theme .archived-item {
  border-bottom-color: #2a3942;
}

body.dark-theme .archived-item .contact-name {
  color: #e9edef;
}

/* Modal */
body.dark-theme .modal-overlay {
  background: rgba(0,0,0,0.6);
}

body.dark-theme .modal {
  background: #1f2c34;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}

body.dark-theme .modal-header {
  border-bottom-color: #2a3942;
}

body.dark-theme .modal-header h3 {
  color: #e9edef;
}

body.dark-theme .modal-close {
  color: #8696a0;
}

body.dark-theme .modal-close:hover {
  color: #e9edef;
}

body.dark-theme .modal-body h4 {
  color: #8696a0;
}

body.dark-theme .modal-input {
  background: #2a3942;
  border-color: #2a3942;
  color: #e9edef;
}

body.dark-theme .modal-input:focus {
  border-color: #00a884;
}

body.dark-theme .modal-footer {
  border-top-color: #2a3942;
}

body.dark-theme .group-contact-item {
  border-bottom-color: #2a3942;
}

body.dark-theme .group-contact-item span {
  color: #e9edef;
}

body.dark-theme .group-contact-item input[type="checkbox"] {
  accent-color: #00a884;
}

/* Group info */
body.dark-theme .group-member-item {
  border-bottom-color: #2a3942;
}

body.dark-theme .group-member-name {
  color: #e9edef;
}

body.dark-theme .group-role {
  background: #00a884;
}

/* Create group */
body.dark-theme .create-group-area {
  border-bottom-color: #2a3942;
}

body.dark-theme .create-group-btn {
  background: #00a884;
}

body.dark-theme .create-group-btn:hover {
  background: #06cf9c;
}

/* Media overlay */
body.dark-theme .media-overlay {
  background: rgba(0,0,0,0.95);
}

/* Call UI */
body.dark-theme .call-overlay {
  background: #0b141a;
}

body.dark-theme .call-videos {
  background: #060d13;
}

body.dark-theme .incoming-call-card {
  background: #1f2c34;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}

body.dark-theme .incoming-call-name {
  color: #e9edef;
}

body.dark-theme .incoming-call-type {
  color: #8696a0;
}

/* Scrollbar dark */
body.dark-theme ::-webkit-scrollbar {
  width: 6px;
}

body.dark-theme ::-webkit-scrollbar-track {
  background: #0b141a;
}

body.dark-theme ::-webkit-scrollbar-thumb {
  background: #374045;
  border-radius: 3px;
}

/* Small phones */
@media (max-width: 380px) {
  .request-actions {
    flex-direction: column;
    gap: 4px;
  }

  .btn-accept, .btn-reject {
    padding: 5px 10px;
    font-size: 11px;
  }

  .sidebar-actions button {
    padding: 4px 8px;
    font-size: 11px;
  }
}
