/* =========================================================
   WISP — design tokens
   ========================================================= */
:root {
  --bg-deep:     #0E1013;
  --surface:     #171A21;
  --surface-2:   #1E222B;
  --surface-3:   #262B36;
  --border:      #2A2F3A;
  --text:        #ECEEF3;
  --text-muted:  #8B92A3;
  --text-faint:  #565D6C;

  --violet:      #7C5CFC;
  --violet-dim:  #5B44BD;
  --teal:        #33D6C0;
  --coral:       #FF7A59;

  --grad: linear-gradient(135deg, var(--violet), var(--teal));

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 9px;

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --shadow-lift: 0 12px 32px rgba(0,0,0,.35);
}

/* ---------- Светлая тема ---------- */
:root[data-theme="light"] {
  --bg-deep:     #F3F4F8;
  --surface:     #FFFFFF;
  --surface-2:   #F1F2F7;
  --surface-3:   #E7E9F1;
  --border:      #E2E4EC;
  --text:        #1A1D27;
  --text-muted:  #6B7280;
  --text-faint:  #9CA3AF;

  --shadow-lift: 0 12px 32px rgba(20,20,40,.10);
}
:root[data-theme="light"] body::before {
  background:
    radial-gradient(600px 400px at 10% 0%, rgba(124,92,252,.07), transparent 60%),
    radial-gradient(600px 400px at 100% 100%, rgba(51,214,192,.06), transparent 60%);
}
:root[data-theme="light"] .msg-row.mine .bubble {
  background: linear-gradient(135deg, rgba(124,92,252,.16), rgba(51,214,192,.14));
  border-color: rgba(124,92,252,.28);
}
:root[data-theme="light"] .avatar-ring {
  box-shadow: 0 0 0 2px var(--surface), 0 1px 3px rgba(20,20,40,.08);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
input, textarea, button { font-family: inherit; }
button { cursor: pointer; }
::selection { background: var(--violet); color: #fff; }

/* subtle ambient background */
body::before {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(600px 400px at 10% 0%, rgba(124,92,252,.10), transparent 60%),
    radial-gradient(600px 400px at 100% 100%, rgba(51,214,192,.08), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* =========================================================
   AUTH SCREEN
   ========================================================= */
.auth-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  position: relative; z-index: 1;
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px 28px;
  box-shadow: var(--shadow-lift);
}
.auth-logo {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-weight: 700; font-size: 24px;
  margin-bottom: 4px;
}
.auth-tagline { color: var(--text-muted); font-size: 14px; margin: 6px 0 26px; }

.auth-tabs {
  display: flex; background: var(--surface-2);
  border-radius: var(--radius-sm); padding: 4px; margin-bottom: 22px;
}
.auth-tab {
  flex: 1; border: none; background: transparent; color: var(--text-muted);
  padding: 9px 0; border-radius: 7px; font-weight: 600; font-size: 14px;
  transition: all .15s ease;
}
.auth-tab.active { background: var(--surface-3); color: var(--text); }

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12.5px; color: var(--text-muted); font-weight: 500;
}
.auth-form input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 14.5px;
  outline: none;
  transition: border-color .15s ease, background .15s ease;
}
.auth-form input:focus { border-color: var(--violet); background: var(--surface-3); }

.auth-error { color: var(--coral); font-size: 13px; min-height: 0; margin: -4px 0 0; }
.auth-error:empty { display: none; }

.btn-primary {
  background: var(--grad); border: none; color: #0E1013;
  font-weight: 700; font-size: 14.5px;
  padding: 12px 0; border-radius: var(--radius-sm);
  margin-top: 4px;
  transition: transform .12s ease, filter .12s ease;
}
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary.danger { background: linear-gradient(135deg, var(--coral), #ff5f6d); }

.btn-ghost {
  width: 100%; margin-top: 14px; background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); padding: 10px 0; border-radius: var(--radius-sm); font-size: 13.5px;
  transition: border-color .15s ease, color .15s ease;
}
.btn-ghost:hover { border-color: var(--coral); color: var(--coral); }

/* =========================================================
   APP LAYOUT
   ========================================================= */
.app {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 340px 1fr;
  height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-width: 0;
}
.sidebar-top {
  display: flex; align-items: center; gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.my-avatar {
  width: 40px; height: 40px; border-radius: 50%; border: none; flex-shrink: 0;
  background: var(--grad); color: #fff; font-family: var(--font-display); font-weight: 700;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
  background-size: cover; background-position: center;
}
.search-wrap {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 8px 14px; color: var(--text-faint);
}
.search-wrap input {
  flex: 1; background: transparent; border: none; outline: none; color: var(--text); font-size: 13.5px;
}
.icon-btn {
  width: 34px; height: 34px; border-radius: 50%; border: none; background: var(--surface-2);
  color: var(--text-muted); display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: background .15s ease, color .15s ease;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.small { width: 26px; height: 26px; }

.search-results {
  border-bottom: 1px solid var(--border);
  max-height: 260px; overflow-y: auto;
}
.search-results.inline { border: 1px solid var(--border); border-radius: var(--radius-sm); max-height: 180px; margin-top: -6px; }
.search-result-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; cursor: pointer;
  transition: background .12s ease;
}
.search-result-item:hover { background: var(--surface-2); }
.search-result-name { font-size: 14px; font-weight: 600; }
.search-result-sub { font-size: 12px; color: var(--text-muted); }

.chat-list { flex: 1; overflow-y: auto; padding: 6px; }
.chat-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 10px; border-radius: var(--radius-md); cursor: pointer;
  transition: background .12s ease;
  position: relative;
}
.chat-item:hover { background: var(--surface-2); }
.chat-item.active { background: var(--surface-3); }
.chat-item-body { flex: 1; min-width: 0; }
.chat-item-top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.chat-item-name { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-time { font-size: 11px; color: var(--text-faint); font-family: var(--font-mono); flex-shrink: 0; }
.chat-item-preview { font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.unread-badge {
  background: var(--grad); color: #0E1013; font-weight: 700; font-size: 11px;
  min-width: 20px; height: 20px; border-radius: 999px; display: flex; align-items: center; justify-content: center;
  padding: 0 6px; flex-shrink: 0;
}

/* ---------- Avatars ---------- */
.avatar-ring {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 15px;
  background-size: cover; background-position: center;
  box-shadow: 0 0 0 2px var(--surface);
  position: relative;
}
.avatar-ring.online::after {
  content: ''; position: absolute; bottom: -1px; right: -1px;
  width: 11px; height: 11px; border-radius: 50%; background: var(--teal);
  border: 2px solid var(--surface);
}
.avatar-ring.big { width: 84px; height: 84px; font-size: 26px; margin: 0 auto; }
.avatar-ring.favorites-avatar { font-size: 18px; }
.avatar-ring.favorites-avatar.big { font-size: 34px; }

/* ---------- Chat pane ---------- */
.chat-pane { position: relative; min-width: 0; display: flex; flex-direction: column; }
.empty-state {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-muted); gap: 10px; text-align: center;
}
.empty-wisp {
  width: 72px; height: 72px; border-radius: 46% 54% 60% 40% / 50% 46% 54% 50%;
  background: var(--grad); opacity: .35; margin-bottom: 6px;
  animation: float 5s ease-in-out infinite;
}
@keyframes float { 0%,100% { transform: translateY(0) rotate(0deg);} 50% { transform: translateY(-10px) rotate(6deg);} }
.empty-state h2 { font-family: var(--font-display); margin: 0; color: var(--text); }
.empty-state p { margin: 0; font-size: 14px; }

.chat-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.chat-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-title { font-weight: 700; font-size: 15px; font-family: var(--font-display); }
.chat-header-sub { font-size: 12.5px; color: var(--text-muted); }
.chat-header-sub.typing { color: var(--teal); font-weight: 600; }
.only-mobile { display: none; }

.messages {
  flex: 1; overflow-y: auto; padding: 20px 24px;
  display: flex; flex-direction: column; gap: 3px;
}
.msg-day-sep {
  align-self: center; font-size: 11.5px; color: var(--text-faint);
  background: var(--surface-2); padding: 4px 12px; border-radius: 999px;
  margin: 14px 0 10px; font-family: var(--font-mono);
}
.msg-row { display: flex; gap: 8px; max-width: 62%; margin-top: 8px; }
.msg-row.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg-row .avatar-ring { width: 30px; height: 30px; font-size: 12px; align-self: flex-end; }
.msg-row.grouped { margin-top: 2px; }
.msg-row.grouped .avatar-ring { visibility: hidden; }

.bubble {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 9px 13px 8px;
  border-radius: 16px 16px 16px 4px;
  position: relative;
}
.msg-row.mine .bubble {
  background: linear-gradient(135deg, rgba(124,92,252,.35), rgba(51,214,192,.22));
  border-color: rgba(124,92,252,.35);
  border-radius: 16px 16px 4px 16px;
}
.bubble-sender { font-size: 12px; font-weight: 700; margin-bottom: 3px; }
.bubble-reply {
  border-left: 2px solid var(--violet); padding: 3px 8px; margin-bottom: 5px;
  font-size: 12px; color: var(--text-muted); background: rgba(255,255,255,.03); border-radius: 4px;
}
.bubble-reply b { color: var(--text); }
.bubble-content { font-size: 14.5px; line-height: 1.4; white-space: pre-wrap; word-break: break-word; }
.bubble-content.deleted { color: var(--text-faint); font-style: italic; }
.bubble-meta { display: flex; gap: 5px; align-items: center; justify-content: flex-end; margin-top: 3px; }
.bubble-time { font-size: 10.5px; color: var(--text-faint); font-family: var(--font-mono); }
.bubble-edited { font-size: 10px; color: var(--text-faint); font-style: italic; }
.bubble-ticks { font-size: 12px; color: var(--text-faint); letter-spacing: -2px; }
.bubble-ticks.read { color: var(--teal); }

/* ---------- Реакции на сообщения ---------- */
.reaction-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.reaction-chip {
  display: flex; align-items: center; gap: 4px;
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: 999px; padding: 2px 8px; font-size: 12px;
  transition: border-color .12s ease, background .12s ease;
}
.reaction-chip:hover { border-color: var(--violet); }
.reaction-chip.mine { background: rgba(124,92,252,.22); border-color: var(--violet); }
.reaction-chip-count { font-family: var(--font-mono); color: var(--text-muted); font-size: 11px; }
.reaction-chip.mine .reaction-chip-count { color: var(--text); }

/* ---------- Плавающий пикер эмодзи ---------- */
.emoji-picker {
  position: fixed; z-index: 60;
  display: flex; gap: 2px; padding: 6px;
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: 999px; box-shadow: var(--shadow-lift);
}
.emoji-picker button {
  border: none; background: transparent; font-size: 19px;
  width: 32px; height: 32px; border-radius: 50%; transition: background .12s ease, transform .1s ease;
}
.emoji-picker button:hover { background: var(--surface-2); transform: scale(1.15); }

.msg-actions {
  position: absolute; top: -14px; right: 8px;
  display: none; gap: 3px; background: var(--surface-3); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px;
}
.msg-row.mine .msg-actions { right: auto; left: 8px; }
.bubble:hover .msg-actions { display: flex; }
.msg-actions button {
  border: none; background: transparent; color: var(--text-muted); font-size: 12px;
  width: 22px; height: 22px; border-radius: 50%;
}
.msg-actions button:hover { background: var(--surface-2); color: var(--text); }

.reply-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 20px; background: var(--surface-2); border-top: 1px solid var(--border);
}
.reply-bar-line { width: 2px; height: 28px; background: var(--violet); border-radius: 2px; }
.reply-bar-text { flex: 1; min-width: 0; font-size: 12.5px; }
.reply-bar-text span { display: block; }
#reply-bar-name { font-weight: 700; color: var(--violet); }
#reply-bar-content { color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Закреплённое сообщение ---------- */
.pin-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px; background: var(--surface-2); border-bottom: 1px solid var(--border);
  cursor: default;
}
.pin-bar-icon { font-size: 15px; flex-shrink: 0; }
.pin-bar-text { flex: 1; min-width: 0; font-size: 12.5px; display: flex; flex-direction: column; }
.pin-bar-label { font-weight: 700; color: var(--teal); font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
#pin-bar-content { color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Пересланное сообщение ---------- */
.bubble-forwarded {
  font-size: 12px; color: var(--teal); font-weight: 600; margin-bottom: 4px;
  display: flex; align-items: center; gap: 4px;
}
.bubble-forwarded b { color: var(--text); font-weight: 700; }

/* ---------- Список чатов для пересылки ---------- */
.forward-chat-list { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.forward-chat-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-radius: var(--radius-md);
  cursor: pointer; transition: background .12s ease;
}
.forward-chat-item:hover { background: var(--surface-2); }
.forward-chat-item input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--violet); flex-shrink: 0; }
.forward-chat-item .chat-item-name { font-size: 14px; font-weight: 600; }

.composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface);
  position: relative;
}
.composer textarea {
  flex: 1; resize: none; max-height: 140px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-md); padding: 11px 15px; font-size: 14.5px; outline: none;
  transition: border-color .15s ease;
  line-height: 1.4;
}
.composer textarea:focus { border-color: var(--violet); }
.composer .icon-btn { width: 40px; height: 40px; flex-shrink: 0; }
.send-btn {
  width: 42px; height: 42px; border-radius: 50%; border: none; background: var(--grad);
  color: #0E1013; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: transform .12s ease;
}
.send-btn:hover { transform: scale(1.06); }
.send-btn:active { transform: scale(.96); }

.mic-btn.recording { background: var(--coral); color: #fff; }

/* ---------- Индикатор записи голоса ---------- */
.record-indicator {
  flex: 1; min-height: 42px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md);
  display: flex; align-items: center; gap: 10px; padding: 0 15px;
  font-size: 13.5px; color: var(--text-muted);
}
.record-dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--coral);
  animation: pulse-dot 1s ease-in-out infinite;
}
@keyframes pulse-dot { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
#record-timer { font-family: var(--font-mono); color: var(--text); font-weight: 600; }
.record-hint { margin-left: auto; font-size: 12px; color: var(--text-faint); }
.record-hint strong { color: var(--teal); font-size: 15px; }

/* ---------- Превью прикреплённого файла перед отправкой ---------- */
.attach-preview {
  display: flex; align-items: center; gap: 10px;
  margin: 0 20px; padding: 8px 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.attach-preview-thumb {
  width: 38px; height: 38px; border-radius: 8px; background: var(--surface-3);
  background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 16px;
}
.attach-preview-info { flex: 1; min-width: 0; }
#attach-preview-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-preview-size { font-size: 11.5px; color: var(--text-faint); font-family: var(--font-mono); }
.attach-preview-thumb.multi { font-size: 13px; font-weight: 700; color: #0E1013; background: var(--grad); }

/* =========================================================
   ВЛОЖЕНИЯ В СООБЩЕНИЯХ
   ========================================================= */
.bubble.has-image { padding: 4px; overflow: hidden; }
.bubble-image {
  display: block; max-width: 280px; max-height: 320px; border-radius: 12px;
  cursor: pointer; object-fit: cover;
}
.bubble.has-image .bubble-content,
.bubble.has-image .bubble-meta { padding: 6px 8px 2px; }
.bubble.has-image .bubble-meta { justify-content: flex-end; }
.bubble.has-image .bubble-sender,
.bubble.has-image .bubble-reply { margin: 4px 6px 5px; }

.file-card {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.04); border-radius: 12px; padding: 8px 10px;
  text-decoration: none; color: inherit; min-width: 200px;
}
.file-card-icon {
  width: 38px; height: 38px; border-radius: 10px; background: var(--grad);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: #0E1013; font-weight: 700; font-size: 11px;
}
.file-card-info { min-width: 0; }
.file-card-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.file-card-size { font-size: 11.5px; color: var(--text-muted); font-family: var(--font-mono); }

.voice-player {
  display: flex; align-items: center; gap: 10px; min-width: 220px; padding: 2px 2px;
}
.voice-play-btn {
  width: 36px; height: 36px; border-radius: 50%; border: none; background: var(--grad);
  color: #0E1013; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: transform .1s ease;
}
.voice-play-btn:active { transform: scale(.92); }
.voice-track { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.voice-bars { display: flex; align-items: center; gap: 2px; height: 22px; position: relative; }
.voice-bar { width: 2.5px; border-radius: 2px; background: var(--text-faint); flex-shrink: 0; transition: background .15s ease; }
.voice-bar.played { background: var(--violet); }
.voice-time { font-size: 10.5px; color: var(--text-faint); font-family: var(--font-mono); }


/* =========================================================
   MODALS
   ========================================================= */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(6,7,9,.6); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-card {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px;
  box-shadow: var(--shadow-lift);
  max-height: 86vh; overflow-y: auto;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-head h3 { margin: 0; font-family: var(--font-display); }

.profile-avatar-edit { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 20px; }
.upload-link { color: var(--violet); font-size: 13px; font-weight: 600; cursor: pointer; }
.upload-link:hover { text-decoration: underline; }

.chip-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 6px 5px 10px; font-size: 12.5px;
}
.chip button { border: none; background: transparent; color: var(--text-faint); font-size: 12px; }

.member-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.member-row-name { font-size: 14px; font-weight: 600; }
.member-row-role { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; }
.member-list { max-height: 240px; overflow-y: auto; }

.member-actions { display: flex; gap: 5px; flex-shrink: 0; }
.member-action-btn {
  border: none; background: var(--surface-3); color: var(--text-muted);
  font-size: 11px; padding: 5px 9px; border-radius: 999px; white-space: nowrap;
  transition: background .12s ease, color .12s ease;
}
.member-action-btn:hover { background: var(--surface-2); color: var(--text); }
.member-action-btn.danger { color: var(--coral); }
.member-action-btn.danger:hover { background: rgba(255,122,89,.12); }

.add-member-box { margin-top: 12px; }
.add-member-input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 10px 13px; font-size: 13.5px; outline: none;
  transition: border-color .15s ease;
}
.add-member-input:focus { border-color: var(--violet); }

/* ---------- Поиск по сообщениям ---------- */
.search-msgs-results { max-height: 360px; overflow-y: auto; margin-top: 12px; }
.search-msg-item {
  padding: 10px 4px; border-bottom: 1px solid var(--border);
}
.search-msg-item:last-child { border-bottom: none; }
.search-msg-item-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 3px; }
.search-msg-sender { font-size: 13px; font-weight: 700; color: var(--violet); }
.search-msg-time { font-size: 11px; color: var(--text-faint); font-family: var(--font-mono); flex-shrink: 0; }
.search-msg-content { font-size: 13.5px; color: var(--text); line-height: 1.4; word-break: break-word; }
.search-msg-empty { padding: 20px 4px; text-align: center; color: var(--text-muted); font-size: 13.5px; }

/* ---------- Аватар группы (редактируемый) ---------- */
.group-avatar-edit { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 16px; }

/* ---------- Действия с чатом (в info-modal) ---------- */
.chat-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.chat-action-btn {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 11px 14px; border-radius: var(--radius-md); font-size: 14px; font-weight: 500;
  text-align: left; transition: background .12s ease, border-color .12s ease;
}
.chat-action-btn:hover { background: var(--surface-3); }
.chat-action-btn:disabled { opacity: .55; cursor: default; }
.chat-action-btn:disabled:hover { background: var(--surface-2); }
.chat-action-btn.danger { color: var(--coral); }
.chat-action-btn.danger:hover { border-color: var(--coral); }

/* ---------- Выбор при удалении сообщения ---------- */
.delete-choice-list { display: flex; flex-direction: column; gap: 10px; }
.delete-choice {
  display: flex; flex-direction: column; gap: 3px; text-align: left;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 13px 16px; border-radius: var(--radius-md);
  transition: background .12s ease, border-color .12s ease;
}
.delete-choice:hover { background: var(--surface-3); }
.delete-choice.danger { color: var(--coral); }
.delete-choice.danger:hover { border-color: var(--coral); }
.delete-choice-title { font-size: 14.5px; font-weight: 700; }
.delete-choice-sub { font-size: 12px; color: var(--text-muted); }
.delete-choice.danger .delete-choice-sub { color: rgba(255,122,89,.7); }

/* ---------- Двухфакторная аутентификация ---------- */
.twofa-secret-box {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; font-family: var(--font-mono); font-size: 15px; letter-spacing: 1.5px;
  text-align: center; word-break: break-all; margin: 10px 0;
  color: var(--violet); font-weight: 600;
}
.twofa-hint { font-size: 12.5px; color: var(--text-muted); line-height: 1.5; margin: 0 0 4px; }

/* ---------- Панель модерации ---------- */
.admin-tab {
  flex: 1; border: none; background: transparent; color: var(--text-muted);
  padding: 9px 0; border-radius: 7px; font-weight: 600; font-size: 13.5px;
  transition: all .15s ease; cursor: pointer;
}
.admin-tab.active { background: var(--surface-3); color: var(--text); }
.admin-list { max-height: 440px; overflow-y: auto; margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.admin-empty { text-align: center; color: var(--text-muted); font-size: 13.5px; padding: 30px 10px; }

.report-card {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 12px 14px;
}
.report-card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.report-card-chat { font-size: 12px; color: var(--text-faint); font-family: var(--font-mono); }
.report-card-reason { font-size: 12.5px; color: var(--coral); margin-bottom: 8px; }
.report-card-content {
  font-size: 13.5px; color: var(--text); background: rgba(255,255,255,.03);
  border-left: 2px solid var(--border); padding: 6px 10px; border-radius: 4px; margin-bottom: 8px;
  word-break: break-word;
}
.report-card-content.deleted { color: var(--text-faint); font-style: italic; }
.report-card-meta { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.report-card-meta b { color: var(--text); font-weight: 600; }
.report-card-actions { display: flex; gap: 8px; }
.report-card-actions button {
  flex: 1; border: none; padding: 8px 0; border-radius: var(--radius-sm); font-size: 12.5px; font-weight: 700;
}
.report-accept-btn { background: rgba(51,214,192,.16); color: var(--teal); }
.report-accept-btn:hover { background: rgba(51,214,192,.26); }
.report-reject-btn { background: var(--surface-3); color: var(--text-muted); }
.report-reject-btn:hover { background: rgba(255,122,89,.14); color: var(--coral); }
.report-status-badge {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; text-transform: uppercase;
}
.report-status-badge.accepted { background: rgba(51,214,192,.16); color: var(--teal); }
.report-status-badge.rejected { background: rgba(255,122,89,.14); color: var(--coral); }

.admin-user-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--border);
}
.admin-user-row:last-child { border-bottom: none; }
.admin-user-info { flex: 1; min-width: 0; }
.admin-user-name { font-size: 14px; font-weight: 600; }
.admin-user-sub { font-size: 11.5px; color: var(--text-faint); }
.admin-user-sub.banned { color: var(--coral); }
.admin-ban-btn {
  border: none; padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.admin-ban-btn.ban { background: rgba(255,122,89,.14); color: var(--coral); }
.admin-ban-btn.ban:hover { background: rgba(255,122,89,.24); }
.admin-ban-btn.unban { background: rgba(51,214,192,.16); color: var(--teal); }
.admin-ban-btn.unban:hover { background: rgba(51,214,192,.26); }
.admin-search-input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 10px 13px; font-size: 13.5px; outline: none; margin-top: 12px;
  transition: border-color .15s ease;
}
.admin-search-input:focus { border-color: var(--violet); }

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 780px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: absolute; inset: 0; z-index: 5; transition: transform .2s ease; }
  .app.chat-open .sidebar { transform: translateX(-100%); }
  .chat-pane { position: absolute; inset: 0; }
  .only-mobile { display: flex; }
  .msg-row { max-width: 82%; }
}

/* scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }
