﻿/* ===================================================================
   TeleClone — стили в духе Telegram (улучшенная версия)
   =================================================================== */

/* ----------------------------- ПЕРЕМЕННЫЕ ------------------------- */
:root {
  --accent:        #3390ec;
  --accent-hover:  #2b82dc;
  --accent-light:  rgba(51, 144, 236, 0.12);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
          Arial, 'Apple Color Emoji', 'Segoe UI Emoji', sans-serif;
  --radius:        12px;
  --header-h:      56px;
  --sidebar-w:     360px;
  --font-size:     15px;
  --transition:    .15s ease;
}

/* Светлая тема */
[data-theme="light"] {
  --bg-app:         #ffffff;
  --bg-sidebar:     #ffffff;
  --bg-chat:        #c8d5dc;
  --bg-pattern-op:  0.45;
  --bg-hover:       #f1f3f5;
  --bg-active:      var(--accent);
  --bg-secondary:   #f4f4f5;
  --bg-input:       #ffffff;
  --bg-composer:    #ffffff;
  --bubble-in:      #ffffff;
  --bubble-out:     #eeffde;
  --text:           #000000;
  --text-secondary: #707579;
  --text-on-accent: #ffffff;
  --text-meta:      #a0acb6;
  --border:         rgba(0, 0, 0, 0.08);
  --shadow:         0 1px 2px rgba(16, 35, 47, .12);
  --shadow-md:      0 4px 16px rgba(16, 35, 47, .12);
  --scrollbar:      #ccd1d4;
  --link:           #3390ec;
  --tick:           #4fae4e;
  --divider:        rgba(0, 0, 0, 0.06);
}

/* Тёмная тема */
[data-theme="dark"] {
  --bg-app:         #17212b;
  --bg-sidebar:     #17212b;
  --bg-chat:        #0e1621;
  --bg-pattern-op:  0.3;
  --bg-hover:       #1f2d3d;
  --bg-active:      #2b5278;
  --bg-secondary:   #232e3c;
  --bg-input:       #242f3d;
  --bg-composer:    #17212b;
  --bubble-in:      #182533;
  --bubble-out:     #2b5278;
  --text:           #e8e8e8;
  --text-secondary: #7d8e9b;
  --text-on-accent: #ffffff;
  --text-meta:      #5f7282;
  --border:         rgba(255, 255, 255, 0.05);
  --shadow:         0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md:      0 4px 16px rgba(0, 0, 0, .4);
  --scrollbar:      #2a3a4a;
  --link:           #71b7f5;
  --tick:           #71b7f5;
  --divider:        rgba(255, 255, 255, 0.04);
}

/* ----------------------------- БАЗА ------------------------------- */
*, *::before, *::after {
  margin: 0; padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font);
  font-size: var(--font-size);
  background: var(--bg-app);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; outline: none; border: none; background: none; color: inherit; }
img { display: block; }
svg {
  width: 24px; height: 24px;
  fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}

/* Скроллбар */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
  border-radius: 10px;
}
::-webkit-scrollbar-track { background: transparent; }
* { scrollbar-width: thin; scrollbar-color: var(--scrollbar) transparent; }

/* ----------------------------- АТОМЫ ----------------------------- */

/* Кнопка-иконка */
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition), transform .1s;
  flex-shrink: 0;
}
.icon-btn svg { pointer-events: none; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn:active { transform: scale(.9); }

/* Аватар */
.avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 16px; flex-shrink: 0;
  background-size: cover; background-position: center;
  overflow: hidden; user-select: none;
  letter-spacing: .3px;
}
.avatar-lg { width: 72px; height: 72px; font-size: 28px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ===================================================================
   ЭКРАН ВХОДА (split-panel)
   =================================================================== */
.auth-screen {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; height: 100%;
}

.auth-left {
  flex: 0 0 42%;
  background: var(--bg-app);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px;
  border-right: 1px solid var(--border);
  position: relative; z-index: 2;
}

.auth-heading {
  font-size: 20px; font-weight: 700; letter-spacing: -.2px;
  margin-bottom: 22px; color: var(--text); text-align: center;
}
.auth-form { width: 100%; max-width: 420px; }
.auth-form .field { position: relative; margin-bottom: 14px; display: flex; align-items: center; }
.field-icon {
  position: absolute; left: 14px;
  width: 18px; height: 18px; color: var(--text-meta);
  pointer-events: none; display: flex; align-items: center; justify-content: center;
  z-index: 2;
}
.field-icon svg { width: 18px; height: 18px; }
.auth-form input {
  width: 100%; padding: 14px 16px 14px 42px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--bg-input);
  font-size: 15px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.auth-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.auth-error {
  color: #e53935; font-size: 13px;
  min-height: 18px; margin-bottom: 10px; text-align: left;
  line-height: 1.4;
}
.btn-primary {
  width: 100%; padding: 14px;
  border-radius: 12px;
  background: var(--accent); color: #fff;
  font-size: 15px; font-weight: 600;
  letter-spacing: .3px;
  transition: background var(--transition), transform .1s, box-shadow var(--transition);
  box-shadow: 0 4px 14px rgba(51, 144, 236, .35);
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 6px 18px rgba(51, 144, 236, .4);
}
.btn-primary:active { transform: scale(.98); box-shadow: none; }
.btn-primary:disabled { opacity: .55; cursor: default; box-shadow: none; }

.auth-switch {
  margin-top: 24px; font-size: 14px; color: var(--text-secondary);
}
.auth-switch a {
  color: var(--accent); text-decoration: none;
  margin-left: 4px; font-weight: 500;
  transition: opacity var(--transition);
}
.auth-switch a:hover { text-decoration: underline; }

.auth-theme-toggle {
  position: absolute; bottom: 28px; left: 50%; transform: translateX(-50%);
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(0,0,0,.18); color: #fff;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.22);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), transform .15s ease;
  z-index: 3;
}
.auth-theme-toggle:hover { background: rgba(0,0,0,.38); transform: scale(1.06); }
.auth-theme-toggle:hover svg { filter: drop-shadow(0 0 6px rgba(255,255,255,.45)); }
.auth-theme-toggle:active { transform: scale(.92); }
.auth-theme-toggle svg { width: 18px; height: 18px; }

.auth-right {
  flex: 1;
  background:
    radial-gradient(circle at 50% 38%, rgba(120,200,255,.22), transparent 28%),
    radial-gradient(circle at 38% 55%, rgba(80,160,240,.14), transparent 36%),
    radial-gradient(ellipse at 20% 30%, rgba(51,144,236,.25), transparent 50%),
    radial-gradient(ellipse at 75% 70%, rgba(43,130,220,.18), transparent 50%),
    linear-gradient(145deg, #5b92d8, #3a72b2);
  position: relative; overflow: hidden;
}
[data-theme="dark"] .auth-right {
  background:
    radial-gradient(circle at 50% 38%, rgba(60,130,210,.16), transparent 28%),
    radial-gradient(circle at 38% 55%, rgba(50,100,180,.10), transparent 36%),
    radial-gradient(ellipse at 20% 30%, rgba(51,144,236,.22), transparent 50%),
    radial-gradient(ellipse at 75% 70%, rgba(43,82,120,.5), transparent 50%),
    linear-gradient(145deg, #12213a, #1a2a3e);
}

.auth-brand {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px; text-align: center;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0,0,0,.18);
}
.auth-brand .auth-logo {
  width: 120px; height: 120px; margin-bottom: 28px;
  border-radius: 28px; background: #ffffff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
}
.auth-brand .auth-logo img { width: 80px; height: 80px; object-fit: contain; }

.auth-welcome { font-size: 32px; font-weight: 700; letter-spacing: -.3px; margin-bottom: 10px; }
.auth-product { font-size: 20px; opacity: .85; letter-spacing: .2px; font-weight: 500; }
.hidden-mobile { display: none; }

@media (max-width: 820px) {
  .auth-screen { flex-direction: column; }
  .auth-right { display: none; }
  .auth-left {
    flex: none; height: 100%;
    border-right: none;
    padding: 36px 24px 20px;
    justify-content: flex-start;
  }
  .auth-heading { margin-top: 0; }
  .auth-product-mobile {
    display: block;
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
  }
  .auth-form { margin-top: 6px; }
  .auth-theme-toggle {
    position: static;
    transform: none;
    margin: 20px auto 0;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
  }
  .auth-theme-toggle:hover { background: var(--bg-hover); }
}

/* ===================================================================
   ОБОЛОЧКА ПРИЛОЖЕНИЯ
   =================================================================== */
.app { display: flex; height: 100%; position: relative; }

/* ===================================================================
   SIDEBAR
   =================================================================== */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: relative;
}

/* Шапка сайдбара */
.sidebar-head {
  height: var(--header-h); flex-shrink: 0;
  display: flex; align-items: center; gap: 6px;
  padding: 0 10px 0 14px;
  border-bottom: 1px solid var(--divider);
}

/* Поиск */
.search-box {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: var(--bg-secondary);
  border-radius: 20px;
  padding: 0 12px; height: 36px;
  transition: box-shadow var(--transition);
}
.search-box:focus-within {
  box-shadow: 0 0 0 2px var(--accent-light);
}
.search-box .search-ico { width: 17px; height: 17px; color: var(--text-secondary); flex-shrink: 0; }
.search-box input { flex: 1; font-size: 15px; background: transparent; }
.search-clear {
  display: none; font-size: 20px;
  color: var(--text-secondary); width: 22px; height: 22px; line-height: 1;
  transition: color var(--transition);
}
.search-clear:hover { color: var(--text); }
.search-box.has-text .search-clear { display: block; }

/* Список чатов */
.chat-list, .search-results { flex: 1; overflow-y: auto; overflow-x: hidden; }

.chat-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  cursor: pointer; position: relative;
  transition: background var(--transition);
  user-select: none;
}
.chat-item::after {
  content: '';
  position: absolute; left: 66px; right: 0; bottom: 0;
  height: 1px; background: var(--divider);
}
.chat-item:last-child::after { display: none; }
.chat-item:hover { background: var(--bg-hover); }
.chat-item.active {
  background: var(--bg-active);
}
.chat-item.active::after { display: none; }
.chat-item.active .ci-name,
.chat-item.active .ci-last,
.chat-item.active .ci-time,
.chat-item.active .ci-sender { color: var(--text-on-accent) !important; }
.chat-item.active .ci-badge { background: rgba(255,255,255,.25); color: #fff; }
.chat-item.active .ci-time { opacity: .85; }

.ci-body { flex: 1; min-width: 0; }
.ci-top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.ci-name {
  font-weight: 500; font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ci-time { font-size: 12px; color: var(--text-secondary); flex-shrink: 0; }
.ci-bottom {
  display: flex; justify-content: space-between; align-items: center;
  gap: 6px; margin-top: 2px;
}
.ci-last {
  font-size: 13.5px; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
}
.ci-sender { color: var(--text); }
.ci-badge {
  background: var(--accent); color: #fff;
  font-size: 12px; font-weight: 600;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.ci-type-ico { width: 14px; height: 14px; color: var(--text-secondary); margin-right: 3px; vertical-align: -2px; }

.ci-avatar-wrap { position: relative; }
.online-dot {
  position: absolute; right: 0; bottom: 0;
  width: 11px; height: 11px;
  background: #0ac630;
  border: 2px solid var(--bg-sidebar);
  border-radius: 50%;
}

/* FAB */
.fab {
  position: absolute; right: 18px; bottom: 20px;
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 18px rgba(51, 144, 236, .5);
  transition: transform var(--transition), background var(--transition), box-shadow var(--transition);
  z-index: 5;
}
.fab:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
  box-shadow: 0 6px 22px rgba(51, 144, 236, .55);
}
.fab:active { transform: scale(.93); }

/* Заголовки секций поиска */
.search-section-title {
  padding: 10px 16px 6px;
  font-size: 12.5px; font-weight: 600;
  color: var(--text-secondary); text-transform: uppercase;
  letter-spacing: .5px;
}

/* ===================================================================
   ОБЛАСТЬ ЧАТА
   =================================================================== */
.chat-area {
  flex: 1; display: flex; flex-direction: column;
  position: relative; background: var(--bg-chat); min-width: 0;
}

/* Паттерн фона */
.chat-area::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  opacity: var(--bg-pattern-op);
  background-image: url("data:image/svg+xml,%3Csvg width='120' height='120' viewBox='0 0 120 120' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23000000' fill-opacity='0.045'%3E%3Cpath d='M30 30c5-10 15-10 20 0s15 10 20 0M10 70c5-10 15-10 20 0s15 10 20 0M70 90c5-10 15-10 20 0'/%3E%3Ccircle cx='20' cy='20' r='2.5'/%3E%3Ccircle cx='90' cy='40' r='2.5'/%3E%3Ccircle cx='60' cy='100' r='2.5'/%3E%3C/g%3E%3C/svg%3E");
}

.chat-empty {
  flex: 1; display: flex; align-items: center;
  justify-content: center; position: relative; z-index: 1;
}
.chat-empty-bubble {
  background: rgba(0, 0, 0, .2); color: #fff;
  padding: 9px 20px; border-radius: 20px; font-size: 14px;
  backdrop-filter: blur(6px);
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
[data-theme="dark"] .chat-empty-bubble { background: rgba(0, 0, 0, .45); }

.chat-active {
  flex: 1; display: flex; flex-direction: column;
  position: relative; z-index: 1; min-height: 0;
}

/* Шапка чата */
.chat-head {
  height: var(--header-h); flex-shrink: 0;
  display: flex; align-items: center; gap: 6px;
  padding: 0 10px 0 14px;
  background: var(--bg-app);
  border-bottom: 1px solid var(--divider);
  z-index: 10;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.chat-back { display: none; }
.chat-head-info {
  flex: 1; display: flex; align-items: center; gap: 10px;
  cursor: pointer; min-width: 0; border-radius: 8px;
  padding: 4px 6px; margin: -4px -6px;
  transition: background var(--transition);
}
.chat-head-info:hover { background: var(--bg-hover); }
.chat-head-text { min-width: 0; }
.chat-head-name {
  font-weight: 600; font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-head-status { font-size: 13px; color: var(--text-secondary); margin-top: 1px; }
.chat-head-status.online { color: var(--accent); }

/* ----------------------------- СООБЩЕНИЯ -------------------------- */
.messages {
  flex: 1; overflow-y: auto;
  padding: 16px 8%;
  display: flex; flex-direction: column; gap: 2px;
}

.msg-day {
  align-self: center;
  background: rgba(0, 0, 0, .18); color: #fff;
  padding: 4px 14px; border-radius: 16px;
  font-size: 13px; margin: 12px 0;
  backdrop-filter: blur(6px);
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
  user-select: none;
}
[data-theme="dark"] .msg-day { background: rgba(0, 0, 0, .45); }

.msg {
  display: flex; max-width: 72%;
  animation: msgIn .22s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.msg.out { align-self: flex-end; flex-direction: row-reverse; }
.msg.in  { align-self: flex-start; }

.msg-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  flex-shrink: 0; margin-right: 7px; align-self: flex-end;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
  background-size: cover;
}
.msg.out .msg-avatar { display: none; }
.msg.grouped .msg-avatar { visibility: hidden; }

/* Пузырь */
.bubble {
  position: relative;
  padding: 7px 10px 8px;
  border-radius: 14px;
  background: var(--bubble-in);
  box-shadow: var(--shadow);
  word-wrap: break-word; overflow-wrap: break-word;
  min-width: 52px;
  transition: box-shadow var(--transition);
}
.bubble:hover { box-shadow: var(--shadow-md); }

.msg.out .bubble {
  background: var(--bubble-out);
  border-bottom-right-radius: 4px;
}
.msg.in .bubble { border-bottom-left-radius: 4px; }

[data-theme="dark"] .msg.out .bubble { color: #fff; }
[data-theme="dark"] .msg.out .bubble .msg-text { color: #fff; }

.msg-sender {
  font-size: 13.5px; font-weight: 600;
  margin-bottom: 2px; color: var(--accent);
}
.msg-text {
  font-size: 15px; line-height: 1.4;
  white-space: pre-wrap; word-break: break-word;
}
.msg-text a { color: var(--link); text-decoration: none; }
.msg-text a:hover { text-decoration: underline; }
.msg-text.emoji-only { font-size: 46px; line-height: 1.15; }

.msg-meta {
  float: right; margin: 5px 0 -2px 10px;
  font-size: 11px; color: var(--text-meta);
  display: flex; align-items: center; gap: 3px;
  user-select: none; line-height: 1;
}
.msg.out .msg-meta { color: #6cab5a; }
[data-theme="dark"] .msg.out .msg-meta { color: #71b7f5; }
.msg-meta .tick { width: 15px; height: 15px; stroke: currentColor; }

/* Медиа */
.msg-image { max-width: 300px; border-radius: 12px; cursor: pointer; margin: -3px 0 2px; }
.msg-image img { width: 100%; border-radius: 12px; display: block; }
.msg-video { max-width: 300px; border-radius: 12px; margin: -3px 0 2px; }
.msg-video video { width: 100%; border-radius: 12px; display: block; }
.bubble.media-bubble { padding: 4px; }
.bubble.media-bubble .msg-text { padding: 3px 7px 4px; }
.bubble.media-bubble .msg-meta {
  position: absolute; right: 10px; bottom: 9px;
  background: rgba(0, 0, 0, .38); color: #fff !important;
  padding: 2px 7px; border-radius: 10px; margin: 0;
  backdrop-filter: blur(4px);
}

/* Файл */
.msg-file {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 2px; min-width: 200px;
}
.file-ico {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.file-ico svg { width: 20px; height: 20px; }
.file-info { min-width: 0; }
.file-name {
  font-size: 14px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px;
}
.file-size { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* Голосовое */
.msg-voice {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 2px; min-width: 200px;
}
.voice-play {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: background var(--transition), transform .1s;
}
.voice-play:hover { background: var(--accent-hover); }
.voice-play:active { transform: scale(.92); }
.voice-play svg { width: 20px; height: 20px; fill: #fff; stroke: none; }
.voice-wave { flex: 1; height: 22px; display: flex; align-items: center; gap: 2px; }
.voice-wave span { flex: 1; background: var(--text-secondary); border-radius: 2px; opacity: .35; }
.msg.out .voice-wave span { background: #6cab5a; }
.voice-dur { font-size: 12px; color: var(--text-secondary); min-width: 32px; }

/* Ответ в пузыре */
.msg-reply {
  border-left: 3px solid var(--accent);
  padding: 3px 8px; margin-bottom: 5px;
  background: var(--accent-light);
  border-radius: 5px; cursor: pointer;
}
.msg-reply-name { font-size: 12.5px; font-weight: 600; color: var(--accent); }
.msg-reply-text {
  font-size: 13px; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px;
}

/* Контекстное меню */
.msg-context {
  position: fixed; z-index: 300;
  background: var(--bg-app);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .22);
  padding: 6px 0; min-width: 168px;
  animation: ctxIn .15s ease;
  border: 1px solid var(--border);
}
@keyframes ctxIn {
  from { opacity: 0; transform: scale(.96); }
  to   { opacity: 1; transform: scale(1); }
}
.msg-context div {
  padding: 10px 16px; font-size: 14px;
  display: flex; align-items: center; gap: 12px;
  transition: background var(--transition);
}
.msg-context div:hover { background: var(--bg-hover); }
.msg-context div svg { width: 17px; height: 17px; }
.msg-context .danger { color: #e53935; }

/* Индикатор печати */
.typing-bar {
  padding: 3px 8% 6px;
  font-size: 13px; color: var(--accent);
  background: var(--bg-chat); position: relative; z-index: 2;
}

/* Панель ответа */
.reply-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  background: var(--bg-app);
  border-top: 1px solid var(--divider);
  animation: replySlide .18s ease;
}
@keyframes replySlide {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.reply-bar-line {
  width: 3px; height: 34px;
  background: var(--accent); border-radius: 2px;
}
.reply-bar-content { flex: 1; min-width: 0; }
.reply-bar-name { font-size: 13px; font-weight: 600; color: var(--accent); }
.reply-bar-text {
  font-size: 13px; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ===================================================================
   КОМПОЗЕР
   =================================================================== */
.composer {
  flex-shrink: 0;
  display: flex; align-items: flex-end; gap: 4px;
  padding: 8px 10px;
  background: var(--bg-composer);
  border-top: 1px solid var(--divider);
  position: relative; z-index: 10;
}

/* Обёртка поля ввода */
.composer-input-wrap {
  flex: 1;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: 22px;
  padding: 0 14px;
  display: flex; align-items: flex-end;
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 44px;
}
.composer-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

#msg-input {
  flex: 1;
  resize: none; font-size: 15px; line-height: 1.45;
  padding: 10px 0; max-height: 140px; background: transparent;
}
#msg-input::placeholder { color: var(--text-secondary); }

.send-btn { color: var(--accent); }
.send-btn .ic-send { display: none; }
.send-btn .ic-mic  { display: block; }
.send-btn.has-text .ic-send { display: block; }
.send-btn.has-text .ic-mic  { display: none; }
.send-btn:hover { background: var(--bg-hover); }

/* Запись голоса */
.voice-bar {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px;
  background: var(--bg-composer);
  border-top: 1px solid var(--divider);
  position: relative; z-index: 10;
}
.voice-rec-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: #e53935; animation: blink 1s infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: .2; }
}
.voice-timer { font-size: 16px; font-variant-numeric: tabular-nums; min-width: 48px; }
.voice-hint  { flex: 1; color: var(--text-secondary); font-size: 14px; }
.voice-send   { color: var(--accent); }
.voice-cancel { color: #e53935; }

/* ===================================================================
   ПАНЕЛЬ ЭМОДЗИ
   =================================================================== */
.emoji-panel {
  position: absolute; bottom: 62px; left: 10px;
  width: 336px; max-width: calc(100% - 20px);
  height: 316px;
  background: var(--bg-app);
  border-radius: 16px;
  box-shadow: 0 8px 36px rgba(0, 0, 0, .22);
  border: 1px solid var(--border);
  z-index: 50;
  display: flex; flex-direction: column; overflow: hidden;
  animation: emojiUp .2s ease;
}
@keyframes emojiUp {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to   { opacity: 1; transform: translateY(0)  scale(1); }
}
.emoji-tabs {
  display: flex; border-bottom: 1px solid var(--divider);
  padding: 4px 6px; gap: 2px;
}
.emoji-tab {
  flex: 1; padding: 7px 0; text-align: center;
  font-size: 20px; border-radius: 9px; opacity: .55;
  transition: background var(--transition), opacity var(--transition);
}
.emoji-tab.active { background: var(--bg-secondary); opacity: 1; }
.emoji-tab:hover  { opacity: .85; }
.emoji-grid {
  flex: 1; overflow-y: auto; padding: 8px;
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
}
.emoji-grid span {
  font-size: 25px; text-align: center; padding: 4px;
  border-radius: 8px; cursor: pointer;
  transition: background var(--transition), transform .1s;
}
.emoji-grid span:hover { background: var(--bg-hover); transform: scale(1.15); }

/* ===================================================================
   ПРАВАЯ ПАНЕЛЬ ИНФО
   =================================================================== */
.info-panel {
  width: 340px; flex-shrink: 0;
  background: var(--bg-app);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.info-head {
  height: var(--header-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 14px;
  border-bottom: 1px solid var(--divider);
  font-weight: 600; font-size: 15px;
}
.info-body { flex: 1; overflow-y: auto; }
.info-cover {
  display: flex; flex-direction: column;
  align-items: center;
  padding: 28px 24px 20px; gap: 10px;
  border-bottom: 8px solid var(--bg-secondary);
}
.info-cover .avatar { width: 92px; height: 92px; font-size: 36px; }
.info-cover-name { font-size: 19px; font-weight: 600; text-align: center; letter-spacing: -.2px; }
.info-cover-sub  { font-size: 14px; color: var(--text-secondary); }

.info-row { display: flex; gap: 14px; padding: 14px 18px; align-items: flex-start; }
.info-row svg { width: 20px; height: 20px; color: var(--text-secondary); flex-shrink: 0; margin-top: 2px; }
.info-row .ir-label { font-size: 12.5px; color: var(--text-secondary); margin-bottom: 2px; }
.info-row .ir-value { font-size: 15px; }

.info-section-title {
  padding: 14px 18px 6px;
  font-size: 13px; color: var(--accent); font-weight: 600;
  text-transform: uppercase; letter-spacing: .4px;
}
.info-member {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 18px; cursor: pointer;
  transition: background var(--transition);
}
.info-member:hover { background: var(--bg-hover); }
.info-member .im-name { font-size: 15px; }
.info-member .im-role { font-size: 12px; color: var(--accent); margin-left: auto; }
.info-action {
  padding: 14px 18px;
  display: flex; align-items: center; gap: 14px;
  cursor: pointer; transition: background var(--transition);
}
.info-action:hover { background: var(--bg-hover); }
.info-action.danger { color: #e53935; }

/* Панель ответа */
.reply-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--divider);
}
.reply-bar.hidden { display: none; }
.reply-bar-inner {
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0;
}
.reply-bar-name {
  font-size: 13px; font-weight: 600; color: var(--accent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px;
}
.reply-bar-text {
  font-size: 13px; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0;
}
.info-action {
  padding: 14px 18px;
  display: flex; align-items: center; gap: 14px;
  cursor: pointer; transition: background var(--transition);
}
.info-action:hover { background: var(--bg-hover); }
.info-action.danger { color: #e53935; }

/* ===================================================================
   ШТОРКА МЕНЮ (DRAWER)
   =================================================================== */
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .45); z-index: 200;
  animation: fade .2s;
}
@keyframes fade {
  from { opacity: 0; } to { opacity: 1; }
}
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: 290px; max-width: 85%;
  background: var(--bg-app); z-index: 201;
  display: flex; flex-direction: column;
  box-shadow: 4px 0 32px rgba(0, 0, 0, .25);
  animation: slideIn .25s cubic-bezier(.2, .8, .2, 1);
}
@keyframes slideIn {
  from { transform: translateX(-100%); }
  to   { transform: translateX(0); }
}

.drawer-profile {
  padding: 24px 20px 20px;
  background: linear-gradient(150deg, var(--accent) 0%, var(--accent-hover) 100%);
  color: #fff; cursor: pointer;
}
.drawer-profile .avatar {
  margin-bottom: 14px;
  border: 2.5px solid rgba(255, 255, 255, .4);
  box-shadow: 0 4px 14px rgba(0,0,0,.2);
}
.drawer-name { font-size: 17px; font-weight: 600; }
.drawer-username { font-size: 14px; opacity: .8; margin-top: 2px; }

.drawer-menu {
  list-style: none; padding: 6px 0; flex: 1; overflow-y: auto;
  display: flex; flex-direction: column;
}
.drawer-menu li {
  display: flex; align-items: center; gap: 18px;
  padding: 12px 20px; font-size: 14.5px; cursor: pointer;
  transition: background var(--transition);
  border-radius: 0; min-height: 44px;
}
.drawer-menu li:hover { background: var(--bg-hover); }
.drawer-menu li svg { width: 21px; height: 21px; color: var(--text-secondary); flex-shrink: 0; }
.drawer-menu li.danger { color: #e53935; }
.drawer-menu li.danger svg { color: #e53935; }

.drawer-menu--bottom {
  margin-top: auto; flex-shrink: 0; padding-top: 8px;
  border-top: 1px solid var(--divider);
  overflow-y: visible;
}
.drawer-footer {
  padding: 14px 20px;
  font-size: 12px; color: var(--text-secondary);
  border-top: 1px solid var(--divider);
}

@media (max-width: 768px) {
  .drawer {
    top: auto; left: 0; right: 0; bottom: 0;
    width: 100%; max-width: 100%;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, .28);
    transform: translateY(100%);
    transition: transform .28s cubic-bezier(.2, .8, .2, 1);
  }
  .drawer.hidden {
    transform: translateY(100%);
    transition: transform .22s ease-in;
  }
  .drawer:not(.hidden) { transform: translateY(0); }
  .drawer-overlay { opacity: 1; transition: opacity .22s; }
  .drawer-overlay.hidden { opacity: 0; pointer-events: none; }

  .drawer-profile { padding: 20px 20px 14px; }
  .drawer-name { font-size: 15px; }
  .drawer-username { font-size: 13px; }
  .drawer-menu { padding: 4px 0; }
  .drawer-menu li { padding: 11px 18px; font-size: 14px; }
  .drawer-footer { padding: 10px 20px; font-size: 11px; }
  .menu-new-group, .menu-new-channel { display: none; }
}
﻿/* ===================================================================
   МОДАЛКИ
   =================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-overlay.hidden {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}
.modal {
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-app);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .4);
}
.modal-head {
  padding: 18px 22px 14px;
  font-size: 18px; font-weight: 600;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--divider);
}
.modal-head .icon-btn { margin-left: auto; }
.modal-body { padding: 16px 22px 8px; }
.modal-footer {
  padding: 14px 22px 20px;
  display: flex; gap: 10px; justify-content: flex-end;
  border-top: 1px solid var(--divider);
}

.modal-field { margin-bottom: 16px; }
.modal-field label {
  display: block; font-size: 13px;
  color: var(--text-secondary); margin-bottom: 6px; font-weight: 500;
}
.modal-field input,
.modal-field textarea,
.modal-field select {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--bg-input);
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.modal-field input:focus,
.modal-field textarea:focus,
.modal-field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* ===================================================================
   MARKET — СТИЛИ ДЛЯ ДОСКИ ОБЪЯВЛЕНИЙ
   =================================================================== */
.market-screen {
  position: fixed; inset: 0;
  background: var(--bg-app);
  z-index: 200;
  display: flex;
  flex-direction: column;
}
.market-screen.hidden { display: none; }
.market-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--divider);
  background: var(--bg-app);
}
.market-header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}
.market-back-btn {
  flex-shrink: 0;
}

/* Авторизация market */
.market-auth {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.market-logo { font-size: 64px; margin-bottom: 16px; }
.market-title { font-size: 28px; font-weight: 700; margin-bottom: 8px; }
.market-subtitle { font-size: 14px; color: var(--text-secondary); margin-bottom: 32px; }
.market-form { width: 100%; max-width: 360px; }
.market-form input {
  width: 100%; padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--bg-input);
  font-size: 15px;
  margin-bottom: 14px;
  transition: border-color var(--transition);
}
.market-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.market-btn {
  width: 100%; padding: 14px;
  border-radius: 12px;
  font-size: 15px; font-weight: 600;
  transition: background var(--transition), transform .1s;
}
.market-btn-primary {
  background: var(--accent); color: #fff;
  box-shadow: 0 4px 14px rgba(51, 144, 236, .35);
}
.market-btn-primary:hover { background: var(--accent-hover); }
.market-btn-primary:active { transform: scale(.98); }
.market-btn-danger {
  background: transparent; color: var(--danger);
  border: 1.5px solid var(--danger);
}
.market-btn-danger:hover { background: var(--danger); color: #fff; }
.market-toggle {
  margin-top: 16px; font-size: 13px; color: var(--text-secondary);
  text-align: center; cursor: pointer;
}
.market-toggle:hover { color: var(--accent); }

/* Market header */
.market-header {
  position: sticky; top: 0;
  background: var(--bg-app);
  border-bottom: 1px solid var(--divider);
  padding: 12px 16px;
  display: flex; justify-content: space-between; align-items: center;
  z-index: 10;
}
.market-header-title { font-weight: 700; font-size: 18px; }
.market-header-user { font-size: 13px; color: var(--text-secondary); }

/* Market content */
.market-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}
.market-items-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
@media (min-width: 768px) {
  .market-items-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1024px) {
  .market-items-grid { grid-template-columns: repeat(4, 1fr); }
}
.market-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
@media (min-width: 768px) {
  .market-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1024px) {
  .market-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Market card */
.market-card {
  background: var(--bg-secondary);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform .2s, box-shadow .2s;
}
.market-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .15);
}
.market-card:active { transform: scale(.98); }
.market-card-img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  background: var(--bg-input);
}
.market-card-body { padding: 10px; }
.market-card-price { font-weight: 700; font-size: 16px; color: var(--success); margin-bottom: 6px; }
.market-card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.market-card-title { font-size: 13px; font-weight: 500; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.market-item-loc { font-size: 11px; color: var(--text-secondary); margin: 4px 0; }
.market-card-seller { font-size: 11px; color: var(--text-secondary); margin-top: 4px; }

/* Tags */
.market-tag {
  font-size: 9px; font-weight: 600; padding: 3px 5px; border-radius: 4px;
}
.market-tag-warn { background: var(--warning); color: #000; }
.market-tag-info { background: #9b59b6; color: #fff; }
.market-tag-accent { background: var(--accent); color: #fff; }

/* FAB */
.market-fab {
  position: fixed;
  bottom: 80px; right: 20px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--accent); color: #fff;
  font-size: 32px; font-weight: 400;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 18px rgba(51, 144, 236, .5);
  border: none;
  z-index: 999;
  transition: transform .2s, background .2s;
  line-height: 1;
  padding: 0;
}
.market-fab:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}
.market-fab:active { transform: scale(.93); }

/* Modal detail */
.market-modal {
  position: fixed; inset: 0;
  z-index: 10000;
  display: none;
}
.market-modal-show { display: block; }
.market-modal-overlay {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, .6);
  backdrop-filter: blur(2px);
}
.market-modal-content {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 90%; max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-app);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .4);
}
.market-close {
  position: absolute; top: 12px; right: 12px;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .2); color: #fff;
  font-size: 24px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  z-index: 10;
}
.market-detail-img {
  width: 100%;
  height: 250px;
  object-fit: cover;
  border-radius: 12px;
  background: var(--bg-input);
}
.market-detail-header { position: relative; }
.market-detail-body { padding: 16px; }
.market-detail-price { font-size: 28px; font-weight: 700; color: var(--success); margin-bottom: 8px; }
.market-detail-title { font-size: 20px; font-weight: 600; margin-bottom: 12px; }
.market-detail-meta { display: flex; gap: 12px; margin-bottom: 16px; font-size: 13px; color: var(--text-secondary); }
.market-detail-desc {
  background: var(--bg-secondary);
  border-radius: 12px; padding: 14px;
  font-size: 14px; line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 16px;
  white-space: pre-wrap;
}
.market-seller-info {
  background: var(--bg-secondary);
  border-radius: 12px; padding: 12px;
  font-size: 13px; color: var(--text-secondary);
}

/* Empty state */
.market-empty {
  grid-column: 1 / -1;
  text-align: center; padding: 60px 24px;
  color: var(--text-secondary);
}
.market-empty-icon { font-size: 48px; margin-bottom: 16px; opacity: .5; }
.market-empty-hint { font-size: 13px; margin-top: 8px; }

/* Loading */
.market-loading {
  grid-column: 1 / -1;
  text-align: center; padding: 40px;
  color: var(--text-secondary);
}

/* Buttons */
.market-btn {
  width: 100%; padding: 12px;
  border-radius: 10px;
  font-size: 14px; font-weight: 600;
  margin-top: 12px;
  transition: background .2s, transform .1s;
}
.market-btn:active { transform: scale(.98); }

/* Form fields */
.market-field { margin-bottom: 16px; }
.market-field label {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); margin-bottom: 6px;
}
.market-field input,
.market-field textarea,
.market-field select {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--bg-input);
  font-size: 14px;
  transition: border-color .2s, box-shadow .2s;
}
.market-field input:focus,
.market-field textarea:focus,
.market-field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
  outline: none;
}
.market-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%237d8e9b' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 40px;
}
.market-checks {
  display: flex; flex-direction: column; gap: 10px;
  margin-bottom: 16px;
}
.market-check {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; color: var(--text);
  cursor: pointer;
}
.market-check input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}
.modal-field textarea,
.modal-field select {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--border); border-radius: 10px;
  background: var(--bg-input); font-size: 15px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.modal-field textarea { resize: vertical; min-height: 70px; }
.modal-field input:focus,
.modal-field textarea:focus,
.modal-field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.btn-ghost {
  padding: 10px 18px; border-radius: 9px;
  color: var(--accent); font-weight: 500;
  font-size: 14px; letter-spacing: .3px;
  transition: background var(--transition);
}
.btn-ghost:hover { background: var(--accent-light); }
.btn-solid {
  padding: 10px 22px; border-radius: 9px;
  background: var(--accent); color: #fff;
  font-weight: 500; font-size: 14px; letter-spacing: .3px;
  transition: background var(--transition), box-shadow var(--transition);
  box-shadow: 0 3px 10px rgba(51,144,236,.3);
}
.btn-solid:hover { background: var(--accent-hover); box-shadow: 0 4px 14px rgba(51,144,236,.4); }
.btn-danger { color: #e53935; }

/* Настройки */
.settings-group {
  border-bottom: 8px solid var(--bg-secondary); padding: 6px 0;
}
.settings-group:last-child { border-bottom: none; }
.settings-item {
  display: flex; align-items: center; gap: 16px;
  padding: 13px 22px; cursor: pointer;
  transition: background var(--transition);
}
.settings-item:hover { background: var(--bg-hover); }
.settings-item svg { width: 21px; height: 21px; color: var(--text-secondary); }
.settings-item .si-text { flex: 1; }
.settings-item .si-title { font-size: 15px; }
.settings-item .si-sub  { font-size: 13px; color: var(--text-secondary); margin-top: 1px; }

/* Переключатель */
.switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { display: none; }
.switch .track {
  position: absolute; inset: 0;
  background: #b0b6ba; border-radius: 12px;
  transition: background .22s;
}
.switch .thumb {
  position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px;
  background: #fff; border-radius: 50%;
  transition: transform .22s cubic-bezier(.4, 0, .2, 1);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track + .thumb { transform: translateX(18px); }

/* Выбор аватарки */
.avatar-picker {
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; margin-bottom: 20px;
}
.avatar-picker .avatar {
  width: 88px; height: 88px; font-size: 33px;
  cursor: pointer; position: relative;
  transition: transform var(--transition);
}
.avatar-picker .avatar:hover { transform: scale(1.04); }
.avatar-picker .avatar::after {
  content: ""; position: absolute; inset: 0;
  background: rgba(0,0,0,.32) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' fill='none' stroke='white' stroke-width='2'%3E%3Cpath d='M23 19a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h3l2-3h4l2 3h3a2 2 0 0 1 2 2z'/%3E%3Ccircle cx='14' cy='13' r='4'/%3E%3C/svg%3E") center no-repeat;
  opacity: 0; transition: opacity var(--transition);
  border-radius: 50%;
}
.avatar-picker .avatar:hover::after { opacity: 1; }

/* Выбор участников */
.member-select { max-height: 240px; overflow-y: auto; margin: -4px -8px 12px; }
.member-pick {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 14px; cursor: pointer; border-radius: 10px;
  transition: background var(--transition);
}
.member-pick:hover { background: var(--bg-hover); }
.member-pick .mp-check {
  width: 22px; height: 22px;
  border: 2px solid var(--border); border-radius: 50%;
  margin-left: auto; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), border-color var(--transition);
}
.member-pick.selected .mp-check { background: var(--accent); border-color: var(--accent); }
.member-pick.selected .mp-check::after { content: "✓"; color: #fff; font-size: 13px; }

/* Сегмент-переключатель */
.seg {
  display: flex; background: var(--bg-secondary);
  border-radius: 11px; padding: 3px; margin-bottom: 16px;
}
.seg button {
  flex: 1; padding: 9px 0; border-radius: 9px;
  font-size: 14px; font-weight: 500; color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
}
.seg button.active { background: var(--accent); color: #fff; }

/* Выбор акцентного цвета */
.accent-list { display: flex; gap: 10px; padding: 8px 0; flex-wrap: wrap; }
.accent-dot {
  width: 32px; height: 32px; border-radius: 50%;
  cursor: pointer; border: 3px solid transparent;
  transition: transform .15s, box-shadow .15s;
}
.accent-dot:hover { transform: scale(1.12); box-shadow: 0 3px 10px rgba(0,0,0,.2); }
.accent-dot.active {
  border-color: var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

/* ===================================================================
   ЛАЙТБОКС
   =================================================================== */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .92); z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 30px; animation: fade .2s;
}
.lightbox img {
  max-width: 100%; max-height: 100%;
  border-radius: 8px;
  box-shadow: 0 8px 48px rgba(0,0,0,.6);
}
.lightbox-close {
  position: absolute; top: 18px; right: 24px;
  color: rgba(255,255,255,.85); font-size: 38px; line-height: 1;
  transition: color var(--transition), transform var(--transition);
}
.lightbox-close:hover { color: #fff; transform: scale(1.1); }

/* ===================================================================
   ТОСТЫ
   =================================================================== */
.toast-wrap {
  position: fixed; bottom: 26px; left: 50%;
  transform: translateX(-50%); z-index: 600;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: rgba(32, 32, 32, .92); color: #fff;
  padding: 11px 22px; border-radius: 22px;
  font-size: 14px; font-weight: 500;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
  backdrop-filter: blur(8px);
  animation: toastIn .3s cubic-bezier(.18, .89, .32, 1.1);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(16px) scale(.95); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

/* ===================================================================
   МОБИЛЬНОЕ НИЖНЕЕ ТАБ-МЕНЮ (Telegram-style)
   =================================================================== */
.mobile-tabs {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 56px;
  background: var(--bg-app);
  border-top: 1px solid var(--divider);
  z-index: 150;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.mobile-tabs-inner {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: 100%;
}
.mobile-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-meta);
  font-size: 11px;
  font-weight: 500;
  transition: color var(--transition);
  padding: 4px 0;
  background: transparent;
  border: none;
}
.mobile-tab svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.6;
}
.mobile-tab.active {
  color: var(--accent);
}

/* Экраны для мобильных табов */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
  z-index: 90;
}
.screen-header {
  padding: 16px 20px;
  font-size: 24px;
  font-weight: 600;
  border-bottom: 1px solid var(--divider);
  background: var(--bg-app);
}
.screen-header h1 {
  margin: 0;
}
.screen-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}
.search-bar {
  margin-bottom: 16px;
}
.search-bar input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--bg-input);
  font-size: 15px;
}

@media (max-width: 768px) {
  #btn-menu { display: none; }
  #btn-new-chat { display: none; }
  .mobile-tabs { 
    display: flex;
    justify-content: space-around;
  }
  .app { padding-bottom: 56px; }
  .emoji-panel { bottom: 66px; }
  .settings-group { padding: 0; border-bottom: none; }
  .settings-item { padding: 12px 16px; }
  .modal-body { padding: 12px 16px; }
}
/* Когда чат открыт на мобильном устройстве */
/* ===================================================================
   ЖЕСТКИЙ ФИКС ДЛЯ МОБИЛЬНОГО КОМПОЗЕРА И ТАБОВ
   =================================================================== */
@media (max-width: 820px) {
  /* 1. Когда чат открыт, полностью убираем панель вкладок со страницы */
  .app.chat-open .mobile-tabs {
    display: none !important;
  }

  /* 2. Сбрасываем лишние отступы у контейнера приложения */
  .app.chat-open {
    padding-bottom: 0 !important;
  }

  /* 3. Гарантируем, что активный чат занимает абсолютно весь экран смартфона */
  .app.chat-open .chat-area,
  .app.chat-open #chat-active {
    height: 100vh !important;
    max-height: 100vh !important;
    display: flex !important;
    flex-direction: column !important;
    position: fixed !important;
    inset: 0 !important;
    z-index: 9999 !important;
    transform: translateX(0) !important; /* Убираем сдвиг */
  }

  /* 4. Принудительно прижимаем поле ввода к нижнему краю экрана */
  .app.chat-open #composer {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    z-index: 10000 !important;
    background: var(--bg-composer) !important;
    border-top: 1px solid var(--border) !important;
    
    /* Безопасная зона для iOS (полоска Home на iPhone) и Android */
    padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
  }

  /* 5. Добавляем отступ для списка сообщений, чтобы инпут не перекрывал последнее сообщение */
  .app.chat-open .messages {
    flex: 1 !important;
    overflow-y: auto !important;
    padding-bottom: 90px !important; /* Отступ под высоту фиксированного инпута */
  }

  /* 6. Перемещаем панель смайликов чуть выше инпута, чтобы она не перекрывала его */
  .app.chat-open .emoji-panel {
    bottom: calc(75px + env(safe-area-inset-bottom)) !important;
    z-index: 10001 !important;
  }
  /* Принудительно показываем инпут, когда открыта область чата на мобилке */
  .app.chat-open #composer {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
}


@media (max-width: 380px) {
  .auth-card { padding: 32px 22px 24px; }
  .messages { padding: 10px 6px; }
}

@media (max-width: 600px) {
  /* 1. Находим контейнер активного чата. Если он открыт (не имеет класса .hidden) */
  #chat-active:not(.hidden) {
    display: flex;
    flex-direction: column;
    height: 100vh;
    /* Убедимся, что чат занимает всё доступное пространство выше инпута */
    padding-bottom: 70px; 
  }

  /* 2. Скрываем нижнее меню навигации, когда чат активен */
  .app:has(#chat-active:not(.hidden)) #mobile-tabs,
  body:has(#chat-active:not(.hidden)) #mobile-tabs,
  #chat-area:has(#chat-active:not(.hidden)) ~ #mobile-tabs {
    display: none !important;
  }

  /* 3. Фиксируем блок ввода сообщения в самом низу экрана */
  #composer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 999;
    background: #1e1e24; /* Или переменная вашего фона, например var(--bg-color) */
    padding: 10px;
    padding-bottom: max(10px, env(safe-area-inset-bottom)); /* Для мобильных рамок и челок */
  }
}