/* ============================================================
   My Messenger — стили v2
   ============================================================ */
:root {
  --bg-0:        #0e1621;
  --bg-1:        #17212b;
  --bg-2:        #232e3c;
  --bg-3:        #2b5278;
  --accent:      #5288c1;
  --accent-hover:#6ba0d4;
  --text:        #f5f5f5;
  --text-dim:    #8893a3;
  --border:      #1f2c3a;
  --bubble-me:   #2b5278;
  --bubble-them: #182533;
  --danger:      #e36464;
  --success:     #4fae4e;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%; width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-0); color: var(--text);
  overflow: hidden;
}
button { cursor: pointer; font-family: inherit; }
input, textarea { font-family: inherit; }

/* ===================== АВТОРИЗАЦИЯ ===================== */
.auth-wrap {
  height: 100vh; width: 100vw;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0e1621 0%, #17212b 100%);
}
.auth-card {
  background: var(--bg-1);
  width: 380px; max-width: 92vw;
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.5);
}
.auth-card h1 { font-size: 24px; margin-bottom: 4px; text-align: center; }
.auth-card .sub { color: var(--text-dim); text-align: center; font-size: 14px; margin-bottom: 24px; }
.auth-tabs { display: flex; gap: 4px; margin-bottom: 20px; background: var(--bg-0); padding: 4px; border-radius: 10px; }
.auth-tabs button {
  flex: 1; padding: 9px; border: none; background: transparent; color: var(--text-dim);
  border-radius: 7px; font-size: 14px; transition: all .15s;
}
.auth-tabs button.active { background: var(--bg-2); color: var(--text); }
.auth-card input {
  width: 100%; padding: 12px 14px;
  background: var(--bg-0); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text);
  font-size: 14px; margin-bottom: 12px; outline: none;
  transition: border-color .15s;
}
.auth-card input:focus { border-color: var(--accent); }
.auth-card .btn-primary {
  width: 100%; padding: 12px; margin-top: 8px;
  background: var(--accent); color: #fff; border: none; border-radius: 10px;
  font-size: 15px; font-weight: 500; transition: background .15s;
}
.auth-card .btn-primary:hover { background: var(--accent-hover); }
.auth-error { color: var(--danger); font-size: 13px; text-align: center; margin-top: 10px; min-height: 18px; }

/* ===================== АВАТАРКА ===================== */
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--bg-3); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 15px; flex-shrink: 0;
  overflow: hidden; position: relative;
  background-size: cover; background-position: center;
}
.avatar.lg { width: 96px; height: 96px; font-size: 36px; }
.avatar.online::after {
  content: ''; position: absolute; right: -2px; bottom: -2px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--success); border: 2px solid var(--bg-1);
}

/* ===================== ОСНОВНОЙ ЭКРАН ===================== */
.app {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: 100vh; width: 100vw;
}
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .app.chat-open .sidebar { display: none; }
  .app:not(.chat-open) .chat { display: none; }
}

/* ----- сайдбар ----- */
.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
}
.sidebar-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-header .me-clickable {
  display: flex; align-items: center; gap: 10px; flex: 1;
  min-width: 0; cursor: pointer; padding: 4px 6px; margin: -4px -6px;
  border-radius: 8px; transition: background .12s;
}
.sidebar-header .me-clickable:hover { background: var(--bg-2); }
.sidebar-header .me-info { flex: 1; min-width: 0; }
.sidebar-header .me-info .name {
  font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-header .me-info .status {
  font-size: 12px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-header .logout {
  background: transparent; border: none; color: var(--text-dim);
  font-size: 18px; padding: 6px; border-radius: 6px; flex-shrink: 0;
}
.sidebar-header .logout:hover { background: var(--bg-2); color: var(--text); }

.search { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.search input {
  width: 100%; padding: 8px 12px;
  background: var(--bg-0); border: 1px solid transparent;
  border-radius: 18px; color: var(--text); font-size: 13px; outline: none;
}
.search input:focus { border-color: var(--accent); }

.contacts { flex: 1; overflow-y: auto; min-height: 0; }
.contact {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.02);
  transition: background .12s;
}
.contact:hover  { background: var(--bg-2); }
.contact.active { background: var(--bg-3); }
.contact .info { flex: 1; min-width: 0; }
.contact .info .name {
  font-size: 14px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.contact .info .preview {
  font-size: 13px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.empty-list { padding: 30px 20px; color: var(--text-dim); text-align: center; font-size: 13px; }

/* ----- область чата (фикс flex/scroll) ----- */
.chat {
  display: flex; flex-direction: column;
  background: var(--bg-0);
  min-width: 0; min-height: 0;
  overflow: hidden;
}
.chat-empty {
  flex: 1; display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); font-size: 14px;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(82, 136, 193, 0.05), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(82, 136, 193, 0.05), transparent 40%);
}
.chat-active {
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.chat-header {
  padding: 12px 16px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.chat-header .back {
  display: none; background: transparent; border: none;
  color: var(--text); font-size: 22px; padding: 4px 8px;
}
@media (max-width: 720px) { .chat-header .back { display: block; } }
.chat-header .info { flex: 1; min-width: 0; cursor: pointer; }
.chat-header .info .name {
  font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-header .info .status {
  font-size: 12px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-header .info .status.online { color: var(--success); }

.messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  padding: 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.bubble-row { display: flex; max-width: 100%; }
.bubble-row.me  { justify-content: flex-end; }
.bubble-row.them{ justify-content: flex-start; }
.bubble {
  max-width: 70%;
  padding: 8px 12px;
  border-radius: 14px;
  word-wrap: break-word; word-break: break-word;
  font-size: 14px; line-height: 1.4;
}
.bubble-row.me   .bubble { background: var(--bubble-me);   border-bottom-right-radius: 4px; }
.bubble-row.them .bubble { background: var(--bubble-them); border-bottom-left-radius:  4px; }
.bubble .time {
  font-size: 10px; color: rgba(255,255,255,0.5);
  margin-left: 8px; float: right; padding-top: 4px;
}
.bubble img.msg-image {
  max-width: 100%; max-height: 320px;
  border-radius: 10px; display: block;
  cursor: pointer;
}
.bubble audio { display: block; max-width: 280px; }
.bubble .file-attach { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.bubble .file-attach .file-icon {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.bubble .file-attach .file-meta { font-size: 13px; }
.bubble .file-attach .file-meta a { color: #fff; text-decoration: underline; }
.bubble .file-attach .file-meta .size { color: rgba(255,255,255,0.5); font-size: 11px; }

.typing-indicator {
  font-size: 12px; color: var(--text-dim);
  padding: 4px 16px; height: 20px;
  flex-shrink: 0;
}

.input-bar {
  padding: 10px 14px;
  background: var(--bg-1);
  border-top: 1px solid var(--border);
  display: flex; align-items: flex-end; gap: 8px;
  flex-shrink: 0;
}
.input-bar .icon-btn {
  background: transparent; border: none;
  color: var(--text-dim); font-size: 22px;
  padding: 8px; border-radius: 50%;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.input-bar .icon-btn:hover { background: var(--bg-2); color: var(--text); }
.input-bar .icon-btn.recording { color: var(--danger); }
.input-bar textarea {
  flex: 1; resize: none;
  max-height: 140px; min-height: 24px;
  padding: 9px 14px;
  background: var(--bg-0); border: 1px solid transparent;
  border-radius: 18px; color: var(--text);
  font-size: 14px; outline: none; line-height: 1.4;
}
.input-bar textarea:focus { border-color: var(--accent); }
.input-bar .send-btn { background: var(--accent); color: #fff; }
.input-bar .send-btn:hover { background: var(--accent-hover); color: #fff; }

.recording-indicator {
  flex: 1; display: flex; align-items: center; gap: 10px;
  padding: 0 14px; color: var(--danger); font-size: 14px;
}
.recording-indicator .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--danger); animation: pulse 1s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-3); }

/* ===================== МОДАЛКИ ===================== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: none; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--bg-1);
  width: 420px; max-width: 100%;
  max-height: 90vh; overflow-y: auto;
  border-radius: 14px; padding: 24px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}
.modal h2 {
  font-size: 18px; margin-bottom: 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.modal h2 .close-btn {
  background: transparent; border: none; color: var(--text-dim);
  font-size: 24px; cursor: pointer; padding: 0;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
}
.modal h2 .close-btn:hover { background: var(--bg-2); color: var(--text); }

.profile-avatar-row {
  display: flex; flex-direction: column; align-items: center;
  gap: 12px; margin-bottom: 24px;
}
.profile-avatar-row .avatar { cursor: pointer; }
.profile-avatar-row .avatar:hover { opacity: 0.85; }
.profile-avatar-row .ava-actions { display: flex; gap: 8px; }
.profile-avatar-row .ava-actions button {
  padding: 6px 14px; font-size: 13px;
  background: var(--bg-2); color: var(--text);
  border: none; border-radius: 8px;
}
.profile-avatar-row .ava-actions button:hover { background: var(--bg-3); }
.profile-avatar-row .ava-actions button.danger { color: var(--danger); }

.profile-field { margin-bottom: 16px; }
.profile-field label {
  display: block; font-size: 12px; color: var(--text-dim);
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;
}
.profile-field input, .profile-field textarea {
  width: 100%; padding: 10px 12px;
  background: var(--bg-0); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text);
  font-size: 14px; outline: none;
}
.profile-field input:focus, .profile-field textarea:focus { border-color: var(--accent); }
.profile-field input:disabled { opacity: 0.6; cursor: not-allowed; }
.profile-field .hint { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

.modal-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 20px;
}
.modal-actions button {
  padding: 9px 18px; border: none; border-radius: 8px;
  font-size: 14px; font-weight: 500;
}
.modal-actions .btn-primary { background: var(--accent); color: #fff; }
.modal-actions .btn-primary:hover { background: var(--accent-hover); }
.modal-actions .btn-secondary { background: var(--bg-2); color: var(--text); }
.modal-actions .btn-secondary:hover { background: var(--bg-3); }

.profile-saved {
  font-size: 12px; color: var(--success);
  text-align: center; margin-top: 8px;
  opacity: 0; transition: opacity 0.3s;
}
.profile-saved.show { opacity: 1; }

/* ----- модалка просмотра картинки ----- */
.image-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.9);
  display: none; align-items: center; justify-content: center;
  z-index: 1100; cursor: pointer;
}
.image-modal.show { display: flex; }
.image-modal img { max-width: 95vw; max-height: 95vh; }

/* ============================================================
   My Messenger v3 — новые функции: непрочитанные, галочки,
   ответы, действия с сообщениями, мобильный фикс нижней панели
   ============================================================ */

.contact .name-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.contact .name-line .name { flex: 1; }
.unread-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.contact.has-unread .preview {
  color: var(--text);
  font-weight: 500;
}

.reply-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--bg-1);
  border-top: 1px solid var(--border);
}
.reply-info {
  flex: 1;
  min-width: 0;
  border-left: 3px solid var(--accent);
  padding-left: 10px;
}
.reply-label {
  font-size: 11px;
  color: var(--accent-hover);
  font-weight: 600;
  margin-bottom: 2px;
}
.reply-text {
  font-size: 13px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reply-cancel {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-dim);
  font-size: 22px;
}
.reply-cancel:hover { background: var(--bg-2); color: var(--text); }

.reply-preview {
  border-left: 3px solid rgba(255,255,255,0.35);
  padding: 4px 8px;
  margin-bottom: 6px;
  background: rgba(0,0,0,0.12);
  border-radius: 6px;
  max-width: 100%;
}
.reply-author {
  font-size: 12px;
  color: #dbeaff;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reply-snippet {
  font-size: 12px;
  color: rgba(255,255,255,0.72);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.forwarded-label {
  font-size: 12px;
  color: rgba(255,255,255,0.62);
  margin-bottom: 4px;
  font-style: italic;
}

.bubble-row {
  align-items: center;
  gap: 6px;
}
.msg-menu-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  color: var(--text-dim);
  opacity: 0;
  transition: opacity .12s, background .12s, color .12s;
  flex-shrink: 0;
}
.bubble-row:hover .msg-menu-btn,
.bubble-row:focus-within .msg-menu-btn {
  opacity: 1;
}
.msg-menu-btn:hover {
  background: var(--bg-2);
  color: var(--text);
}
.bubble-row.me .msg-menu-btn { order: -1; }
@media (hover: none) {
  .msg-menu-btn { opacity: 1; }
}

.msg-status {
  margin-left: 5px;
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  letter-spacing: -2px;
}
.msg-status.read { color: #75c7ff; }
.edited { color: rgba(255,255,255,0.45); }
.deleted-text {
  color: rgba(255,255,255,0.55);
  font-style: italic;
}
.bubble-row.deleted .bubble {
  opacity: 0.78;
}

.action-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 1300;
  padding: 16px;
}
.action-sheet-overlay.show { display: flex; }
.action-sheet {
  width: 360px;
  max-width: 100%;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 8px;
  box-shadow: 0 18px 60px rgba(0,0,0,0.55);
}
.action-title {
  padding: 10px 12px;
  color: var(--text-dim);
  font-size: 12px;
  text-align: center;
}
.action-sheet button {
  width: 100%;
  padding: 13px 14px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  text-align: left;
}
.action-sheet button:hover { background: var(--bg-2); }
.action-sheet button.danger { color: var(--danger); }
.action-sheet button.cancel {
  margin-top: 6px;
  background: var(--bg-2);
  text-align: center;
}

.settings-section-title {
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  margin: 18px 0 12px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.btn-full-secondary {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-2);
  color: var(--text);
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 10px;
}
.btn-full-secondary:hover { background: var(--bg-3); }

/* анимации сообщений */
.bubble-row.new-message.me { animation: msgInMe 0.22s ease-out; }
.bubble-row.new-message.them { animation: msgInThem 0.22s ease-out; }
.bubble-row.new-message .bubble { animation: bubblePop 0.22s ease-out; }
@keyframes msgInMe {
  from { opacity: 0; transform: translateX(18px) translateY(8px); }
  to   { opacity: 1; transform: translateX(0) translateY(0); }
}
@keyframes msgInThem {
  from { opacity: 0; transform: translateX(-18px) translateY(8px); }
  to   { opacity: 1; transform: translateX(0) translateY(0); }
}
@keyframes bubblePop {
  0% { transform: scale(0.92); }
  70% { transform: scale(1.03); }
  100% { transform: scale(1); }
}
.input-bar .send-btn.sending { animation: sendPulse 0.22s ease-out; }
@keyframes sendPulse {
  0% { transform: scale(1); }
  50% { transform: scale(0.86) rotate(-8deg); }
  100% { transform: scale(1) rotate(0); }
}

/* фикс мобильной высоты, чтобы поле ввода не пропадало */
.app {
  height: 100vh;
  height: 100dvh;
}
@media (max-width: 720px) {
  html, body {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
  }
  .app {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }
  .chat,
  .chat-active {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }
  .messages {
    flex: 1;
    min-height: 0;
    padding-bottom: 8px;
  }
  .reply-bar {
    padding: 8px 10px;
  }
  .input-bar {
    position: sticky;
    bottom: 0;
    z-index: 50;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    gap: 6px;
  }
  .input-bar textarea {
    min-width: 0;
    font-size: 16px;
  }
  .input-bar .icon-btn {
    width: 38px;
    height: 38px;
    padding: 6px;
    font-size: 20px;
  }
  .bubble { max-width: 82%; }
  .modal { max-height: 88dvh; }
}

@media (prefers-reduced-motion: reduce) {
  .bubble-row.new-message.me,
  .bubble-row.new-message.them,
  .bubble-row.new-message .bubble,
  .input-bar .send-btn.sending {
    animation: none;
  }
}

/* ============================================================
   My Messenger v4 — улучшенный дизайн, PWA, группы, поиск
   ============================================================ */
body {
  background:
    radial-gradient(circle at 10% 10%, rgba(82,136,193,.15), transparent 35%),
    radial-gradient(circle at 90% 90%, rgba(54,179,126,.08), transparent 32%),
    var(--bg-0);
}
body[data-theme="midnight"] {
  --bg-0:#07111f; --bg-1:#0c1a2b; --bg-2:#152b46; --bg-3:#1d5a96;
  --accent:#5eb1ff; --accent-hover:#7cc0ff; --bubble-me:#1f6aa5; --bubble-them:#11243a;
}
body[data-theme="light"] {
  --bg-0:#e9eef7; --bg-1:#ffffff; --bg-2:#edf3fb; --bg-3:#dbeafe;
  --accent:#2672c9; --accent-hover:#3a86dd; --text:#17212b; --text-dim:#64748b;
  --border:#d8e2ef; --bubble-me:#d7ecff; --bubble-them:#ffffff;
}
body[data-theme="light"] .bubble .time,
body[data-theme="light"] .bubble .file-attach .file-meta .size { color: rgba(23,33,43,.55); }
body[data-theme="light"] .bubble-row.me .bubble,
body[data-theme="light"] .bubble-row.them .bubble { color: var(--text); border:1px solid var(--border); }

.app {
  height: 100vh;
  height: 100dvh;
  backdrop-filter: blur(10px);
}
.sidebar {
  background: rgba(23,33,43,.88);
  backdrop-filter: blur(18px);
}
body[data-theme="light"] .sidebar { background: rgba(255,255,255,.88); }
.sidebar-header {
  padding: 14px 14px;
  gap: 8px;
}
.round-btn, .chat-tool-btn {
  border:none; color:var(--text); background:var(--bg-2);
  width:36px; height:36px; border-radius:12px;
  display:flex; align-items:center; justify-content:center;
  font-size:18px; flex-shrink:0; transition:.15s transform,.15s background;
}
.round-btn:hover, .chat-tool-btn:hover { background:var(--bg-3); transform:translateY(-1px); }
.sidebar-title-row {
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 16px 8px;
}
.sidebar-title { font-size:22px; font-weight:800; letter-spacing:.2px; }
.sidebar-subtitle { font-size:12px; color:var(--text-dim); margin-top:2px; }
.small-pill {
  border:1px solid var(--border); background:var(--bg-2); color:var(--text);
  border-radius:999px; padding:7px 12px; font-size:12px;
}
.small-pill:hover { background:var(--bg-3); }
.search { padding:8px 14px 12px; }
.search input {
  border-radius:14px; padding:11px 14px; background:rgba(0,0,0,.18); border-color:rgba(255,255,255,.04);
}
body[data-theme="light"] .search input { background:#f5f8fc; }
.contact {
  margin: 4px 10px;
  border-radius: 16px;
  border-bottom: 0;
  padding: 11px 12px;
}
.contact:hover { transform: translateX(2px); }
.contact.active {
  background: linear-gradient(135deg, var(--bg-3), rgba(82,136,193,.35));
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.contact.has-unread .name { font-weight: 800; }
.group-avatar { font-size: 18px; background: linear-gradient(135deg, var(--accent), var(--bg-3)); }
.chat-header {
  background: rgba(23,33,43,.86);
  backdrop-filter: blur(18px);
  padding: 12px 16px;
}
body[data-theme="light"] .chat-header { background: rgba(255,255,255,.88); }
.empty-hero { text-align:center; max-width:340px; padding:30px; }
.empty-logo { font-size:54px; margin-bottom:12px; }
.empty-title { font-size:24px; font-weight:800; margin-bottom:8px; }
.empty-text { color:var(--text-dim); line-height:1.5; }
.messages {
  padding: 18px 18px 20px;
  background:
    radial-gradient(circle at 15% 15%, rgba(82,136,193,.06), transparent 30%),
    radial-gradient(circle at 85% 85%, rgba(82,136,193,.05), transparent 30%);
}
.bubble {
  box-shadow: 0 8px 26px rgba(0,0,0,.16);
  border:1px solid rgba(255,255,255,.04);
}
.bubble-row.me .bubble {
  background: linear-gradient(135deg, var(--bubble-me), color-mix(in srgb, var(--bubble-me) 85%, #fff 15%));
}
.bubble-row.them .bubble {
  background: color-mix(in srgb, var(--bubble-them) 92%, #fff 8%);
}
.group-author {
  color: var(--accent-hover);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 3px;
}
.input-bar {
  background: rgba(23,33,43,.9);
  backdrop-filter: blur(18px);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
}
body[data-theme="light"] .input-bar { background: rgba(255,255,255,.92); }
.input-bar textarea {
  border-radius: 16px;
  min-height: 40px;
  padding: 10px 14px;
}
.input-bar .icon-btn { border-radius: 14px; }
.send-btn { box-shadow:0 8px 20px rgba(82,136,193,.25); }

.settings-modal { width: 820px; }
.settings-grid {
  display:grid; grid-template-columns: 1fr 1fr; gap:14px;
}
.settings-card {
  background: color-mix(in srgb, var(--bg-0) 78%, var(--bg-1) 22%);
  border:1px solid var(--border);
  border-radius:16px;
  padding:16px;
}
.settings-card .profile-avatar-row.compact { margin-bottom:16px; }
.settings-text { color:var(--text-dim); font-size:13px; line-height:1.45; margin:6px 0 12px; }
.btn-block { width:100%; padding:10px; border-radius:10px; border:0; }
.theme-buttons { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin-bottom:10px; }
.theme-buttons button {
  border:1px solid var(--border); background:var(--bg-2); color:var(--text);
  border-radius:12px; padding:10px 8px;
}
.theme-buttons button:hover { background:var(--bg-3); }
.small-modal { width: 460px; }
.profile-field textarea {
  width:100%; resize:vertical; min-height:90px;
  background: var(--bg-0); border:1px solid var(--border);
  border-radius:8px; color:var(--text); padding:10px 12px; outline:none;
}
.search-modal { width: 620px; }
.search-results { max-height: 60vh; overflow:auto; display:flex; flex-direction:column; gap:8px; }
.search-result {
  text-align:left; border:1px solid var(--border); background:var(--bg-0); color:var(--text);
  border-radius:14px; padding:12px; cursor:pointer;
}
.search-result:hover { background:var(--bg-2); }
.search-result-top { display:flex; align-items:center; justify-content:space-between; gap:10px; }
.search-result-top span { font-size:11px; color:var(--text-dim); }
.search-result-from { color:var(--accent-hover); font-size:12px; margin-top:5px; }
.search-result-text { color:var(--text-dim); font-size:13px; margin-top:4px; line-height:1.4; }
.highlight-message .bubble { animation: highlightPulse 1.8s ease-out; }
@keyframes highlightPulse {
  0%,100% { box-shadow: 0 8px 26px rgba(0,0,0,.16); }
  30% { box-shadow: 0 0 0 6px rgba(82,136,193,.35), 0 8px 26px rgba(0,0,0,.2); }
}

@media (max-width: 720px) {
  html, body { height:100%; height:100dvh; overflow:hidden; }
  .app { height:100dvh; min-height:100dvh; overflow:hidden; }
  .chat, .chat-active { height:100%; min-height:0; overflow:hidden; }
  .sidebar-title-row { padding:12px 14px 6px; }
  .sidebar-title { font-size:20px; }
  .messages { padding:14px 10px 12px; }
  .bubble { max-width:82%; }
  .input-bar { position:sticky; bottom:0; z-index:50; padding:8px 10px calc(8px + env(safe-area-inset-bottom)); gap:6px; }
  .input-bar textarea { min-width:0; font-size:16px; }
  .input-bar .icon-btn { width:38px; height:38px; padding:6px; font-size:20px; }
  .settings-modal, .search-modal, .small-modal { width:100%; max-height:92vh; }
  .settings-grid { grid-template-columns:1fr; }
  .theme-buttons { grid-template-columns:1fr; }
}

/* ===== уведомления ===== */
#notification-status {
  margin-top: 10px;
  line-height: 1.4;
}
#btn-test-notification {
  margin-top: 8px;
}


/* ============================================================
   My Messenger v4.1 — удаление с анимацией, мобильный свайп,
   визуальная полировка интерфейса
   ============================================================ */
:root {
  --panel-glass: rgba(23, 33, 43, .82);
  --panel-glass-strong: rgba(23, 33, 43, .94);
  --soft-shadow: 0 18px 46px rgba(0, 0, 0, .22);
  --soft-border: rgba(255, 255, 255, .07);
}
body[data-theme="light"] {
  --panel-glass: rgba(255, 255, 255, .86);
  --panel-glass-strong: rgba(255, 255, 255, .96);
  --soft-shadow: 0 18px 46px rgba(36, 54, 84, .12);
  --soft-border: rgba(24, 42, 68, .09);
}
.sidebar {
  border-right: 1px solid var(--soft-border);
  box-shadow: inset -1px 0 0 rgba(255,255,255,.03);
}
.sidebar-header,
.chat-header,
.input-bar,
.reply-bar {
  background: var(--panel-glass-strong);
  border-color: var(--soft-border);
}
.contact {
  position: relative;
  overflow: hidden;
  transition: transform .18s ease, background .18s ease, box-shadow .18s ease;
}
.contact::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--accent);
  opacity: 0;
  transition: opacity .18s ease;
}
.contact:hover { box-shadow: 0 10px 26px rgba(0,0,0,.12); }
.contact.active::before,
.contact.has-unread::before { opacity: 1; }
.contact.active .preview,
.contact.active .name { color: #fff; }
body[data-theme="light"] .contact.active .preview,
body[data-theme="light"] .contact.active .name { color: var(--text); }
.messages {
  gap: 6px;
  scroll-behavior: smooth;
}
.bubble-row {
  transform-origin: center bottom;
  transition: opacity .2s ease, transform .2s ease, max-height .24s ease, margin .24s ease, filter .2s ease;
}
.bubble-row.message-removing {
  opacity: 0;
  transform: translateY(-8px) scale(.96);
  filter: blur(1px);
  overflow: hidden;
  pointer-events: none;
}
.bubble-row.message-removing .bubble,
.bubble-row.message-removing .msg-menu-btn {
  transform: scale(.98);
}
.bubble {
  border-radius: 18px;
  transition: transform .16s ease, box-shadow .16s ease, background .18s ease;
}
.bubble-row:hover .bubble {
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(0,0,0,.20);
}
.bubble-row.me .bubble { border-bottom-right-radius: 7px; }
.bubble-row.them .bubble { border-bottom-left-radius: 7px; }
.msg-menu-btn {
  box-shadow: 0 6px 18px rgba(0,0,0,.16);
  backdrop-filter: blur(10px);
}
.input-bar {
  box-shadow: 0 -12px 34px rgba(0,0,0,.12);
}
.input-bar textarea {
  border: 1px solid var(--soft-border);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
.input-bar textarea:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent), inset 0 1px 0 rgba(255,255,255,.04);
}
.round-btn:active,
.chat-tool-btn:active,
.input-bar .icon-btn:active,
.btn-full-secondary:active {
  transform: scale(.96);
}
.modal,
.action-sheet,
.settings-card,
.search-result {
  box-shadow: var(--soft-shadow);
  border-color: var(--soft-border);
}
.action-sheet-overlay.show .action-sheet {
  animation: sheetRise .18s ease-out;
}
@keyframes sheetRise {
  from { opacity: 0; transform: translateY(18px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 720px) {
  .app.chat-open .chat {
    display: flex;
  }
  .app.chat-open .chat-active:not(.mobile-swiping):not(.mobile-chat-closing):not(.mobile-snap-back) {
    animation: mobileChatIn .22s cubic-bezier(.2,.8,.2,1);
  }
  .chat-active {
    will-change: transform, opacity;
    box-shadow: -24px 0 60px rgba(0,0,0,.22);
    position: relative;
  }
  .chat-active.mobile-swiping {
    transition: none;
  }
  .chat-active.mobile-swiping::before {
    content: '← к чатам';
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;
    pointer-events: none;
    padding: 8px 12px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 88%, #000 12%);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    box-shadow: 0 10px 30px rgba(0,0,0,.25);
    opacity: .92;
  }
  .chat-active.mobile-snap-back {
    transition: transform .2s cubic-bezier(.2,.8,.2,1), opacity .2s ease;
  }
  .chat-active.mobile-chat-closing {
    transform: translateX(100%) !important;
    opacity: .82;
    transition: transform .22s cubic-bezier(.4,0,.2,1), opacity .22s ease;
  }
  .contact {
    margin: 5px 10px;
    padding: 12px;
  }
  .chat-header {
    min-height: 62px;
    box-shadow: 0 10px 28px rgba(0,0,0,.13);
  }
  .messages {
    padding-top: 16px;
  }
  .bubble-row.message-removing {
    transform: translateX(18px) scale(.95);
  }
}
@keyframes mobileChatIn {
  from { opacity: .85; transform: translateX(34px); }
  to { opacity: 1; transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) {
  .bubble-row,
  .bubble,
  .contact,
  .chat-active.mobile-chat-closing,
  .chat-active.mobile-snap-back {
    transition: none !important;
    animation: none !important;
  }
}

/* ============================================================
   My Messenger v4.2 — Modern dark glass redesign
   ============================================================ */
:root {
  --bg-0: #07101c;
  --bg-1: rgba(11, 19, 33, 0.78);
  --bg-2: rgba(19, 31, 53, 0.88);
  --bg-3: #173968;
  --accent: #4da3ff;
  --accent-hover: #78bbff;
  --text: #f4f7fb;
  --text-dim: #8ca0bf;
  --border: rgba(158, 191, 255, 0.10);
  --bubble-me: #173a69;
  --bubble-them: rgba(18, 30, 51, 0.9);
  --glass-heavy: rgba(9, 17, 31, 0.74);
  --glass: rgba(13, 22, 38, 0.62);
  --glass-soft: rgba(255, 255, 255, 0.04);
  --panel-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  --elev-1: 0 10px 28px rgba(0, 0, 0, 0.18);
  --elev-2: 0 18px 44px rgba(0, 0, 0, 0.28);
}
body[data-theme="midnight"] {
  --accent: #5fb5ff;
  --accent-hover: #8ccaff;
  --bubble-me: #14518c;
  --bubble-them: rgba(10, 25, 46, 0.92);
}
body[data-theme="light"] {
  --bg-0: #eef4fb;
  --bg-1: rgba(255, 255, 255, 0.76);
  --bg-2: rgba(245, 249, 255, 0.92);
  --bg-3: #d9eaff;
  --accent: #2878d8;
  --accent-hover: #3b8aea;
  --text: #172334;
  --text-dim: #61748f;
  --border: rgba(41, 85, 144, 0.12);
  --bubble-me: #dbeeff;
  --bubble-them: rgba(255, 255, 255, 0.92);
  --glass-heavy: rgba(255, 255, 255, 0.8);
  --glass: rgba(255, 255, 255, 0.7);
  --glass-soft: rgba(18, 34, 58, 0.04);
  --panel-shadow: 0 18px 54px rgba(37, 58, 91, 0.12);
  --elev-1: 0 10px 24px rgba(30, 58, 102, 0.08);
  --elev-2: 0 18px 40px rgba(30, 58, 102, 0.12);
}
html, body {
  background:
    radial-gradient(circle at 12% 10%, rgba(67, 124, 243, 0.22), transparent 28%),
    radial-gradient(circle at 88% 12%, rgba(40, 119, 216, 0.16), transparent 26%),
    radial-gradient(circle at 50% 100%, rgba(54, 93, 173, 0.12), transparent 34%),
    linear-gradient(180deg, #07101a 0%, #0b1320 38%, #09111c 100%);
  color: var(--text);
}
body[data-theme="light"] {
  background:
    radial-gradient(circle at 12% 10%, rgba(104, 160, 235, 0.26), transparent 26%),
    radial-gradient(circle at 88% 12%, rgba(117, 173, 243, 0.19), transparent 22%),
    linear-gradient(180deg, #eef4fb 0%, #eaf0f8 100%);
}
body::before,
body::after {
  content: '';
  position: fixed;
  inset: auto;
  width: 360px;
  height: 360px;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(110px);
  opacity: .22;
  z-index: 0;
}
body::before {
  top: -90px;
  left: -80px;
  background: #266ac7;
}
body::after {
  right: -120px;
  bottom: -80px;
  background: #1f4d90;
}
.app {
  position: relative;
  z-index: 1;
  gap: 16px;
  padding: 14px;
  background: transparent;
}
.sidebar,
.chat {
  background: var(--glass);
  border: 1px solid var(--border);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  box-shadow: var(--panel-shadow), inset 0 1px 0 rgba(255,255,255,.05);
  border-radius: 28px;
  overflow: hidden;
}
.sidebar {
  background:
    linear-gradient(180deg, rgba(255,255,255,.04), transparent 24%),
    var(--glass);
}
.chat {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255,255,255,.04), transparent 25%),
    var(--glass);
}
.sidebar-header {
  padding: 16px;
  gap: 10px;
  background: rgba(255,255,255,.02);
}
.sidebar-header .me-clickable {
  padding: 10px;
  border-radius: 18px;
  background: rgba(255,255,255,.02);
  border: 1px solid rgba(255,255,255,.04);
}
.sidebar-header .me-clickable:hover {
  background: rgba(255,255,255,.06);
}
.avatar {
  background: linear-gradient(135deg, rgba(77,163,255,.95), rgba(33,79,143,.95));
  box-shadow: 0 10px 24px rgba(25, 74, 143, 0.28);
}
.sidebar-header .me-info .name,
.chat-header .info .name,
.contact .info .name {
  letter-spacing: .1px;
}
.round-btn,
.chat-tool-btn,
.sidebar-header .logout {
  border: 1px solid rgba(255,255,255,.05);
  background: rgba(255,255,255,.04);
  color: var(--text);
  box-shadow: var(--elev-1);
}
.round-btn:hover,
.chat-tool-btn:hover,
.sidebar-header .logout:hover {
  background: rgba(255,255,255,.09);
}
.sidebar-title-row {
  padding: 8px 16px 10px;
}
.sidebar-title {
  font-size: 24px;
  font-weight: 800;
}
.sidebar-subtitle {
  color: var(--text-dim);
  font-size: 12px;
}
.small-pill {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.06);
  box-shadow: var(--elev-1);
}
.search {
  padding: 8px 16px 12px;
}
.search input,
.profile-field input,
.profile-field textarea,
.auth-card input,
#message-search-input {
  background: rgba(255,255,255,.045);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 18px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}
.search input:focus,
.profile-field input:focus,
.profile-field textarea:focus,
.auth-card input:focus,
#message-search-input:focus,
.input-bar textarea:focus {
  border-color: color-mix(in srgb, var(--accent) 62%, white 6%);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent), inset 0 1px 0 rgba(255,255,255,.03);
}
.contacts {
  padding: 4px 8px 10px;
}
.contact {
  margin: 5px 6px;
  padding: 12px 13px;
  border-radius: 22px;
  background: rgba(255,255,255,.03);
  border: 1px solid transparent;
}
.contact:hover {
  background: rgba(255,255,255,.055);
  border-color: rgba(255,255,255,.05);
  transform: translateX(3px) translateY(-1px);
}
.contact.active {
  background:
    linear-gradient(135deg, rgba(77,163,255,.28), rgba(18,42,74,.82)),
    rgba(255,255,255,.05);
  border-color: rgba(112, 179, 255, 0.24);
  box-shadow: 0 18px 42px rgba(13, 31, 56, 0.28);
}
.contact .preview {
  color: var(--text-dim);
  margin-top: 3px;
}
.unread-badge {
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 72%, white 28%));
  box-shadow: 0 10px 20px rgba(40, 119, 216, 0.28);
}
.chat-empty {
  background:
    radial-gradient(circle at 20% 18%, rgba(77,163,255,.08), transparent 28%),
    radial-gradient(circle at 80% 82%, rgba(77,163,255,.06), transparent 32%),
    transparent;
}
.empty-hero {
  background: rgba(255,255,255,.035);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 28px;
  padding: 34px 30px;
  box-shadow: var(--elev-2);
}
.empty-logo {
  width: 86px;
  height: 86px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(77,163,255,.24), rgba(21,58,107,.45));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 12px 28px rgba(15, 35, 64, 0.26);
}
.chat-header {
  padding: 14px 16px;
  background: rgba(8, 15, 29, 0.5);
  border-bottom: 1px solid rgba(255,255,255,.05);
  box-shadow: 0 10px 30px rgba(0,0,0,.10);
}
body[data-theme="light"] .chat-header {
  background: rgba(255,255,255,.56);
}
.chat-header .avatar {
  width: 42px;
  height: 42px;
}
.chat-header .info .name {
  font-size: 15px;
  font-weight: 700;
}
.chat-header .info .status {
  font-size: 12px;
}
.messages {
  padding: 20px 18px 18px;
  gap: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.015), transparent 22%),
    radial-gradient(circle at 10% 12%, rgba(77,163,255,.06), transparent 22%),
    radial-gradient(circle at 88% 84%, rgba(77,163,255,.05), transparent 26%);
}
.bubble-row {
  gap: 8px;
}
.bubble {
  max-width: 76%;
  padding: 11px 14px 10px;
  border-radius: 22px;
  line-height: 1.46;
  box-shadow: var(--elev-1);
  border: 1px solid rgba(255,255,255,.05);
}
.bubble-row.them .bubble {
  background:
    linear-gradient(180deg, rgba(255,255,255,.04), transparent 35%),
    var(--bubble-them);
  border-bottom-left-radius: 8px;
}
.bubble-row.me .bubble {
  background:
    linear-gradient(180deg, rgba(255,255,255,.08), transparent 34%),
    linear-gradient(135deg, var(--bubble-me), color-mix(in srgb, var(--bubble-me) 82%, #66b6ff 18%));
  border-bottom-right-radius: 8px;
}
.group-author {
  color: #9dd0ff;
  margin-bottom: 5px;
}
.bubble .time {
  color: rgba(255,255,255,.58);
}
body[data-theme="light"] .bubble .time,
body[data-theme="light"] .bubble .file-attach .file-meta .size,
body[data-theme="light"] .forwarded-label,
body[data-theme="light"] .reply-snippet,
body[data-theme="light"] .deleted-text,
body[data-theme="light"] .msg-status {
  color: rgba(23,35,52,.58);
}
.reply-preview {
  background: rgba(255,255,255,.045);
  border-left: 3px solid color-mix(in srgb, var(--accent) 76%, white 24%);
  border-radius: 12px;
  padding: 7px 9px;
}
.forwarded-label {
  color: rgba(255,255,255,.7);
}
.msg-menu-btn {
  border: 1px solid rgba(255,255,255,.06);
  background: rgba(11, 18, 30, 0.56);
}
.msg-menu-btn:hover {
  background: rgba(255,255,255,.08);
}
.typing-indicator {
  padding: 2px 18px 8px;
  color: var(--text-dim);
}
.reply-bar {
  margin: 0 12px;
  border: 1px solid rgba(255,255,255,.05);
  border-bottom: none;
  border-radius: 18px 18px 0 0;
  background: rgba(255,255,255,.03);
}
.reply-label {
  color: var(--accent-hover);
}
.input-bar {
  margin: 0 12px 12px;
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 22px;
  background: rgba(7, 13, 25, 0.52);
  box-shadow: var(--elev-2);
}
body[data-theme="light"] .input-bar {
  background: rgba(255,255,255,.68);
}
.input-bar textarea {
  min-height: 42px;
  background: rgba(255,255,255,.05);
  border-radius: 16px;
}
.input-bar .icon-btn {
  border-radius: 14px;
  width: 42px;
  height: 42px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.04);
}
.input-bar .icon-btn:hover {
  background: rgba(255,255,255,.09);
}
.input-bar .send-btn {
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 75%, white 25%));
  box-shadow: 0 14px 26px rgba(40, 119, 216, 0.32);
}
.modal-overlay {
  background: rgba(4, 8, 15, 0.62);
  backdrop-filter: blur(10px);
}
.modal,
.action-sheet {
  background:
    linear-gradient(180deg, rgba(255,255,255,.05), transparent 24%),
    var(--glass-heavy);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 26px;
  box-shadow: var(--panel-shadow);
}
.settings-card,
.search-result {
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 20px;
}
.settings-section-title {
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 14px;
}
.profile-field label {
  color: var(--text-dim);
  margin-bottom: 8px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
}
.profile-avatar-row .ava-actions button,
.modal-actions button,
.btn-block,
.btn-full-secondary,
.theme-buttons button,
#btn-enable-notifications,
#btn-test-notification,
#profile-save,
#group-create,
#group-cancel {
  border-radius: 14px;
}
.btn-primary,
.modal-actions .btn-primary,
#profile-save,
#group-create {
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 76%, white 24%));
  color: #fff;
  box-shadow: 0 12px 26px rgba(40, 119, 216, 0.28);
}
.btn-secondary,
.btn-full-secondary,
.profile-avatar-row .ava-actions button,
.modal-actions .btn-secondary,
.theme-buttons button {
  background: rgba(255,255,255,.05);
  color: var(--text);
  border: 1px solid rgba(255,255,255,.06);
}
.auth-wrap {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 18%, rgba(77,163,255,.18), transparent 25%),
    radial-gradient(circle at 82% 20%, rgba(77,163,255,.12), transparent 22%),
    linear-gradient(180deg, #07101a 0%, #0a1320 100%);
}
.auth-wrap::before,
.auth-wrap::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .26;
}
.auth-wrap::before {
  width: 260px;
  height: 260px;
  left: -60px;
  top: -50px;
  background: #2368c1;
}
.auth-wrap::after {
  width: 320px;
  height: 320px;
  right: -90px;
  bottom: -80px;
  background: #19447d;
}
.auth-card {
  position: relative;
  z-index: 1;
  background:
    linear-gradient(180deg, rgba(255,255,255,.06), transparent 22%),
    rgba(10, 18, 31, 0.72);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 28px;
  backdrop-filter: blur(22px) saturate(140%);
  box-shadow: var(--panel-shadow);
}
.auth-card h1 {
  font-size: 28px;
  margin-bottom: 8px;
}
.auth-tabs {
  border-radius: 16px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.05);
}
.auth-tabs button {
  border-radius: 12px;
}
.auth-tabs button.active {
  background: linear-gradient(135deg, rgba(77,163,255,.24), rgba(31,82,148,.42));
}
.empty-list,
.settings-text,
.hint,
.search-result-text {
  color: var(--text-dim);
}
.profile-saved {
  color: #8de297;
}
@media (max-width: 960px) {
  .app {
    gap: 12px;
    padding: 10px;
  }
  .sidebar,
  .chat {
    border-radius: 24px;
  }
}
@media (max-width: 720px) {
  .app {
    padding: 6px;
    gap: 0;
  }
  .sidebar,
  .chat {
    border-radius: 24px;
    min-height: calc(100dvh - 12px);
  }
  .app.chat-open .sidebar {
    display: none;
  }
  .chat-active {
    box-shadow: none;
  }
  .sidebar-header,
  .chat-header {
    padding: 14px;
  }
  .sidebar-title {
    font-size: 22px;
  }
  .contact {
    margin: 5px 6px;
    border-radius: 20px;
  }
  .messages {
    padding: 14px 10px 10px;
  }
  .bubble {
    max-width: 86%;
    border-radius: 20px;
  }
  .reply-bar {
    margin: 0 8px;
    border-radius: 16px 16px 0 0;
  }
  .input-bar {
    margin: 0 8px 8px;
    border-radius: 18px;
    gap: 6px;
  }
  .input-bar .icon-btn {
    width: 40px;
    height: 40px;
  }
  .input-bar textarea {
    font-size: 16px;
  }
  .modal,
  .settings-modal,
  .search-modal,
  .small-modal {
    border-radius: 22px;
    padding: 18px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .chat,
  .contact,
  .bubble,
  .auth-card,
  .input-bar .send-btn {
    transition: none !important;
  }
}


/* ============================================================
   My Messenger v4.2.1 — выбор зоны аватарки
   ============================================================ */
.avatar-crop-overlay {
  z-index: 1250;
}
.avatar-crop-modal {
  width: 430px;
  max-width: min(430px, 94vw);
}
.avatar-crop-stage {
  width: min(310px, 76vw);
  height: min(310px, 76vw);
  margin: 8px auto 14px;
  position: relative;
  overflow: hidden;
  border-radius: 30px;
  background:
    radial-gradient(circle at 30% 20%, rgba(77,163,255,.18), transparent 34%),
    rgba(255,255,255,.035);
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 18px 42px rgba(0,0,0,.25);
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.avatar-crop-stage.dragging {
  cursor: grabbing;
}
.avatar-crop-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  user-select: none;
}
.avatar-crop-stage::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 39.5%, rgba(0,0,0,.52) 40%);
}
.avatar-crop-stage::after {
  content: '';
  position: absolute;
  inset: 10%;
  z-index: 3;
  pointer-events: none;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.88);
  box-shadow: 0 0 0 999px rgba(0,0,0,.12), inset 0 0 0 1px rgba(77,163,255,.38);
}
.avatar-crop-hint {
  color: var(--text-dim);
  text-align: center;
  font-size: 13px;
  line-height: 1.45;
  margin: 0 auto 14px;
  max-width: 330px;
}
.avatar-crop-control {
  display: grid;
  grid-template-columns: 26px 1fr 26px;
  align-items: center;
  gap: 10px;
  color: var(--text-dim);
  margin: 0 4px 14px;
}
.avatar-crop-control span {
  text-align: center;
  font-weight: 700;
}
.avatar-crop-control input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}
.avatar-crop-modal .btn-primary:disabled {
  opacity: .65;
  cursor: wait;
}
@media (max-width: 720px) {
  .avatar-crop-modal {
    width: 100%;
  }
  .avatar-crop-stage {
    width: min(320px, 82vw);
    height: min(320px, 82vw);
    border-radius: 26px;
  }
}

/* ============================================================
   My Messenger v4.2.2 — фикс отображения аватарок после glass-дизайна
   ============================================================ */
.avatar {
  background-position: center center;
  background-size: cover;
  background-repeat: no-repeat;
}
.avatar[style*="background-image"] {
  background-position: center center !important;
  background-size: cover !important;
  background-repeat: no-repeat !important;
}
.profile-avatar-row .avatar.lg,
.sidebar-header .avatar,
.contact .avatar,
.chat-header .avatar {
  background-position: center center !important;
  background-size: cover !important;
  background-repeat: no-repeat !important;
}
