:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-tertiary: #e9ecef;
  --text-primary: #212529;
  --text-secondary: #6c757d;
  --border-color: #dee2e6;
  --button-bg: #007bff;
  --button-hover: #0056b3;
  --message-sent: #f5c842;
  --message-received: #e8b830;
  --sidebar-bg: #f8f9fa;
  --input-bg: #ffffff;
  --shadow: rgba(0, 0, 0, 0.1);
  --auth-bg: rgba(255, 255, 255, 0.95);
  --accent-color: #0088cc;
  --hover-bg: #e9ecef;
  --active-bg: #cce7ff;
  --unread-bg: #ff4444;
  --logout-bg: #dc3545;
  --success-bg: #28a745;
  --disabled-bg: #ccc;
  --message-input-container-bg: #ffffff;
  --message-text: #1a1a1a;
}

[data-theme="dark"] {
  --bg-primary: #000000;
  --bg-secondary: #1a1a1a;
  --bg-tertiary: #2d2d2d;
  --text-primary: #ffffff;
  --text-secondary: #cccccc;
  --border-color: #404040;
  --button-bg: #007bff;
  --button-hover: #0056b3;
  --message-sent: #b8960f;
  --message-received: #9a7e0d;
  --sidebar-bg: #1a1a1a;
  --input-bg: #2d2d2d;
  --shadow: rgba(0, 0, 0, 0.3);
  --auth-bg: rgba(0, 0, 0, 0.95);
  --accent-color: #00aaff;
  --hover-bg: #404040;
  --active-bg: #004080;
  --unread-bg: #ff6666;
  --logout-bg: #cc3333;
  --success-bg: #33aa55;
  --disabled-bg: #666666;
  --message-input-container-bg: #1a1a1a;
  --message-text: #ffffff;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  transition: background-color 0.3s, color 0.3s;
}

#app {
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.hidden {
  display: none !important;
}

/* ===== АВТОРИЗАЦИЯ ===== */
.auth-container {
  background: var(--auth-bg);
  backdrop-filter: blur(10px);
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 10px var(--shadow);
  width: 300px;
  text-align: center;
  border: 1px solid var(--border-color);
  max-height: 80vh;
  overflow-y: auto;
}

.auth-container h2 {
  margin-bottom: 1rem;
  color: var(--text-primary);
  background: linear-gradient(135deg, #f7971e, #ffd200);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 2rem;
}

.auth-container form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-container input {
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 1rem;
  background: var(--input-bg);
  color: var(--text-primary);
}

.auth-container button {
  padding: 0.75rem;
  background-color: var(--button-bg);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.auth-container button:hover {
  background-color: var(--button-hover);
  transform: translateY(-2px);
}

.auth-container p {
  margin-top: 1rem;
  color: var(--text-secondary);
}

.auth-container a {
  color: var(--button-bg);
  text-decoration: none;
}

/* ===== ПРОФИЛЬ (МОДАЛЬНОЕ ОКНО) ===== */
#profile.auth-container {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 999;
  width: 90%;
  max-width: 450px;
  max-height: 90vh;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  overflow-y: auto;
}

.profile-header {
  display: flex;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.profile-header button {
  background: var(--button-bg);
  color: white;
  border: none;
  padding: 0.4rem 0.75rem;
  border-radius: 5px;
  cursor: pointer;
  margin-right: 0.75rem;
  transition: all 0.3s ease;
}

.profile-header button:hover {
  background: var(--button-hover);
}

.profile-header h2 {
  margin: 0;
}

.profile-pic-section {
  text-align: center;
  margin-bottom: 2rem;
}

.profile-pic-large {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  margin: 0 auto 1rem;
  overflow: hidden;
  border: 3px solid var(--border-color);
}

.profile-pic-large img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.change-pic-btn {
  background: var(--button-bg);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.change-pic-btn:hover {
  background: var(--button-hover);
  transform: translateY(-2px);
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-primary);
}

.form-group input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  background: var(--input-bg);
  color: var(--text-primary);
}

.form-group textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  background: var(--input-bg);
  color: var(--text-primary);
  resize: vertical;
  min-height: 80px;
}

.form-group small {
  display: block;
  margin-top: 0.3rem;
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.save-btn {
  background: var(--button-bg);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.3s ease;
  width: 100%;
}

.save-btn:hover {
  background: var(--button-hover);
  transform: translateY(-2px);
}

/* ===== ИНФОРМАЦИЯ О ПОЛЬЗОВАТЕЛЕ В ПРОФИЛЕ ===== */
.profile-user-info {
  text-align: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.profile-username-display {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-primary);
}

.profile-custom-username-display {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  font-style: italic;
}

.user-role {
  color: var(--text-secondary);
  font-weight: 500;
}

/* ===== ОСНОВНОЙ ЧАТ ===== */
#chat.chat-mobile {
  display: flex;
  width: 100%;
  height: 100vh;
  background: var(--bg-primary);
}

/* ===== ЛЕВАЯ КОЛОНКА (САЙДБАР) ===== */
.sidebar-panel {
  width: 100%;
  height: 100vh;
  background-color: var(--bg-secondary);
  display: flex;
  flex-direction: column;
}

.mobile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.mobile-header h1 {
  font-size: 1.2rem;
  margin: 0;
  font-weight: 700;
  color: var(--text-primary);
  background: linear-gradient(135deg, #f7971e, #ffd200);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hamburger-btn {
  background: none;
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
  color: var(--text-primary);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: background 0.2s;
}

.hamburger-btn:hover {
  background: var(--hover-bg);
}

.find-friends {
  padding: 0.8rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-primary);
}

#searchUser {
  width: 100%;
  padding: 0.65rem;
  border: 2px solid var(--border-color);
  border-radius: 25px;
  font-size: 0.9rem;
  background: var(--input-bg);
  color: var(--text-primary);
  transition: all 0.3s ease;
}

#searchUser:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 8px rgba(0, 136, 204, 0.2);
}

.search-results {
  margin-top: 0.75rem;
  max-height: 180px;
  overflow-y: auto;
  border-radius: 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
}

.search-result {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-primary);
  transition: all 0.2s ease;
  font-size: 0.9rem;
  gap: 0.5rem;
}

.search-result:hover {
  background-color: var(--hover-bg);
}

.search-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}

.search-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.add-friend-btn {
  background-color: var(--success-bg);
  color: white;
  border: none;
  padding: 0.25rem 0.5rem;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.7rem;
  transition: all 0.2s ease;
}

.add-friend-btn:hover {
  opacity: 0.8;
  transform: scale(1.05);
}

.friends-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.user-item {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.user-item:hover {
  background-color: var(--hover-bg);
}

.user-item.active {
  background-color: #fcd34d;
  color: #1f2937;
  font-weight: 600;
}

.user-item.active span {
  color: #1f2937 !important;
}

.user-avatar-small {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--border-color);
}

.user-item-right {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-width: 0;
}

.user-item-right span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unread-badge {
  background-color: var(--unread-bg);
  color: white;
  border-radius: 50%;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  font-weight: bold;
  min-width: 1.5rem;
  text-align: center;
}

.no-friends {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-secondary);
}

/* ===== ПРАВАЯ КОЛОНКА (ОБЛАСТЬ ЧАТА) ===== */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

.chat-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.chat-header h3 {
  margin: 0;
  color: var(--text-primary);
}

#chatWith span {
  transition: all 0.2s ease;
}

#chatWith span:hover {
  opacity: 0.7;
  text-decoration-color: var(--accent-color);
}

.call-btn {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: background 0.2s;
}

.call-btn:hover {
  background: var(--hover-bg);
}

/* ===== СООБЩЕНИЯ ===== */
.messages {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  background-color: var(--bg-secondary);
  padding-bottom: 0.5rem;
  min-height: 0;
}

.message {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.message.sent {
  align-items: flex-end;
}

.message.received {
  align-items: flex-start;
}

.message-bubble {
  max-width: 70%;
  padding: 0.75rem 1rem;
  border-radius: 18px;
  word-wrap: break-word;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}

.message.sent .message-bubble {
  background-color: var(--message-sent);
  color: var(--message-text);
}

.message.received .message-bubble {
  background-color: var(--message-received);
  color: var(--message-text);
}

.message-timestamp {
  font-size: 0.65rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
  opacity: 0.7;
}

.message.sent .message-timestamp {
  text-align: right;
  padding-right: 0.5rem;
}

.message.received .message-timestamp {
  text-align: left;
  padding-left: 0.5rem;
}

.message-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-size: cover;
  flex-shrink: 0;
  margin-bottom: 0.3rem;
}

.empty-chat-message {
  margin: auto;
  text-align: center;
  color: var(--text-secondary);
}

.empty-chat-message h3 {
  background: linear-gradient(135deg, #f7971e, #ffd200);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 2rem;
}

/* ПК версия сообщений */
@media (min-width: 769px) {
  .message {
    flex-direction: row;
    align-items: flex-start;
  }
  
  .message.sent {
    flex-direction: row-reverse;
  }
  
  .message.sent .message-avatar {
    margin-left: 0.5rem;
    margin-right: 0;
    margin-bottom: 0;
  }
  
  .message.received .message-avatar {
    margin-right: 0.5rem;
    margin-left: 0;
    margin-bottom: 0;
  }
  
  .message-timestamp {
    margin-top: 0.2rem;
  }
}

/* ===== ПОЛЕ ВВОДА ===== */
.message-input-container {
  display: none;
  padding: 0.8rem;
  background: var(--message-input-container-bg);
  border-top: 1px solid var(--border-color);
  transition: background-color 0.3s ease;
  flex-shrink: 0;
}

.message-input-container.active {
  display: flex;
  align-items: flex-end;
  gap: 0.8rem;
}

.message-input {
  flex: 1;
  display: flex;
  align-items: flex-end;
  padding: 0.4rem 0.6rem;
  border: 2px solid var(--border-color);
  border-radius: 20px;
  background: var(--bg-secondary);
  transition: all 0.3s ease;
  position: relative;
}

.message-input:focus-within {
  border-color: var(--accent-color);
}

#messageInput {
  flex: 1;
  padding: 0.5rem 0.8rem;
  border: none;
  font-size: 0.95rem;
  background: transparent;
  color: var(--text-primary);
  resize: none;
  max-height: 200px;
  min-height: 44px;
  font-family: inherit;
}

#messageInput:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#messageInput:focus {
  outline: none;
}

.input-icon-btn {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.4rem;
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.input-icon-btn:hover {
  color: var(--text-primary);
  transform: scale(1.1);
}

.send-button-modern {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.send-button-modern:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.send-button-image {
  width: 44px;
  height: 44px;
  object-fit: contain;
  transition: all 0.3s ease;
}

.send-button-modern:not(:disabled):hover .send-button-image {
  transform: scale(1.1);
}

/* ===== МЕНЮ-ВЫЕЗЖАЛКА (DRAWER) ===== */
.drawer {
  position: fixed;
  top: 0;
  left: -320px;
  width: 280px;
  height: 100vh;
  background: var(--bg-primary);
  z-index: 1000;
  box-shadow: 2px 0 20px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-right: 1px solid var(--border-color);
}

.drawer.open {
  left: 0;
}

.drawer::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  z-index: -1;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.drawer.open::before {
  opacity: 1;
  pointer-events: auto;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 1rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.drawer-header h2 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--text-primary);
  background: linear-gradient(135deg, #f7971e, #ffd200);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#closeDrawerBtn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-primary);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: background 0.2s;
}

#closeDrawerBtn:hover {
  background: var(--hover-bg);
}

.drawer-content {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
  background: var(--bg-primary);
}

.drawer-content button {
  background: none;
  border: none;
  padding: 0.8rem 1rem;
  text-align: left;
  font-size: 1rem;
  color: var(--text-primary);
  border-radius: 8px;
  cursor: pointer;
  width: 100%;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.drawer-content button:hover {
  background: var(--hover-bg);
  transform: translateX(4px);
}

.drawer-content button:active {
  transform: scale(0.98);
}

/* ===== КНОПКА ПРОКРУТКИ ===== */
.scroll-to-bottom {
  position: absolute;
  bottom: 110px;
  right: 30px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background-color: var(--accent-color);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 4px 12px rgba(0, 136, 204, 0.3);
  transition: all 0.3s ease;
  z-index: 100;
}

.scroll-to-bottom.hidden {
  display: none;
}

.scroll-to-bottom:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 136, 204, 0.4);
}

.new-messages-count {
  position: absolute;
  top: -5px;
  right: -5px;
  background-color: var(--unread-bg);
  color: white;
  border-radius: 50%;
  padding: 0.15rem 0.45rem;
  font-size: 0.7rem;
  font-weight: bold;
  min-width: 20px;
  text-align: center;
}

.back-btn-mobile {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-primary);
  display: none;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: background 0.2s;
}

.back-btn-mobile:hover {
  background: var(--hover-bg);
}

/* ===== ЗАГРУЗКА ФАЙЛОВ ===== */
.upload-status {
  padding: 0.5rem 1rem;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
}

.upload-progress {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.upload-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.upload-filename {
  max-width: 70%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-percent {
  font-weight: 500;
}

.upload-progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  background: var(--accent-color);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.upload-cancel {
  background: var(--logout-bg);
  color: white;
  border: none;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  margin-top: 0.3rem;
}

/* ===== ЭМОДЗИ ПИКЕР ===== */
.emoji-picker {
  position: absolute;
  bottom: 100%;
  left: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  max-width: 300px;
  box-shadow: 0 4px 12px var(--shadow);
  z-index: 50;
}

.emoji-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  transition: background 0.2s;
}

.emoji-btn:hover {
  background: var(--hover-bg);
}

.message-input {
  position: relative;
}

/* ===== ФАЙЛЫ В СООБЩЕНИЯХ ===== */
.file-message {
  max-width: 300px;
}

.file-preview img,
.file-preview video {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
}

.file-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}

.file-icon {
  font-size: 2rem;
}

.file-details {
  flex: 1;
}

.file-name {
  font-weight: 500;
  word-break: break-all;
}

.file-size {
  font-size: 0.75rem;
  opacity: 0.7;
}

/* ===== МОДАЛЬНЫЕ ОКНА ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--bg-primary);
  border-radius: 12px;
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
  padding: 1rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: background 0.2s;
}

.modal-close:hover {
  background: var(--hover-bg);
}

.modal-body {
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 70vh;
  overflow-y: auto;
  color: var(--text-primary);
}

/* ===== РОЛИ ===== */
.creator-role {
  color: #ff4444;
  font-weight: bold;
  text-shadow: 0 0 5px rgba(255, 68, 68, 0.5);
}

.admin-role {
  color: #ffaa00;
  font-weight: bold;
}

.user-role {
  color: var(--text-secondary);
  font-weight: 500;
}

/* ===== СКРОЛЛБАР ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ============================================
   ===== АДАПТИВНОСТЬ =====
   ============================================ */

/* ПК версия */
@media (min-width: 769px) {
  .sidebar-panel {
    width: 280px;
    min-width: 280px;
    border-right: 1px solid var(--border-color);
  }
  
  .back-btn-mobile {
    display: none !important;
  }
  
  .chat-area {
    display: flex !important;
  }
  
  .profile-username-display {
    font-size: 1.8rem;
  }
  
  .scroll-to-bottom {
    bottom: 110px;
  }
}

/* Мобильная версия */
@media (max-width: 768px) {
  .sidebar-panel {
    width: 100%;
  }
  
  .back-btn-mobile {
    display: block;
  }
  
  .chat-area {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    z-index: 10;
    display: none;
    background: var(--bg-primary);
    flex-direction: column;
  }
  
  .chat-area.open {
    display: flex !important;
  }
  
  .drawer {
    width: 280px;
    left: -100%;
  }
  
  .drawer.open {
    left: 0;
  }
  
  .auth-container {
    width: 95%;
    padding: 1.5rem;
  }
  
  #profile.auth-container {
    width: 95%;
    max-width: 400px;
  }
  
  .profile-username-display {
    font-size: 1.4rem;
  }
  
  /* ===== УЛУЧШЕНИЯ ДЛЯ ТЕЛЕФОНА ===== */
  
  /* Сообщения - с отступом снизу */
  .messages {
    flex: 1;
    padding: 1rem;
    padding-bottom: 0.75rem;
    overflow-y: auto;
    margin-bottom: 0;
    min-height: 0;
  }
  
  /* Поле ввода - фиксировано внизу */
  .message-input-container {
    position: sticky;
    bottom: 0;
    background: var(--message-input-container-bg);
    z-index: 5;
    padding: 0.6rem 0.8rem;
    padding-bottom: calc(0.6rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
  }
  
  /* Увеличиваем отступ для последнего сообщения */
  .message:last-child {
    margin-bottom: 0.5rem;
  }
  
  /* Сообщения с переносами */
  .message-bubble {
    white-space: pre-wrap !important;
    word-break: break-word !important;
    max-width: 85%;
  }
  
  /* Увеличиваем поле ввода для удобства */
  #messageInput {
    font-size: 16px !important;
    min-height: 48px;
    padding: 0.6rem 0.8rem;
  }
  
  /* Кнопка отправки больше */
  .send-button-modern {
    width: 48px;
    height: 48px;
  }
  
  .send-button-image {
    width: 48px;
    height: 48px;
  }
  
  /* Скрываем аватарки на телефоне */
  .message-avatar {
    display: none !important;
  }
  
  .message {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .message.sent {
    align-items: flex-end;
  }
  
  .message-bubble {
    max-width: 85%;
  }
  
  /* Кнопка прокрутки на телефоне выше */
  .scroll-to-bottom {
    bottom: 120px;
    right: 20px;
    width: 44px;
    height: 44px;
    font-size: 1.2rem;
  }
}
.send-button-modern {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    transform: rotate(40deg) translate(-12px, -8px);
}

.send-button-modern:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: rotate(40deg) translate(-12px, -8px);
}

.send-button-image {
    width: 44px;
    height: 44px;
    object-fit: contain;
    transition: all 0.3s ease;
}

.send-button-modern:not(:disabled):hover {
    transform: rotate(40deg) translate(-12px, -8px) scale(1.1);
}

.send-button-modern:not(:disabled):hover .send-button-image {
    transform: rotate(0deg);
}
/* ===== ЮРИДИЧЕСКИЕ ССЫЛКИ ===== */
.legal-links {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.legal-links a {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.legal-links a:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

.legal-links span {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* Для мобильных устройств */
@media (max-width: 480px) {
    .legal-links a {
        font-size: 0.65rem;
    }
}