/* ============================================
   OneMix Desktop — Main Stylesheet
   Light/Dark theme matching mobile app colors
   BUILD: v1.5.83 — web wallpapers reduced to doodles + gradients only
   ============================================ */

:root {
  /* Light theme */
  --primary: #0088CC;
  --background: #F4F4F4;
  --surface: #FFFFFF;
  --foreground: #000000;
  --muted: #8E8E93;
  --border: #E5E5EA;
  --success: #34C759;
  --warning: #FF9500;
  --error: #FF3B30;
  --message-out: #E6F5E9;
  --message-in: #FFFFFF;
  --message-in-alt: #F0F0F0;
  --message-out-text: #1F2F22;
  --message-in-text: #212121;
  --message-out-time: #5A8A62;
  --message-in-time: #8A8A8A;
  --message-in-accent: #3EB1FF;
  --online: #34C759;
  --hover: rgba(0, 0, 0, 0.04);
  --active: rgba(0, 0, 0, 0.08);
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --sidebar-width: 360px;
  --info-panel-width: 340px;
}

body.dark {
  --primary: #64B5F6;
  --background: #000000;
  --surface: #1C1C1E;
  --foreground: #FFFFFF;
  --muted: #8E8E93;
  --border: #38383A;
  --success: #30D158;
  --warning: #FFD60A;
  --error: #FF453A;
  --message-out: #5C35CC;
  --message-in: #2A2A3A;
  --message-in-alt: #3A3A44;
  --message-out-text: #FFFFFF;
  --message-in-text: #FFFFFF;
  --message-out-time: rgba(255,255,255,0.6);
  --message-in-time: #8E8E93;
  --online: #30D158;
  --hover: rgba(255, 255, 255, 0.06);
  --active: rgba(255, 255, 255, 0.1);
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.5);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--background);
  color: var(--foreground);
  overflow: hidden;
  height: 100vh;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(128,128,128,0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(128,128,128,0.5); }

/* ============ SCREENS ============ */
.screen { display: none; height: 100vh; }
.screen.active { display: flex; }

/* ============ AUTH SCREEN ============ */
.auth-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 40px;
  background: var(--background);
}

.auth-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 40px;
}

.auth-logo-icon {
  width: 80px;
  height: 80px;
  border-radius: 24px;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  margin-bottom: 16px;
}

/* Стикер на auth-screen вместо синей иконки (синхронизировано с мобильной) */
.auth-logo-sticker {
  width: 144px;
  height: 144px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
}
.auth-logo-sticker img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 6px 16px rgba(0,0,0,0.18));
  animation: stickerBob 4s ease-in-out infinite;
}
@keyframes stickerBob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}
@media (max-width: 480px) {
  .auth-logo-sticker { width: 120px; height: 120px; margin-bottom: 14px; }
}

.auth-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--foreground);
}

.auth-subtitle {
  font-size: 14px;
  color: var(--muted);
  margin-top: 4px;
}

.auth-step { display: none; width: 100%; max-width: 360px; }
.auth-step.active { display: flex; flex-direction: column; gap: 16px; }

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.auth-field input {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--foreground);
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.auth-field input:focus {
  border-color: var(--primary);
}

.btn-primary {
  padding: 12px 24px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  padding: 8px;
}

.btn-link:hover { text-decoration: underline; }

.auth-error {
  color: var(--error);
  font-size: 13px;
  text-align: center;
  padding: 8px;
  background: rgba(255, 59, 48, 0.1);
  border-radius: var(--radius-sm);
}

.auth-info {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.dev-code {
  color: var(--primary);
  font-size: 14px;
  text-align: center;
  padding: 8px;
  background: rgba(0, 136, 204, 0.1);
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.btn-loader {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

/* ============ APP LAYOUT ============ */
.app-layout {
  display: flex;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  position: relative;
  background: var(--background);
}

/* V8-float: глобальная фоновая подложка под всем layout — те же обои, что в
   чате. Сайдбар, хедер и pinned плавают поверх неё (Telegram-стиль). */
#app-bg-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.app-layout > .sidebar,
.app-layout > .chat-area,
.app-layout > .info-panel { z-index: 1; }

/* ============ SIDEBAR ============ */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  max-width: var(--sidebar-width);
  /* V8-float: плавающая овальная карточка; низ опущен до уровня поля ввода */
  height: calc(100vh - 28px);
  margin: 16px 8px 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
}
body.dark .sidebar { border-color: rgba(255,255,255,0.06); }

.sidebar-header {
  padding: 12px 12px 0;
  flex-shrink: 0;
}

.sidebar-header-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.search-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--background);
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s;
}
.search-box:hover { background: var(--hover); }
.search-box-placeholder {
  flex: 1;
  font-size: 14px;
  color: var(--muted);
  font-family: inherit;
  user-select: none;
}

/* ══════════════════════════ SEARCH OVERLAY ══════════════════════════════════ */
.search-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: var(--surface);
  z-index: 200;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}
.search-overlay.hidden { display: none; opacity: 0; pointer-events: none; }
.search-overlay.so-open { opacity: 1; transform: translateY(0); pointer-events: all; }

/* header row */
.so-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 8px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.so-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: var(--background);
  border-radius: 20px;
  color: var(--muted);
}
.so-input {
  flex: 1;
  border: none;
  background: none;
  color: var(--foreground);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  min-width: 0;
}
.so-input::placeholder { color: var(--muted); }
.so-clear {
  width: 18px; height: 18px;
  border: none; background: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
}
.so-clear:hover { color: var(--foreground); }
.so-cancel-btn {
  border: none; background: none;
  color: var(--primary);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  padding: 4px 0;
  white-space: nowrap;
  flex-shrink: 0;
}
.so-cancel-btn:hover { opacity: 0.8; }

/* body */
.so-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

/* section */
.so-section { padding-top: 4px; }
.so-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 6px;
}
.so-section-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.so-section-action {
  border: none; background: none;
  font-size: 13px;
  color: var(--primary);
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}
.so-section-action:hover { opacity: 0.8; }

/* frequent contacts horizontal scroll */
.so-frequent-list {
  display: flex;
  gap: 4px;
  padding: 6px 12px 14px;
  overflow-x: auto;
  scrollbar-width: none;
}
.so-frequent-list::-webkit-scrollbar { display: none; }
.so-freq-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 10px;
  min-width: 60px;
  transition: background 0.15s;
  flex-shrink: 0;
}
.so-freq-item:hover { background: var(--hover); }
.so-freq-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; color: #fff;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}
.so-freq-avatar img {
  width: 100%; height: 100%;
  object-fit: cover; border-radius: 50%;
}
.so-freq-badge {
  position: absolute;
  top: -1px; right: -1px;
  min-width: 18px; height: 18px;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--surface);
}
.so-freq-name {
  font-size: 11px;
  color: var(--foreground);
  text-align: center;
  max-width: 58px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* result rows (recent + search results) */
.so-result-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 16px;
  cursor: pointer;
  transition: background 0.12s;
}
.so-result-row:hover { background: var(--hover); }
.so-result-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: #fff;
  overflow: hidden;
  flex-shrink: 0;
}
.so-result-avatar img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
}
.so-result-info { flex: 1; min-width: 0; }
.so-result-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--foreground);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.so-result-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* tabs */
.so-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  padding: 0 8px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.so-tabs::-webkit-scrollbar { display: none; }
.so-tab {
  border: none; background: none;
  font-size: 13px; font-weight: 600;
  font-family: inherit;
  color: var(--muted);
  cursor: pointer;
  padding: 10px 14px;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.so-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.so-tab:hover:not(.active) { color: var(--foreground); }

/* spinner + empty */
.so-spinner { display: flex; justify-content: center; padding: 40px; }
.so-empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px; padding: 50px 20px;
  color: var(--muted); font-size: 14px;
}

/* Tabs */
.sidebar-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin: 0 4px 4px;
  overflow-x: auto;
  /* V8-float: овальный контейнер-сегмент под вкладки */
  background: var(--background);
  border-radius: 100px;
}
body.dark .sidebar-tabs { background: rgba(255,255,255,0.05); }

.sidebar-tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1 1 auto;
  padding: 7px 14px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  /* V8-float: овальные вкладки */
  border-radius: 100px;
  white-space: nowrap;
  transition: all 0.2s;
  position: relative;
}

.tab-btn:hover:not(.active) { color: var(--foreground); }
/* V8-float: активная вкладка — цветной плавающий овал */
.tab-btn.active {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 136, 204, 0.35);
}
body.dark .tab-btn.active { background: var(--primary); box-shadow: 0 2px 8px rgba(100, 181, 246, 0.3); }

.tab-badge {
  font-size: 11px;
  font-weight: 600;
  background: var(--primary);
  color: white;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.tab-badge:empty { display: none; }

/* Icon Button */
.icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  border-radius: 50%;
  transition: all 0.15s;
  flex-shrink: 0;
}

.icon-btn:hover { background: var(--hover); color: var(--foreground); }

/* Chat List */
.chat-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}

.chat-item:hover { background: var(--hover); }
.chat-item.active { background: var(--active); }

.chat-item-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  color: white;
  background: var(--primary);
  overflow: hidden;
  position: relative;
}

.chat-item-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 12px;
  height: 12px;
  background: var(--online);
  border: 2px solid var(--surface);
  border-radius: 50%;
}

.chat-item-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chat-item-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.chat-item-time {
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}

.chat-item-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chat-item-message {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.chat-item-message .sender-name {
  color: var(--primary);
  font-weight: 500;
}

.unread-badge {
  background: var(--primary);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.pin-icon {
  color: var(--muted);
  flex-shrink: 0;
  opacity: 0.5;
}

/* FAB */
.fab-btn {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  transition: transform 0.2s;
  z-index: 10;
}

.fab-btn:hover { transform: scale(1.05); }

/* ============ SIDEBAR MENU ============ */
.sidebar-menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.3);
  z-index: 100;
}

.sidebar-menu {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  height: 100vh;
  background: var(--surface);
  z-index: 101;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

.sidebar-menu-header {
  padding: 24px 20px;
  background: var(--primary);
  color: white;
}

.sidebar-menu-items {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}

.sidebar-menu-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  border: none;
  background: none;
  color: var(--foreground);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background 0.15s;
}

.sidebar-menu-item:hover { background: var(--hover); }
.sidebar-menu-item.danger { color: var(--error); }

.sidebar-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

/* ============ CHAT AREA ============ */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  /* V8-float: chat-area прозрачна — фон даёт #app-bg-layer под layout,
     а в открытом чате поверх ложится свой #chat-wallpaper-layer */
  background: transparent;
  position: relative;
  min-width: 0;
  /* Note: no isolation:isolate — wallpaper layer must show through */
}

/* When wallpaper is active — chat-area and messages-container are transparent */
.chat-area.has-wallpaper {
  background: transparent !important;
}
.chat-area.has-wallpaper .messages-container {
  background: transparent !important;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--muted);
  font-size: 15px;
}

/* Chat Header */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  /* V8-float: плавающий овальный хедер, по ширине как поле ввода (800px, центр) */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 800px;
  margin: 16px auto 0;
  flex-shrink: 0;
  z-index: 10;
}
body.dark .chat-header { border-color: rgba(255,255,255,0.06); }

.back-btn { display: none; }

.chat-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  color: white;
  background: var(--primary);
  overflow: hidden;
}

.chat-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

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

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

.chat-header-status {
  font-size: 12px;
  color: var(--muted);
}

.chat-header-status.online { color: var(--online); }

.chat-header-actions {
  display: flex;
  gap: 4px;
}

/* Messages Container */
.messages-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
  background: transparent;
  /* Отключаем плавный скролл — он вызывает прыжки при programmatic scroll */
  scroll-behavior: auto;
  /* Останавливаем цепочку скролла */
  overscroll-behavior: contain;
}

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: auto;
}

/* V155 BUILD-MARKER: floating composer + centered messages column */
/* Применяется при открытом чате (`.has-chat-open`) на любой ширине.
   На узких экранах max-width 800px не вступает в силу — list занимает всю
   доступную ширину как раньше. На широких — центрируется и обои просвечивают
   по бокам, как на скриншоте от пользователя. */
.chat-area.has-chat-open .messages-list {
  max-width: 800px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

/* Message Bubbles */
.message-row {
  display: flex;
  flex-direction: column;
  max-width: 65%;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-row.outgoing { align-self: flex-end; }
.message-row.incoming { align-self: flex-start; }

.message-bubble {
  padding: 8px 12px;
  border-radius: var(--radius);
  position: relative;
  word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 1.45;
}

.message-row.outgoing .message-bubble {
  background: var(--message-out);
  color: var(--message-out-text);
  border-bottom-right-radius: 4px;
}

.message-row.incoming .message-bubble {
  background: var(--message-in);
  color: var(--message-in-text);
  border-bottom-left-radius: 4px;
}

/* Light theme: clean bubbles without accent bar */
body:not(.dark) .message-row.incoming .message-bubble {
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

body:not(.dark) .message-row.outgoing .message-bubble {
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
}

/* Light theme: message time colors */
body:not(.dark) .message-row.outgoing .message-time { color: #5A8A62; }
body:not(.dark) .message-row.incoming .message-time { color: #8A8A8A; }

.message-sender {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 2px;
}

.message-text {
  font-size: 14px;
  white-space: pre-wrap;
  user-select: text;       /* Разрешаем выделение текста мышкой и Ctrl+C */
  -webkit-user-select: text;
  cursor: text;
}

.message-text a {
  color: var(--primary);
  text-decoration: underline;
}

/* ── Выделение текста в сообщениях (Ctrl+C, правая кнопка) ─────────────── */
/* Все текстовые контейнеры внутри пузырей — разрешаем выделение */
.message-bubble .message-text,
.message-bubble p,
.message-bubble span:not(.msg-time):not(.read-check),
.channel-message .message-text,
.bot-message-row .message-text {
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
}

/* Мета-данные (время, галочки) — не выделяем */
.message-meta,
.msg-time,
.read-check,
.message-meta * {
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
}



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

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

.message-row.outgoing .message-time { color: var(--message-out-time); }
.message-row.incoming .message-time { color: var(--message-in-time); }

.msg-checks {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  line-height: 1;
}
/* Default (incoming / dark theme) */
.msg-checks.sent { color: rgba(128,128,128,0.65); }
.msg-checks.read { color: var(--primary); }

/* Outgoing bubble — light theme: blue bubble, so use a slightly darker shade */
body.light .message-row.outgoing .msg-checks.sent { color: rgba(0, 100, 180, 0.55); }
body.light .message-row.outgoing .msg-checks.read { color: #0062b8; }

/* Outgoing bubble — dark theme: purple/dark bubble, white checks */
body.dark  .message-row.outgoing .msg-checks.sent { color: rgba(255,255,255,0.45); }
body.dark  .message-row.outgoing .msg-checks.read { color: rgba(255,255,255,0.9); }

/* Reply in message */
.message-reply {
  padding: 6px 10px;
  margin-bottom: 4px;
  border-left: 3px solid var(--primary);
  border-radius: 4px;
  background: rgba(0,0,0,0.08);
  cursor: pointer;
}

/* Внутри outgoing-пузыря (синий/зелёный bg) — лёгкое осветление */
.message-row.outgoing .message-reply { background: rgba(255,255,255,0.18); }
.message-row.outgoing .message-reply-name { color: #fff; }
.message-row.outgoing .message-reply-text { color: rgba(255,255,255,0.85); }

body.dark .message-reply { background: rgba(255,255,255,0.14); }
body.dark .message-row.outgoing .message-reply { background: rgba(0,0,0,0.25); }

.message-reply-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
}

.message-reply-text {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Forward */
.message-forward {
  font-size: 12px;
  color: var(--primary);
  font-style: italic;
  margin-bottom: 4px;
}

/* Attachment */
.message-attachment {
  margin-top: 4px;
  max-width: 320px;
}

.message-attachment img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: block;
}

.message-attachment video {
  max-width: 100%;
  border-radius: var(--radius-sm);
  max-height: 300px;
}

.message-attachment audio {
  width: 100%;
  max-width: 280px;
}

.message-attachment-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(0,0,0,0.05);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}

body.dark .message-attachment-file { background: rgba(255,255,255,0.08); }
.message-attachment-file:hover { background: rgba(0,0,0,0.1); }
body.dark .message-attachment-file:hover { background: rgba(255,255,255,0.12); }

.file-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { font-size: 11px; color: var(--muted); }

/* Reactions */
.message-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.reaction-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(0,0,0,0.06);
  font-size: 13px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}

body.dark .reaction-badge { background: rgba(255,255,255,0.1); }
.reaction-badge.mine { border-color: var(--primary); background: rgba(0, 136, 204, 0.15); }
.reaction-badge:hover { transform: scale(1.05); }

/* Sticker message */
.message-sticker {
  max-width: 150px;
}

.message-sticker img {
  width: 150px;
  height: 150px;
  object-fit: contain;
}

/* Date separator */
.date-separator {
  text-align: center;
  padding: 8px 0;
}

.date-separator span {
  font-size: 12px;
  color: var(--muted);
  background: var(--surface);
  padding: 4px 12px;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

/* System message */
.system-message {
  text-align: center;
  padding: 4px 0;
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
}

/* ============ REPLY BAR ============ */
.reply-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.reply-bar-content {
  flex: 1;
  display: flex;
  gap: 10px;
  min-width: 0;
}

.reply-bar-line {
  width: 3px;
  border-radius: 2px;
  background: var(--primary);
  flex-shrink: 0;
}

.reply-bar-info { flex: 1; min-width: 0; }
.reply-bar-name { font-size: 13px; font-weight: 600; color: var(--primary); }
.reply-bar-text { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============ TYPING INDICATOR ============ */
/* ── Typing indicator — shown in chat header status ── */
.chat-header-status.typing-active {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--primary);
  font-style: italic;
}
.typing-name {
  font-size: 12px;
  font-weight: 500;
  font-style: italic;
  color: var(--primary);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: 1px;
  padding-bottom: 1px;
}
.typing-dots span {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--primary);
  display: inline-block;
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30%            { transform: translateY(-3px); opacity: 1; }
}

/* ============ MESSAGE INPUT ============ */
/* ── Telegram-style input bar ── */
.message-input-area {
  padding: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Telegram-style: one seamless row, no pill border */
.input-row {
  display: flex;
  align-items: flex-end;
  gap: 0;
  padding: 6px 4px 8px;
  background: var(--surface);
}

/* V155 BUILD-MARKER: composer-pill floating + centered.
   Применяется при открытом чате на любой ширине. На широких — пилюля
   шириной 800px по центру с тенью; на узких max-width не вступает,
   но скругление + тень остаются. */
.chat-area.has-chat-open .message-input-area {
  background: transparent !important;
  border-top: none !important;
  padding: 0 16px 16px !important;
}
.chat-area.has-chat-open .input-row {
  max-width: 800px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: 24px;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
  padding: 6px 10px;
}
.chat-area.has-chat-open .reply-preview,
.chat-area.has-chat-open .edit-preview {
  max-width: 800px;
  margin: 0 auto;
  border-radius: 18px;
}

/* Icon buttons — attach, emoji, mic — all same ghost style */
.inp-icon-btn {
  width: 40px; height: 40px;
  border: none; background: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  border-radius: 50%;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
  padding: 0;
}
.inp-icon-btn:hover { color: var(--primary); background: var(--hover); }
.inp-icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Center: plain textarea — NO border, NO background, NO pill */
.input-pill {
  flex: 1;
  display: flex;
  align-items: flex-end;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  min-height: 40px;
}

.input-pill textarea {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--foreground);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  resize: none;
  max-height: 150px;
  line-height: 1.5;
  padding: 10px 4px;
}
.input-pill textarea::placeholder { color: var(--muted); }

/* Emoji/sticker button — right of textarea */
.inp-emoji-btn {
  width: 36px; height: 36px;
  border: none; background: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  border-radius: 50%;
  flex-shrink: 0;
  transition: color 0.15s;
  padding: 0;
}
.inp-emoji-btn:hover { color: var(--primary); }

/* Right: animated mic/send */
.inp-action-wrap {
  width: 40px; height: 40px;
  position: relative;
  flex-shrink: 0;
}

.inp-action-btn {
  position: absolute;
  inset: 0;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.15s ease,
              background 0.15s;
}

/* Mic — ghost */
.inp-mic {
  background: none;
  color: var(--muted);
}
.inp-mic:hover { color: var(--primary); background: var(--hover); }
.inp-mic.recording { background: var(--error); color: #fff; animation: pulse 1s infinite; }

/* Send — filled blue */
.inp-send {
  background: var(--primary);
  color: #fff;
}
.inp-send:hover { opacity: 0.88; }

.btn-visible {
  opacity: 1;
  transform: scale(1) rotate(0deg);
  pointer-events: auto;
}
.btn-hidden {
  opacity: 0;
  transform: scale(0.4) rotate(-45deg);
  pointer-events: none;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

/* ============ STICKER PICKER ============ */
.sticker-picker {
  position: absolute;
  bottom: 70px;
  right: 16px;
  width: 360px;
  height: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  z-index: 50;
  overflow: hidden;
}

.sticker-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
}

.sticker-picker-tabs {
  display: flex;
  gap: 4px;
  padding: 8px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
}

.sticker-picker-tabs::-webkit-scrollbar { display: none; }

.sticker-tab {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  cursor: pointer;
  padding: 4px;
  transition: background 0.15s;
  flex-shrink: 0;
}

.sticker-tab:hover { background: var(--hover); }
.sticker-tab.active { background: var(--active); }
.sticker-tab img { width: 100%; height: 100%; object-fit: contain; }

.sticker-picker-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 12px;
  overflow-y: auto;
}

.sticker-item {
  aspect-ratio: 1;
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 4px;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sticker-item:hover { background: var(--hover); transform: scale(1.1); }
.sticker-item img { width: 100%; height: 100%; object-fit: contain; }

/* ============ INFO PANEL ============ */
.info-panel {
  width: var(--info-panel-width);
  min-width: var(--info-panel-width);
  /* V8-float: плавающая овальная панель справа */
  height: calc(100vh - 32px);
  margin: 16px 16px 16px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body.dark .info-panel { border-color: rgba(255,255,255,0.06); }

.info-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 16px;
  font-weight: 600;
}

.info-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.info-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 600;
  color: white;
  background: var(--primary);
  overflow: hidden;
}

.info-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.info-name {
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 4px;
}

.info-status {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin-bottom: 16px;
}

.info-section {
  margin-bottom: 16px;
}

.info-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.info-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}

.info-row-label { font-size: 13px; color: var(--muted); min-width: 80px; }
.info-row-value { font-size: 14px; color: var(--foreground); }

.info-member {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}

.info-member-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: white;
  background: var(--primary);
  overflow: hidden;
  flex-shrink: 0;
}

.info-member-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.info-member-name { font-size: 14px; font-weight: 500; }
.info-member-role { font-size: 12px; color: var(--muted); }

/* ============ MODAL ============ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 480px;
  max-height: 80vh;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 201;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 16px;
  font-weight: 600;
}

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

.modal-field {
  margin-bottom: 16px;
}

.modal-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
}

.modal-field input,
.modal-field textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--background);
  color: var(--foreground);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}

.modal-field input:focus,
.modal-field textarea:focus { border-color: var(--primary); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.btn-secondary {
  padding: 8px 20px;
  border: 1px solid var(--border);
  background: none;
  color: var(--foreground);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}

.btn-secondary:hover { background: var(--hover); }

/* User list in modal */
.user-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.user-list-item:hover { background: var(--hover); }

.user-list-item .checkbox {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}

.user-list-item .checkbox.checked {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ============ CONTEXT MENU ============ */
.context-menu {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 300;
  min-width: 180px;
  padding: 4px 0;
  animation: fadeIn 0.1s ease;
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--foreground);
  cursor: pointer;
  transition: background 0.1s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.context-menu-item:hover { background: var(--hover); }
.context-menu-item.danger { color: var(--error); }

.context-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 24px;
  background: var(--foreground);
  color: var(--background);
  border-radius: var(--radius-sm);
  font-size: 14px;
  z-index: 500;
  animation: toastIn 0.3s ease;
  box-shadow: var(--shadow-lg);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ============ LOADING ============ */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ============ MEDIA GROUP ============ */
.media-group {
  display: grid;
  gap: 2px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  max-width: 320px;
}

.media-group.count-2 { grid-template-columns: 1fr 1fr; }
.media-group.count-3 { grid-template-columns: 1fr 1fr; }
.media-group.count-4 { grid-template-columns: 1fr 1fr; }

.media-group-item {
  aspect-ratio: 1;
  overflow: hidden;
  cursor: pointer;
}

.media-group-item img,
.media-group-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ============ IMAGE VIEWER ============ */
/* ═══════════════════════ MEDIA VIEWER ══════════════════════════════════════ */
.image-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0);
  z-index: 10000; /* above Electron titlebar (9999) */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}
.image-viewer.iv-visible { background: rgba(0,0,0,0.92); }

/* toolbar — starts below the 34px Electron titlebar */
.iv-toolbar {
  position: absolute;
  top: 34px; left: 0; right: 0;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  padding: 0 16px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.65), transparent);
  z-index: 10;
  pointer-events: none;
  -webkit-app-region: no-drag;
}
.iv-toolbar > * { pointer-events: auto; -webkit-app-region: no-drag; }

.iv-zoom-label {
  font-size: 13px;
  color: rgba(255,255,255,0.75);
  min-width: 44px;
  text-align: center;
  margin-right: 4px;
  user-select: none;
}

.iv-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.14);
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
  -webkit-app-region: no-drag;
  flex-shrink: 0;
}
.iv-btn:hover { background: rgba(255,255,255,0.28); }
.iv-btn.iv-close { margin-left: 8px; background: rgba(255,255,255,0.18); }
.iv-btn.iv-close:hover { background: rgba(220,50,50,0.7); }

/* image canvas — account for titlebar + toolbar */
.iv-canvas {
  width: 100%;
  height: 100%;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  cursor: default;
  padding-top: 86px; /* 34px titlebar + 52px toolbar */
}
.iv-canvas[style*="grab"] { cursor: grab; }
.iv-canvas[style*="grabbing"] { cursor: grabbing; }

.iv-canvas img {
  max-width: 90vw;
  max-height: calc(90vh - 86px);
  object-fit: contain;
  user-select: none;
  transform-origin: center center;
  transition: transform 0.08s ease-out;
  border-radius: 4px;
}

/* video viewer — centered with room for toolbar */
.iv-video {
  max-width: 92vw;
  max-height: calc(88vh - 86px);
  margin-top: 86px;
  border-radius: 8px;
  outline: none;
  background: #000;
}

/* ============ VOICE RECORDING ============ */
.voice-recording-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.voice-recording-time {
  font-size: 14px;
  color: var(--error);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.voice-recording-wave {
  flex: 1;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.voice-recording-wave .bar {
  width: 3px;
  background: var(--primary);
  border-radius: 2px;
  animation: waveAnim 0.5s ease infinite alternate;
}

@keyframes waveAnim {
  from { height: 4px; }
  to { height: 24px; }
}

/* ============ CHANNEL MESSAGES ============ */
.channel-message {
  max-width: 75%;
  align-self: flex-start;
}

.channel-message .message-bubble {
  background: var(--surface);
  color: var(--foreground);
}

.channel-message .message-views {
  font-size: 11px;
  color: var(--muted);
}

/* ============ BOT MESSAGES ============ */
.bot-message-row.bot .message-bubble {
  background: var(--message-in);
  color: var(--message-in-text);
}

.bot-message-row.user .message-bubble {
  background: var(--message-out);
  color: var(--message-out-text);
}

/* ============ SETTINGS ============ */
.settings-section {
  margin-bottom: 24px;
}

.settings-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 8px;
  text-transform: uppercase;
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.settings-item-label { font-size: 14px; }

.toggle-switch {
  width: 44px;
  height: 24px;
  background: var(--border);
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-switch.active { background: var(--primary); }

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-switch.active::after { transform: translateX(20px); }

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  .sidebar { width: 100%; min-width: 100%; max-width: 100%; }
  .chat-area { display: none; }
  .chat-area.active { display: flex; position: absolute; top: 0; left: 0; right: 0; bottom: 0; z-index: 50; }
  .back-btn { display: flex; }
  .info-panel { position: absolute; top: 0; right: 0; bottom: 0; z-index: 60; }
}

/* Call message */
.message-call {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(0,0,0,0.05);
  border-radius: var(--radius);
  min-width: 200px;
}

body.dark .message-call { background: rgba(255,255,255,0.08); }

.call-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.call-icon.missed { background: var(--error); }

.call-info { flex: 1; min-width: 0; }
.call-title { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.call-duration { font-size: 12px; color: var(--muted); }

/* ── Call message improvements ── */
.message-call {
  min-width: 220px;
  max-width: 280px;
  cursor: default;
  user-select: none;
}

.call-arrow {
  display: inline-flex;
  align-items: center;
  margin-right: 5px;
  vertical-align: middle;
  opacity: 0.6;
}

.call-arrow.arrow-missed {
  color: var(--error);
  opacity: 0.9;
}

.call-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 14px;
  border: 1.5px solid var(--primary);
  background: transparent;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.call-back-btn:hover {
  background: var(--primary);
  color: #fff;
}

.message-call.call-missed .call-icon {
  background: var(--error);
}

.message-call.call-done .call-icon {
  background: var(--primary);
}

.call-title {
  display: flex;
  align-items: center;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
  color: var(--foreground);
}

/* ── File attach button loading state ── */
[onclick="attachFile()"]:disabled {
  cursor: not-allowed;
}

/* ── Toast improvement ── */
#toast {
  max-width: 320px;
  word-break: break-word;
}

/* ════════════════════════════════════════════════
   SYSTEM / SERVICE MESSAGES
   ════════════════════════════════════════════════ */

.system-msg-row {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 4px 16px;
  margin: 6px 0;
}

.system-msg-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border-radius: 14px;
  padding: 5px 12px;
  max-width: 80%;
  cursor: default;
  border: 1px solid var(--border);
}

body.dark .system-msg-pill {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.1);
}

.system-msg-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
}

.system-msg-text {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  text-align: center;
}

/* ════════════════════════════════════════════════
   CALL BUTTONS IN CHAT HEADER
   ════════════════════════════════════════════════ */

.call-header-btn {
  color: var(--primary) !important;
  opacity: 0.85;
  transition: opacity 0.15s, background 0.15s;
}
.call-header-btn:hover {
  opacity: 1;
  background: var(--primary) !important;
  color: #fff !important;
}

/* Active call indicator in header */
.call-active-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #4CD964;
  font-weight: 600;
  padding: 3px 10px;
  background: rgba(76, 217, 100, 0.12);
  border-radius: 10px;
  border: 1px solid rgba(76, 217, 100, 0.3);
}
.call-active-indicator::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #4CD964;
  animation: blink-green 1.2s infinite;
}
@keyframes blink-green {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.3; }
}

/* ── File download button ── */
.message-attachment-file {
  cursor: pointer;
  gap: 12px;
}
.file-download-icon {
  margin-left: auto;
  flex-shrink: 0;
  color: var(--primary);
  opacity: 0.7;
  transition: opacity 0.15s;
  display: flex;
  align-items: center;
}
.message-attachment-file:hover .file-download-icon {
  opacity: 1;
}
.file-download-hint {
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}

/* ════════════════════════════════════════════════
   CUSTOM TITLEBAR — global overlay (top-right)
   ════════════════════════════════════════════════ */

body { margin: 0; }

/* Full-width invisible drag area, height 34px, sits on top of everything */
#global-titlebar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 34px;
  z-index: 9999;
  display: flex;
  align-items: center;
  pointer-events: none; /* let clicks pass through except on controls */
  -webkit-app-region: no-drag;
}

.global-tb-drag {
  flex: 1;
  height: 100%;
  -webkit-app-region: drag;
  pointer-events: auto;
}

.global-tb-controls {
  display: flex;
  align-items: center;
  height: 100%;
  -webkit-app-region: no-drag;
  pointer-events: auto;
}

/* Shared button style */
.tb-btn {
  width: 46px;
  height: 34px;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: background 0.12s, color 0.12s;
  border-radius: 0;
  padding: 0;
  outline: none;
  -webkit-app-region: no-drag;
}
.tb-btn:hover { background: rgba(128,128,128,0.15); color: var(--foreground); }
.tb-close:hover { background: #E81123 !important; color: #fff !important; }

/* Offset main layout so content doesn't go under titlebar */
.app-layout { margin-top: 34px; height: calc(100vh - 34px) !important; }
/* V8-float: учитываем верхний+нижний margin плавающего сайдбара (16+16) */
.sidebar    { height: calc(100vh - 34px - 28px) !important; }
.info-panel { height: calc(100vh - 34px - 32px) !important; }

/* Auth screen needs drag region too */
#auth-screen {
  -webkit-app-region: drag;
}
#auth-screen * {
  -webkit-app-region: no-drag;
}

/* ════════════════════════════════════════════════
   MESSAGE ATTACHMENTS — Telegram style
   ════════════════════════════════════════════════ */

/* ── Image / Video ── */
.msg-img-wrap {
  border-radius: 12px;
  overflow: hidden;
  max-width: 320px;
  cursor: pointer;
  position: relative;
  background: var(--border);
}

/* С подписью — скругление только сверху, снизу прямые углы */
.msg-img-wrap.has-caption {
  border-radius: 12px 12px 0 0;
  margin-bottom: 0;
}

/* Нижний отступ между картинкой и подписью */
.msg-img-wrap.has-caption + .message-text {
  margin-top: 6px;
}
.msg-img {
  display: block;
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  border-radius: inherit;
}
/* Внутри пузыря с подписью — убираем нижнее скругление у самой картинки */
.msg-img-wrap.has-caption .msg-img {
  border-radius: 12px 12px 0 0;
}
.msg-video-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.25);
  border-radius: inherit;
  pointer-events: none;
}
.msg-video-play div {
  width: 52px; height: 52px; border-radius: 26px;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
}

/* ── Voice message ── */
.msg-voice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 2px;
  min-width: 210px;
  max-width: 280px;
  cursor: pointer;
  user-select: none;
}
.vm-play-btn {
  width: 40px; height: 40px; border-radius: 20px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.15s;
}
.vm-play-btn:hover { opacity: 0.75; }

/* Outgoing */
.message-row.outgoing .vm-play-btn {
  background: rgba(255,255,255,0.2);
  color: #fff;
}
body.light .message-row.outgoing .vm-play-btn {
  background: rgba(0,98,184,0.15);
  color: var(--primary);
}
/* Incoming */
.message-row.incoming .vm-play-btn {
  background: rgba(var(--primary-rgb, 10,132,255), 0.15);
  color: var(--primary);
}

.vm-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.vm-bars {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 24px;
}
.vm-bar {
  width: 3px;
  border-radius: 2px;
  flex-shrink: 0;
  transition: background-color 0.08s;
  /* Inactive color set per bubble side */
}
/* Outgoing bars */
.message-row.outgoing .vm-bar { background: rgba(255,255,255,0.3); }
.message-row.outgoing .vm-bar.active { background: #fff; }
body.light .message-row.outgoing .vm-bar { background: rgba(0,98,184,0.25); }
body.light .message-row.outgoing .vm-bar.active { background: var(--primary); }
/* Incoming bars */
.message-row.incoming .vm-bar { background: rgba(var(--primary-rgb, 10,132,255), 0.2); }
.message-row.incoming .vm-bar.active { background: var(--primary); }

.vm-time {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.message-row.outgoing .vm-time { color: rgba(255,255,255,0.6); }
body.light .message-row.outgoing .vm-time { color: rgba(0,98,184,0.6); }

/* ── File message ── */
.msg-file {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 2px;
  min-width: 200px;
  max-width: 300px;
  cursor: pointer;
  border-radius: 8px;
  transition: opacity 0.15s;
}
.msg-file:hover { opacity: 0.82; }

.msg-file-icon {
  width: 44px; height: 44px; border-radius: 22px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
/* Outgoing */
.message-row.outgoing .msg-file-icon {
  background: rgba(255,255,255,0.2);
  color: #fff;
}
body.light .message-row.outgoing .msg-file-icon {
  background: rgba(0,98,184,0.12);
  color: var(--primary);
}
/* Incoming */
.message-row.incoming .msg-file-icon {
  background: rgba(var(--primary-rgb, 10,132,255), 0.12);
  color: var(--primary);
}

.msg-file-info { flex: 1; min-width: 0; }
.msg-file-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Name color */
.message-row.outgoing .msg-file-name { color: #fff; }
body.light .message-row.outgoing .msg-file-name { color: var(--primary); }
.message-row.incoming .msg-file-name { color: var(--foreground); }

.msg-file-meta {
  font-size: 12px;
  margin-top: 2px;
}
.message-row.outgoing .msg-file-meta { color: rgba(255,255,255,0.6); }
body.light .message-row.outgoing .msg-file-meta { color: rgba(0,98,184,0.6); }
.message-row.incoming .msg-file-meta { color: var(--muted); }

.msg-file-dl {
  flex-shrink: 0;
  opacity: 0.6;
}
.message-row.outgoing .msg-file-dl { color: #fff; }
body.light .message-row.outgoing .msg-file-dl { color: var(--primary); }
.message-row.incoming .msg-file-dl { color: var(--primary); }

/* ── Call message — Telegram style ── */
/* Override old .message-call with new layout */
.message-call {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  padding: 4px 2px !important;
  min-width: 180px !important;
  background: none !important;
}

.call-icon {
  width: 40px !important; height: 40px !important;
  border-radius: 20px !important;
  flex-shrink: 0 !important;
  display: flex !important; align-items: center !important; justify-content: center !important;
}
/* Outgoing */
.message-row.outgoing .call-icon { background: rgba(255,255,255,0.2) !important; color: #fff !important; }
body.light .message-row.outgoing .call-icon { background: rgba(0,98,184,0.12) !important; color: var(--primary) !important; }
/* Incoming */
.message-row.incoming .call-icon { background: rgba(var(--primary-rgb,10,132,255),0.12) !important; color: var(--primary) !important; }
/* Missed */
.call-icon.missed { background: rgba(255,59,48,0.15) !important; color: #FF3B30 !important; }

.call-info { flex: 1 !important; }
.call-title {
  font-size: 14px !important; font-weight: 600 !important;
  display: flex !important; align-items: center !important; gap: 4px !important;
}
/* Call title color */
.message-row.outgoing .call-title { color: #fff; }
body.light .message-row.outgoing .call-title { color: var(--primary); }
.message-row.incoming .call-title { color: var(--foreground); }

.call-duration { font-size: 12px !important; margin-top: 2px !important; }
.message-row.outgoing .call-duration { color: rgba(255,255,255,0.6) !important; }
body.light .message-row.outgoing .call-duration { color: rgba(0,98,184,0.6) !important; }
.message-row.incoming .call-duration { color: var(--muted) !important; }

/* Call back button */
.call-back-btn {
  border: 1.5px solid currentColor !important;
  background: none !important;
  border-radius: 12px !important;
  padding: 4px 10px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  white-space: nowrap !important;
  display: flex !important; align-items: center !important; gap: 4px !important;
}
.message-row.outgoing .call-back-btn { color: #fff !important; }
body.light .message-row.outgoing .call-back-btn { color: var(--primary) !important; }
.message-row.incoming .call-back-btn { color: var(--primary) !important; }
.call-back-btn:hover { opacity: 0.75 !important; }

/* ── Media group ── */
.media-group {
  display: grid;
  gap: 2px;
  border-radius: 12px;
  overflow: hidden;
  max-width: 320px;
}
.media-group.count-1 { grid-template-columns: 1fr; }
.media-group.count-2 { grid-template-columns: 1fr 1fr; }
.media-group.count-3 { grid-template-columns: 1fr 1fr; }
.media-group.count-4 { grid-template-columns: 1fr 1fr; }
.media-group-item { position: relative; overflow: hidden; aspect-ratio: 1; background: var(--border); }
.media-group-item img,
.media-group-item video { width: 100%; height: 100%; object-fit: cover; display: block; cursor: pointer; }
.media-group.count-3 .media-group-item:first-child { grid-column: span 2; aspect-ratio: 2/1; }

/* Old attachment wrapper — remove extra padding */
.message-attachment { padding: 0 !important; background: none !important; }

/* ── Media-only bubble: no padding, no background, clean corners ── */
.media-only-bubble {
  padding: 0 !important;
  background: transparent !important;
  border-bottom-right-radius: 12px !important;
  border-bottom-left-radius: 12px !important;
  overflow: hidden;
  position: relative;
}
/* Ensure img inside has rounded corners that match bubble tail */
.message-row.outgoing .media-only-bubble .msg-img-wrap {
  border-radius: 14px 14px 4px 14px;
}
.message-row.incoming .media-only-bubble .msg-img-wrap {
  border-radius: 14px 14px 14px 4px;
}

/* ── Meta (время + галочки) на медиа: прямо в углу фото без плашки ─────────
   Виктор: "должна быть полностью прозрачная, галочки прям на фото в углу".
   Прозрачный фон + белый текст с тенью для читаемости поверх любого фото. */
.media-only-bubble .message-meta,
.tg-media-group + .message-meta-overlay,
.message-bubble.media-group-bubble .message-meta {
  position: absolute;
  bottom: 6px;
  right: 10px;
  z-index: 3;
  margin: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  pointer-events: none;
  text-shadow: 0 0 4px rgba(0,0,0,0.6), 0 1px 2px rgba(0,0,0,0.55);
}
.media-only-bubble .message-meta .message-time,
.media-only-bubble .message-meta .msg-checks,
.message-bubble.media-group-bubble .message-meta .message-time,
.message-bubble.media-group-bubble .message-meta .msg-checks {
  color: #fff !important;
  filter: drop-shadow(0 0 2px rgba(0,0,0,0.6));
}

/* ── Anti-jump: scroll anchoring при подгрузке старых сообщений ─────────────
   overflow-anchor:auto — браузер сам удержит scroll position если высота
   контейнера меняется (картинки догружаются, новые сообщения добавляются).
   Решает прыжки при scroll вверх и при rerender. */
.messages-container,
#messages-container,
.messages-list,
#messages-list {
  overflow-anchor: auto;
  scroll-behavior: auto;
}
/* Картинки в чате — резервируют место заранее, не сдвигают layout при load */
.msg-img-wrap, .media-group-item {
  contain: layout paint;
}

/* Kill old border-radius on raw img tags inside attachments */
.message-attachment img {
  border-radius: 0 !important;
}
.message-attachment { padding: 0 !important; background: none !important; }

/* ── Reply bar inside input ── */
.reply-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 8px;
  border-left: 3px solid var(--primary);
  margin: 0 10px 6px;
  border-radius: 0 4px 4px 0;
  background: rgba(var(--primary-rgb, 10,132,255), 0.06);
}
.reply-bar-content { flex: 1; min-width: 0; }
.reply-bar-name { font-size: 12px; font-weight: 600; color: var(--primary); }
.reply-bar-text {
  font-size: 12px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ============ NEW GROUP WIZARD ============ */
.modal-input-center {
  width: 100%;
  font-size: 17px;
  text-align: center;
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--primary);
  color: var(--foreground);
  padding: 8px 4px;
  outline: none;
  box-sizing: border-box;
}
.modal-input-center::placeholder { color: var(--muted); }

.ng-card {
  background: var(--surface);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 10px;
}
.ng-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
}
.ng-row-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ng-username-input {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 1.5px solid var(--border);
  color: var(--foreground);
  font-size: 16px;
  padding: 6px 2px;
  outline: none;
}
.ng-username-input:focus { border-bottom-color: var(--primary); }

/* Toggle switch */
.ng-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
  cursor: pointer;
}
.ng-toggle input { opacity: 0; width: 0; height: 0; }
.ng-toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 13px;
  transition: background 0.2s;
}
.ng-toggle-track::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  transition: transform 0.2s;
}
.ng-toggle input:checked + .ng-toggle-track { background: var(--primary); }
.ng-toggle input:checked + .ng-toggle-track::before { transform: translateX(18px); }

/* ============ GROUP INFO PANEL ============ */
.gi-card {
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 10px;
}
.gi-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
}
.gi-row-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.gi-row-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 2px;
}
.gi-input {
  width: 100%;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--foreground);
  font-size: 14px;
  padding: 7px 10px;
  outline: none;
  box-sizing: border-box;
  margin-bottom: 4px;
  transition: border-color 0.15s;
}
.gi-input:focus { border-color: var(--primary); }
.gi-textarea {
  resize: vertical;
  min-height: 64px;
  font-family: inherit;
}
.gi-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--foreground);
  transition: opacity 0.15s;
}
.gi-btn:hover { opacity: 0.8; }
.gi-btn-danger {
  color: var(--error) !important;
  border-color: var(--error) !important;
}
.gi-btn-sm {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--foreground);
  cursor: pointer;
  flex-shrink: 0;
}
.gi-mode-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--surface);
  transition: background 0.15s;
}
.gi-mode-option:hover { background: var(--hover); }
.invite-link-box {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--primary);
  word-break: break-all;
}

/* ── Telegram-style media group ──────────────────────────────────────────── */
.tg-media-group {
  display: block;
  line-height: 0;
  user-select: none;
}
.tg-mg-item {
  transition: filter 0.15s;
}
.tg-mg-item:hover {
  filter: brightness(0.9);
}

/* ── Drag & Drop overlay ─────────────────────────────────────────────────── */
.dd-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
  pointer-events: none;
}
.dd-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.dd-overlay:not(.hidden) {
  opacity: 1;
  pointer-events: auto;
}
.dd-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 40px 60px;
  border: 2.5px dashed rgba(255,255,255,0.55);
  border-radius: 24px;
  color: white;
  animation: dd-pulse 1.5s ease-in-out infinite;
}
.dd-overlay-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.dd-overlay-sub {
  font-size: 14px;
  opacity: 0.75;
}
@keyframes dd-pulse {
  0%, 100% { border-color: rgba(255,255,255,0.55); }
  50% { border-color: rgba(255,255,255,0.9); }
}

/* ── Pinned message bar ──────────────────────────────────────────────────── */
.pinned-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px 7px 0;
  /* V8-float: плавающий овальный блок закреплённого, по ширине как хедер/поле ввода */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 800px;
  margin: 8px auto 0;
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
  min-height: 44px;
  transition: background 0.15s;
  position: relative;
  z-index: 2;
}
body.dark .pinned-bar { border-color: rgba(255,255,255,0.06); }
.pinned-bar:hover { background: var(--hover); }

.pinned-bar-accent {
  width: 3px;
  align-self: stretch;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
  flex-shrink: 0;
  margin-right: 8px;
}

.pinned-bar-body {
  flex: 1;
  min-width: 0;
}
.pinned-bar-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 2px;
}
.pinned-bar-text {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pinned-bar-close {
  flex-shrink: 0;
  opacity: 0.5;
}
.pinned-bar-close:hover { opacity: 1; }

/* ── Scroll-to-bottom button ────────────────────────────────────────────── */
.scroll-down-btn {
  position: absolute;
  bottom: 72px;
  right: 16px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--surface);
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
  color: var(--foreground);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: opacity 0.2s, transform 0.2s, background 0.2s;
}
.scroll-down-btn:hover {
  background: var(--hover);
  transform: scale(1.08);
}
.scroll-down-btn.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}
/* History mode — pulse blue to draw attention */
.scroll-down-btn.jump-to-latest {
  background: var(--primary);
  color: #fff;
  animation: jl-pulse 1.8s ease-in-out infinite;
}
@keyframes jl-pulse {
  0%, 100% { box-shadow: 0 2px 12px rgba(0,0,0,0.25); }
  50%       { box-shadow: 0 2px 18px rgba(0,136,204,0.55); }
}

/* ── Media group time overlay ───────────────────────────────────────────── */
.mg-meta-overlay {
  position: absolute;
  bottom: 8px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: rgba(255,255,255,0.92);
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
  pointer-events: none;
  z-index: 2;
}

/* ── Media-group bubble: no padding, transparent ───────────────────────── */
.media-only-bubble .tg-media-group {
  border-radius: 14px;
  overflow: hidden;
}
.message-row.outgoing .media-only-bubble .tg-media-group {
  border-radius: 14px 14px 4px 14px;
}
.message-row.incoming .media-only-bubble .tg-media-group {
  border-radius: 14px 14px 14px 4px;
}


/* Message highlight (pinned/reply scroll target) */
.msg-highlight {
  animation: msg-hl 2s ease forwards;
}
@keyframes msg-hl {
  0%   { background: rgba(0,136,204,0.18); }
  60%  { background: rgba(0,136,204,0.14); }
  100% { background: transparent; }
}

/* ── User Profile Modal (Telegram-style centered dialog) ─────────────────── */
.up2-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.18s ease;
}
.up2-overlay.visible {
  opacity: 1; pointer-events: auto;
}
.up2-overlay.closing { opacity: 0; pointer-events: none; }

.up2-dialog {
  background: var(--background);
  border-radius: 14px;
  width: 460px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 60px);
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 48px rgba(0,0,0,0.35);
  animation: up2-in 0.18s cubic-bezier(0.34,1.4,0.64,1) both;
}
@keyframes up2-in { from { transform: scale(0.93); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.up2-inner {
  display: flex; flex-direction: column;
  height: 100%; overflow: hidden;
  position: relative;
}

/* Close button */
.up2-close {
  position: absolute; top: 10px; right: 12px; z-index: 10;
  width: 30px; height: 30px; border-radius: 50%;
  border: none; background: rgba(120,120,128,0.18);
  color: var(--foreground); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.up2-close:hover { background: rgba(120,120,128,0.32); }

/* Hero / avatar area */
.up2-hero {
  display: flex; flex-direction: column; align-items: center;
  padding: 28px 20px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.up2-avatar-wrap {
  width: 82px; height: 82px; border-radius: 50%;
  overflow: hidden; margin-bottom: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 700; color: white;
  flex-shrink: 0;
}
.up2-avatar-img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; }
.up2-avatar-init { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 30px; font-weight: 700; color: white; }

.up2-hero-name { font-size: 19px; font-weight: 700; color: var(--foreground); text-align: center; }
.up2-hero-status { font-size: 13px; color: var(--muted); margin-top: 3px; text-align: center; }
.up2-hero-status.online { color: #34C759; }

/* Action buttons row */
.up2-actions {
  display: flex; gap: 8px; margin-top: 14px; justify-content: center;
}
.up2-action-btn {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  border: none; background: none; cursor: pointer;
  width: 76px;
}
.up2-action-icon {
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--background);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--primary);
  transition: background 0.15s;
}
.up2-action-btn:hover .up2-action-icon { background: var(--hover); }
.up2-action-btn span { font-size: 12px; color: var(--muted); font-weight: 500; }

/* Scrollable body */
.up2-body {
  flex: 1; overflow-y: auto; padding: 10px 14px 20px;
}

/* Cards */
.up2-card {
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 10px;
}

/* Info rows (value first, label below — Telegram style) */
.up2-info-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  position: relative;
}
.up2-info-row.clickable { cursor: pointer; }
.up2-info-row.clickable:hover { background: var(--hover); }
.up2-info-icon-wrap {
  width: 36px; height: 36px; border-radius: 10px;
  background: rgba(10,132,255,0.1);
  display: flex; align-items: center; justify-content: center;
  color: var(--primary); flex-shrink: 0;
}
.up2-info-body { flex: 1; min-width: 0; }
.up2-info-value { font-size: 16px; color: var(--foreground); font-weight: 400; }
.up2-info-value.primary { color: var(--primary); }
.up2-info-label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.up2-qr-btn {
  border: none; background: none; color: var(--primary); cursor: pointer;
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: 8px; flex-shrink: 0;
}
.up2-qr-btn:hover { background: var(--hover); }
.up2-info-chevron { color: var(--muted); flex-shrink: 0; }
.up2-divider { height: 1px; background: var(--border); margin-left: 62px; }

/* Tabs */
.up2-tabs-row {
  display: flex; border-bottom: 1px solid var(--border);
  padding: 0 14px;
}
.up2-tab {
  padding: 10px 14px;
  border: none; background: none; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.up2-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.up2-tab:hover:not(.active) { color: var(--foreground); }

/* Tab content */
.up2-tab-content { min-height: 100px; }

/* Media grid 3-col */
.up2-media-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px;
  padding: 8px;
}
.up2-media-cell {
  aspect-ratio: 1; overflow: hidden; cursor: pointer;
  position: relative; background: var(--border); border-radius: 4px;
}
.up2-media-cell img { width: 100%; height: 100%; object-fit: cover; transition: filter 0.15s; }
.up2-media-cell:hover img { filter: brightness(0.82); }

/* File rows */
.up2-file-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; cursor: pointer;
  transition: background 0.1s;
}
.up2-file-row:hover { background: var(--hover); }
.up2-file-row-border { border-bottom: 1px solid var(--border); }
.up2-file-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: rgba(10,132,255,0.1);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.up2-file-body { flex: 1; min-width: 0; }
.up2-file-name { font-size: 14px; font-weight: 500; color: var(--foreground); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up2-file-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Keep shared helpers */
.up-empty { text-align: center; color: var(--muted); padding: 30px 0; font-size: 13px; }
.up-loading { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 120px; }
.up-play-icon { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.3); }

/* ── Send File Preview Modal ────────────────────────────────────────────────── */
.sfm-overlay {
  position: fixed; inset: 0; z-index: 600;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  animation: sfm-bg-in 0.15s ease;
}
@keyframes sfm-bg-in { from { opacity: 0; } to { opacity: 1; } }

.sfm-dialog {
  background: var(--background);
  border-radius: 14px;
  width: 420px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 60px);
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 16px 56px rgba(0,0,0,0.35);
  animation: sfm-in 0.16s cubic-bezier(0.34,1.4,0.64,1) both;
}
@keyframes sfm-in { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.sfm-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px;
  flex-shrink: 0;
}
.sfm-title { font-size: 16px; font-weight: 600; color: var(--foreground); }
.sfm-header-btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: none; background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
}
.sfm-header-btn:hover { background: var(--hover); color: var(--foreground); }

.sfm-body {
  flex: 1; overflow-y: auto; padding: 0 14px;
  min-height: 60px; max-height: 55vh;
}

/* Single image preview */
.sfm-single-preview {
  position: relative; border-radius: 10px; overflow: hidden; margin-bottom: 10px;
  background: var(--border);
}
.sfm-preview-img {
  width: 100%; max-height: 340px; object-fit: contain;
  display: block; border-radius: 10px;
}
.sfm-preview-actions {
  position: absolute; top: 8px; right: 8px;
  display: flex; gap: 6px;
}
.sfm-icon-action {
  width: 34px; height: 34px; border-radius: 50%;
  border: none; background: rgba(0,0,0,0.55); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: white; transition: background 0.15s;
}
.sfm-icon-action:hover { background: rgba(0,0,0,0.75); }
.sfm-icon-action.sfm-delete:hover { background: rgba(220,50,50,0.75); }

/* Checkbox row */
.sfm-checkbox-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.sfm-checkbox-label {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; color: var(--foreground); cursor: pointer;
  padding: 4px 0;
}
.sfm-checkbox-label input[type="checkbox"] {
  width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer;
}

/* Multi image grid */
.sfm-grid-preview {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 4px; margin-bottom: 10px; border-radius: 10px; overflow: hidden;
}
.sfm-thumb-item {
  position: relative; aspect-ratio: 1; overflow: hidden; background: var(--border);
  border-radius: 4px;
}
.sfm-thumb-img { width: 100%; height: 100%; object-fit: cover; }
.sfm-thumb-play {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.3);
}
.sfm-thumb-del {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px; border-radius: 50%;
  border: none; background: rgba(0,0,0,0.6); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.sfm-thumb-del:hover { background: rgba(200,40,40,0.8); }

/* File list */
.sfm-file-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.sfm-file-row:last-child { border-bottom: none; }
.sfm-file-thumb {
  width: 46px; height: 46px; border-radius: 8px;
  object-fit: cover; flex-shrink: 0;
}
.sfm-file-icon-big {
  width: 46px; height: 46px; border-radius: 10px;
  background: var(--primary); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.sfm-file-info { flex: 1; min-width: 0; }
.sfm-file-name {
  font-size: 14px; font-weight: 500; color: var(--foreground);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sfm-file-size { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Caption row */
.sfm-caption-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.sfm-caption-input {
  flex: 1; border: none; background: transparent;
  font-size: 14px; color: var(--foreground); outline: none;
  font-family: inherit;
}
.sfm-caption-input::placeholder { color: var(--muted); }
.sfm-emoji-btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: none; background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); flex-shrink: 0;
}
.sfm-emoji-btn:hover { color: var(--primary); }

/* Footer */
.sfm-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px 14px;
  flex-shrink: 0;
}
.sfm-add-btn {
  display: flex; align-items: center; gap: 6px;
  border: none; background: none; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--primary);
  padding: 6px 0;
}
.sfm-add-btn:hover { opacity: 0.75; }
.sfm-right-btns { display: flex; gap: 16px; align-items: center; }
.sfm-cancel-btn {
  border: none; background: none; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--muted);
  padding: 6px 0;
}
.sfm-cancel-btn:hover { color: var(--foreground); }
.sfm-send-btn {
  border: none; background: none; cursor: pointer;
  font-size: 14px; font-weight: 700; color: var(--primary);
  padding: 6px 0;
}
.sfm-send-btn:hover { opacity: 0.75; }

/* ── In-chat search bar ─────────────────────────────────────────────────────── */
.chat-search-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  /* V8-float: плавающий овальный, по ширине как хедер (заменяет его при поиске) */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 800px;
  margin: 16px auto 0;
  flex-shrink: 0;
  z-index: 3;
}
body.dark .chat-search-bar { border-color: rgba(255,255,255,0.06); }
.chat-search-bar.hidden { display: none; }

.chat-search-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
  transition: border-color 0.15s;
}
.chat-search-input-wrap:focus-within { border-color: var(--primary); }

.chat-search-input-wrap svg { color: var(--muted); flex-shrink: 0; }

.chat-search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  color: var(--foreground);
  outline: none;
  font-family: inherit;
}
.chat-search-input::placeholder { color: var(--muted); }

.chat-search-count {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  min-width: 36px;
  text-align: right;
}

/* Highlight matched text in messages */
.search-hit {
  background: rgba(255, 200, 0, 0.4);
  border-radius: 2px;
}
.search-hit.current {
  background: rgba(255, 140, 0, 0.6);
}

/* ── Group manage modal sizing ─────────────────────────────────────────────── */
/* The group info panel is tall — give the modal more height and make it scroll */
#up-modal-inner > div[style*="overflow-y:auto"] {
  overflow-y: auto;
  max-height: calc(100vh - 120px);
}

/* gi-* elements inside modal need some extra space */
#up-modal .gi-card { margin-left: 0; margin-right: 0; }
#up-modal .info-panel-content { padding: 0; }

/* ── Link preview card in messages ──────────────────────────────────────────── */
.link-preview-slot { min-height: 0; }
.link-preview-card {
  display: block;
  margin-top: 6px;
  border-left: 3px solid var(--primary);
  border-radius: 0 8px 8px 0;
  padding: 6px 10px;
  background: rgba(10,132,255,0.07);
  text-decoration: none;
  transition: background 0.15s;
  overflow: hidden;
}
.link-preview-card:hover { background: rgba(10,132,255,0.13); }

/* Outgoing — light theme: dark-on-light-blue */
.message-row.outgoing .link-preview-card {
  border-left-color: var(--primary);
  background: rgba(0,0,0,0.07);
}
.message-row.outgoing .link-preview-card:hover { background: rgba(0,0,0,0.12); }

/* Outgoing — dark theme: white-on-dark-purple */
body.dark .message-row.outgoing .link-preview-card {
  border-left-color: rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.1);
}
body.dark .message-row.outgoing .link-preview-card:hover { background: rgba(255,255,255,0.18); }

.lp-site {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
/* Outgoing light — keep primary color (readable on light blue) */
.message-row.outgoing .lp-site { color: var(--primary); }
/* Outgoing dark — white tint */
body.dark .message-row.outgoing .lp-site { color: rgba(255,255,255,0.75); }

.lp-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--message-in-text, var(--foreground));
  line-height: 1.4;
  margin-bottom: 3px;
}
/* Outgoing light — dark text on light-blue bubble */
.message-row.outgoing .lp-title { color: var(--message-out-text); }
/* Outgoing dark — white */
body.dark .message-row.outgoing .lp-title { color: rgba(255,255,255,0.95); }

.lp-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}
/* Outgoing light — slightly muted but readable */
.message-row.outgoing .lp-desc { color: var(--message-out-text); opacity: 0.65; }
/* Outgoing dark — white muted */
body.dark .message-row.outgoing .lp-desc { color: rgba(255,255,255,0.65); opacity: 1; }

.lp-img {
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  border-radius: 6px;
  margin-top: 6px;
  display: block;
}

/* ── Group modal section titles ─────────────────────────────────────────────── */
.gm-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 0 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Wallpaper picker ─────────────────────────────────────────────────────── */
.wp-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.wp-thumb {
  position: relative;
  height: 90px;
  border-radius: 10px;
  cursor: pointer;
  overflow: hidden;
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.1s;
}
.wp-thumb:hover { transform: scale(1.03); }
.wp-thumb.active { border-color: var(--primary); }

/* ── Wallpaper z-index stacking ───────────────────────────────────────────────
   #chat-wallpaper-layer now lives inside #messages-container (position:relative).
   messages-list sits above it via z-index:1.
   header, input-area, reply-bar etc are siblings of messages-container inside
   .chat-area — they are naturally above the wallpaper since it's scoped inside
   the scroll container. No z-index tricks needed for those elements anymore.    */
.empty-state        { position: relative; z-index: 1; }
.chat-header        { position: relative; z-index: 10; }
.chat-search-bar    { position: relative; z-index: 5; }
.pinned-bar         { position: relative; z-index: 5; }
.reply-bar          { position: relative; z-index: 5; }
.message-input-area { position: relative; z-index: 5; }
.scroll-down-btn    { z-index: 6; }
.messages-list      { position: relative; z-index: 1; }

/* ═══════════════════════ SETTINGS MODAL ════════════════════════════════════ */
.smod-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 500;
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.22s ease;
}
.smod-overlay.smod-open { opacity: 1; }

.smod {
  position: fixed;
  top: 40px; left: 50%; transform: translateX(-50%) translateY(16px);
  width: min(900px, calc(100vw - 40px));
  height: calc(100vh - 80px);
  max-height: 700px;
  background: var(--surface);
  border-radius: 16px;
  z-index: 501;
  display: flex;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.35);
  opacity: 0;
  transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.34,1.26,0.64,1);
}
.smod.smod-open { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Left nav ── */
.smod-nav {
  width: 230px;
  min-width: 230px;
  background: var(--background);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

.smod-nav-profile {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.smod-nav-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; color: #fff;
  overflow: hidden; flex-shrink: 0;
}
.smod-nav-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.smod-nav-name { font-size: 14px; font-weight: 600; color: var(--foreground); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.smod-nav-sub  { font-size: 12px; color: var(--muted); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.smod-nav-items { padding: 8px 0 16px; flex: 1; }
.smod-nav-section {
  font-size: 10px; font-weight: 700;
  color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.7px;
  padding: 12px 18px 4px;
}
.smod-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  margin: 1px 8px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px; color: var(--foreground);
  border: none; background: none;
  text-align: left; width: calc(100% - 16px);
  transition: background 0.12s;
}
.smod-nav-item:hover { background: var(--hover); }
.smod-nav-item.active { background: var(--primary); color: #fff; }
.smod-nav-item.active .smod-ni-icon { color: #fff !important; background: rgba(255,255,255,0.2) !important; }
.smod-nav-item.danger { color: var(--error); }
.smod-ni-icon {
  width: 28px; height: 28px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.smod-nav-sep { height: 1px; background: var(--border); margin: 6px 10px; }

/* ── Right content ── */
.smod-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.smod-page-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.smod-page-title {
  font-size: 16px; font-weight: 700;
  color: var(--foreground); flex: 1;
}
.smod-close-btn {
  width: 30px; height: 30px; border-radius: 50%;
  border: none; background: var(--hover);
  color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.smod-close-btn:hover { background: var(--border); color: var(--foreground); }
.smod-page-body {
  flex: 1; overflow-y: auto; padding: 20px;
}

/* ── Settings cards (reuse s-card patterns) ── */
.sm-card {
  background: var(--background);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 8px;
  border: 1px solid var(--border);
}
.sm-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  min-height: 48px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}
.sm-row:last-child { border-bottom: none; }
.sm-row:hover { background: var(--hover); }
.sm-row.no-hover { cursor: default; }
.sm-row.no-hover:hover { background: transparent; }
.sm-icon {
  width: 30px; height: 30px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sm-label { flex: 1; font-size: 14px; color: var(--foreground); }
.sm-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.sm-value { font-size: 13px; color: var(--muted); }
.sm-hint { font-size: 12px; color: var(--muted); padding: 4px 4px 12px; line-height: 1.5; }

/* Toggle */
.sm-sw {
  width: 40px; height: 24px; border-radius: 12px;
  background: var(--border); position: relative;
  cursor: pointer; flex-shrink: 0;
  transition: background 0.2s;
}
.sm-sw.on { background: #34C759; }
.sm-sw::after {
  content: ''; position: absolute;
  width: 20px; height: 20px; border-radius: 10px;
  background: #fff; top: 2px; left: 2px;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.sm-sw.on::after { transform: translateX(16px); }

/* Input in card */
.sm-input {
  flex: 1; background: none; border: none; outline: none;
  font-size: 14px; color: var(--foreground); font-family: inherit;
}
.sm-input::placeholder { color: var(--muted); }
.sm-textarea {
  flex: 1; background: none; border: none; outline: none;
  font-size: 14px; color: var(--foreground); font-family: inherit;
  resize: none; min-height: 60px; line-height: 1.5;
}
.sm-textarea::placeholder { color: var(--muted); }

/* Avatar section */
.sm-avatar-section { display: flex; flex-direction: column; align-items: center; padding: 4px 0 16px; }
.sm-big-avatar {
  width: 80px; height: 80px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700; color: #fff;
  overflow: hidden; cursor: pointer; position: relative;
  transition: opacity 0.15s; margin-bottom: 8px;
}
.sm-big-avatar:hover { opacity: 0.85; }
.sm-big-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.sm-big-avatar-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,0.35);
  display: none; align-items: center; justify-content: center; border-radius: 50%;
}
.sm-big-avatar:hover .sm-big-avatar-overlay { display: flex; }
.sm-avatar-btn {
  background: none; border: none; color: var(--primary);
  font-size: 14px; font-weight: 500; cursor: pointer; font-family: inherit;
}
.sm-avatar-btn:hover { opacity: 0.8; }

/* Hero */
.sm-hero {
  height: 100px; border-radius: 12px; margin-bottom: 12px;
  position: relative; overflow: hidden;
  display: flex; align-items: flex-end; padding: 12px;
}
.sm-hero-name { font-size: 17px; font-weight: 700; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,0.4); }
.sm-hero-sub  { font-size: 12px; color: rgba(255,255,255,0.8); text-shadow: 0 1px 3px rgba(0,0,0,0.3); margin-top: 1px; }
.sm-hero-av {
  width: 52px; height: 52px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.85);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; color: #fff;
  overflow: hidden; margin-right: 12px; flex-shrink: 0;
}
.sm-hero-av img { width: 100%; height: 100%; object-fit: cover; }

/* Buttons */
.sm-save-btn {
  background: var(--primary); color: #fff;
  border: none; border-radius: 10px;
  padding: 11px 24px; font-size: 14px; font-weight: 600;
  cursor: pointer; width: 100%; font-family: inherit;
  margin-top: 4px; transition: opacity 0.15s;
}
.sm-save-btn:hover { opacity: 0.88; }
.sm-save-btn:disabled { opacity: 0.5; cursor: default; }
.sm-danger-btn {
  background: rgba(255,59,48,0.1); color: var(--error);
  border: none; border-radius: 10px;
  padding: 11px 24px; font-size: 14px; font-weight: 600;
  cursor: pointer; width: 100%; font-family: inherit;
  margin-top: 4px; transition: background 0.15s;
}
.sm-danger-btn:hover { background: rgba(255,59,48,0.18); }

/* Color grid */
.sm-color-grid { display: flex; flex-wrap: wrap; gap: 10px; padding: 12px 0 4px; }
.sm-color-swatch {
  width: 32px; height: 32px; border-radius: 50%;
  cursor: pointer; border: 3px solid transparent;
  transition: transform 0.15s, border-color 0.15s;
}
.sm-color-swatch:hover { transform: scale(1.1); }
.sm-color-swatch.selected { border-color: var(--foreground); transform: scale(1.1); }

/* Device card */
.sm-device {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-bottom: 1px solid var(--border);
}
.sm-device:last-child { border-bottom: none; }
.sm-device-icon {
  width: 38px; height: 38px; border-radius: 9px;
  background: var(--hover);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.sm-device-name  { font-size: 13px; font-weight: 600; color: var(--foreground); }
.sm-device-meta  { font-size: 11px; color: var(--muted); margin-top: 1px; }
.sm-device-cur   { font-size: 10px; color: #34C759; font-weight: 600; }
.sm-terminate {
  margin-left: auto; background: none; border: none;
  color: var(--error); font-size: 12px; cursor: pointer;
  padding: 4px 8px; border-radius: 6px; font-family: inherit;
}
.sm-terminate:hover { background: rgba(255,59,48,0.1); }

/* Privacy buttons */
.sm-privacy-btn {
  min-width: 70px; height: 24px; border-radius: 12px;
  background: var(--primary); color: #fff;
  border: none; cursor: pointer; font-size: 11px;
  font-weight: 600; font-family: inherit; padding: 0 8px;
  flex-shrink: 0;
}

/* Privacy picker */
.sm-privacy-opt {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; cursor: pointer; border-radius: 8px;
  transition: background 0.1s; margin: 2px 0;
}
.sm-privacy-opt:hover { background: var(--hover); }
.sm-privacy-dot {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.sm-privacy-opt.selected .sm-privacy-dot { border-color: var(--primary); background: var(--primary); }
.sm-privacy-opt.selected .sm-privacy-dot::after { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #fff; }

/* Language */
.sm-lang-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.1s;
}
.sm-lang-item:last-child { border-bottom: none; }
.sm-lang-item:hover { background: var(--hover); }

/* About */
.sm-about-icon {
  width: 70px; height: 70px; border-radius: 18px;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 800; color: #fff;
  margin: 0 auto 10px;
}

/* ── Wallpaper picker (inside settings) ─────────────────────────────────── */
.wp-preview {
  height: 180px;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  margin-bottom: 16px;
  display: flex; flex-direction: column;
  justify-content: flex-end;
  padding: 12px 16px;
  gap: 8px;
}
.wp-preview-msg-in {
  align-self: flex-start;
  padding: 8px 12px;
  border-radius: 14px 14px 14px 4px;
  font-size: 13px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  max-width: 60%;
}
.wp-preview-msg-out {
  align-self: flex-end;
  padding: 8px 12px;
  border-radius: 14px 14px 4px 14px;
  font-size: 13px;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  max-width: 60%;
}
.wp-preview-time { font-size: 10px; opacity: 0.65; margin-top: 2px; }

.wp-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.wp-tile {
  border-radius: 12px;
  border: 2px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
  position: relative;
}
.wp-tile:hover { transform: scale(1.02); }
.wp-tile.selected { border-color: var(--primary); }
.wp-tile-thumb {
  height: 90px;
  position: relative;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.wp-tile-thumb-img {
  position: absolute; inset: 0;
  background-repeat: repeat;
  background-size: 140px auto;
}
.wp-tile-label {
  font-size: 11px; font-weight: 500;
  color: var(--foreground);
  text-align: center;
  padding: 5px 4px 6px;
}
.wp-tile-check {
  position: absolute; top: 5px; right: 5px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
}

/* ═══════════════════════ AUTO-UPDATER BANNER ════════════════════════════════ */
.updater-banner {
  /* Фиксированное позиционирование — поверх всего интерфейса, не в сайдбаре */
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 340px;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  /* Непрозрачный фон — не зависит от содержимого под ним */
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0,0,0,0.22), 0 2px 8px rgba(0,0,0,0.14);
  transition: opacity 0.2s, transform 0.3s;
  flex-shrink: 0;
  overflow: hidden;
  /* Высокий z-index — поверх кнопки FAB и всего остального */
  z-index: 9000;
}
body.dark .updater-banner {
  background: #1c1c1e;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.3);
}

/* state colours */
.updater-available  { border-color: var(--primary); background: rgba(0,136,204,0.08); }
.updater-downloading{ border-color: var(--primary); background: rgba(0,136,204,0.06); }
.updater-ready      { border-color: #34C759;         background: rgba(52,199,89,0.08); }
.updater-error      { border-color: var(--error);    background: rgba(255,59,48,0.07); }
body.dark .updater-available   { background: rgba(0,136,204,0.15); }
body.dark .updater-downloading { background: rgba(0,136,204,0.12); }
body.dark .updater-ready       { background: rgba(52,199,89,0.14); }
body.dark .updater-error       { background: rgba(255,59,48,0.14); }

.upd-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.upd-icon.upd-ready { background: #34C759; }
.upd-icon.upd-error { background: var(--error); }

@keyframes upd-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.upd-icon.upd-spin svg { animation: upd-spin 1.2s linear infinite; }

.upd-text { flex: 1; min-width: 0; }
.upd-title {
  font-size: 12px; font-weight: 600;
  color: var(--foreground);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.upd-sub {
  font-size: 11px; color: var(--muted);
  margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.upd-btn {
  flex-shrink: 0;
  padding: 5px 11px;
  border-radius: 8px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
}
.upd-btn:hover { opacity: 0.85; }
.upd-btn-green { background: #34C759; }

.upd-dismiss {
  flex-shrink: 0;
  width: 22px; height: 22px;
  border: none; background: none;
  color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  transition: background 0.15s;
  padding: 0;
}
.upd-dismiss:hover { background: var(--hover); color: var(--foreground); }

/* download progress bar */
.upd-progress-wrap {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: rgba(0,136,204,0.15);
  border-radius: 0 0 12px 12px;
  overflow: hidden;
}
.upd-progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 0 0 12px 12px;
  transition: width 0.3s ease;
}

/* ── In-app уведомления (Telegram-style) ─────────────────────────────────── */
.inapp-notif {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 99999;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 300px;
  max-width: 380px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.12);
  cursor: pointer;
  transform: translateX(calc(100% + 24px));
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
  user-select: none;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.inapp-notif-visible {
  transform: translateX(0);
  opacity: 1;
}

.inapp-notif:hover {
  background: var(--hover);
  border-color: var(--primary);
}

.inapp-notif-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: -0.5px;
}

.inapp-notif-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.inapp-notif-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inapp-notif-sub {
  color: var(--muted);
  font-weight: 400;
}

.inapp-notif-body {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

.inapp-notif-close {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: var(--hover);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}

.inapp-notif:hover .inapp-notif-close {
  opacity: 1;
}

.inapp-notif-close:hover {
  background: var(--border);
  color: var(--foreground);
}




/* ── Медиа с подписью (фото/видео + текст) ───────────────────────────────── */
/* Пузырь: убираем верхний padding — картинка прилегает к краю пузыря */
.message-bubble.has-media-caption {
  padding-top: 0;
}

/* Картинка внутри такого пузыря занимает всю ширину без боковых отступов */
.message-bubble.has-media-caption .msg-img-wrap {
  /* Компенсируем боковые padding пузыря (12px каждая сторона) */
  margin-left: -12px;
  margin-right: -12px;
  /* Ширина на всю ширину пузыря */
  max-width: calc(100% + 24px);
  /* Скругление совпадает с пузырём сверху */
  border-radius: 12px 12px 0 0;
}

/* Отступ между картинкой и текстом подписи */
.message-bubble.has-media-caption .msg-img-wrap + .message-text {
  margin-top: 6px;
}

/* img/video внутри — скругление только сверху */
.message-bubble.has-media-caption .msg-img {
  border-radius: 12px 12px 0 0;
}

/* Для исходящих — правый верхний угол совпадает с bubble tail (4px) */
.message-row.outgoing .message-bubble.has-media-caption .msg-img-wrap {
  border-radius: 12px 4px 0 0;
}
.message-row.outgoing .message-bubble.has-media-caption .msg-img {
  border-radius: 12px 4px 0 0;
}

/* Для входящих — левый верхний угол совпадает с bubble tail (4px) */
.message-row.incoming .message-bubble.has-media-caption .msg-img-wrap {
  border-radius: 4px 12px 0 0;
}
.message-row.incoming .message-bubble.has-media-caption .msg-img {
  border-radius: 4px 12px 0 0;
}

/* ════════════════════════════════════════════════════════════════════════════
   НЕЙРООТВЕТЧИК — стили для десктопной версии
   ════════════════════════════════════════════════════════════════════════════ */

/* Settings toggle switch (переиспользуем sm-sw из существующего) */
.sm-sw {
  width: 40px; height: 22px;
  background: var(--border);
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.sm-sw::after {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  top: 2px; left: 2px;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.sm-sw.on { background: #34C759; }
.sm-sw.on::after { transform: translateX(18px); }

/* Neuro tab content scrollable area */
#neuro-tab-content {
  max-height: calc(100vh - 320px);
  overflow-y: auto;
  padding-right: 2px;
}
#neuro-tab-content::-webkit-scrollbar { width: 4px; }
#neuro-tab-content::-webkit-scrollbar-track { background: transparent; }
#neuro-tab-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Neuro test messages scrollbar */
#neuro-test-msgs::-webkit-scrollbar { width: 4px; }
#neuro-test-msgs::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Typing dots animation (reuse from existing if available) */
.typing-dots span {
  display: inline-block;
  width: 5px; height: 5px;
  background: var(--muted);
  border-radius: 50%;
  margin: 0 1.5px;
  animation: typingBounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%            { transform: translateY(-4px); opacity: 1; }
}

/* Neuro tab buttons hover state */
#neuro-tabs button:hover {
  opacity: 0.85;
}

/* Neuro test input focus */
#neuro-test-input:focus {
  border-color: #5856D6;
  outline: none;
}

/* Settings neuro page inputs */
#neuro-tab-content input[type="text"],
#neuro-tab-content input[type="number"],
#neuro-tab-content textarea {
  outline: none;
  transition: border-color 0.15s;
}
#neuro-tab-content input[type="text"]:focus,
#neuro-tab-content input[type="number"]:focus,
#neuro-tab-content textarea:focus {
  border-color: #5856D6 !important;
}

/* Neuro nav badge */
#neuro-nav-badge {
  transition: background 0.2s, color 0.2s;
}

/* ── Sidebar resize handle ── */
.sidebar-resizer {
  width: 5px;
  height: 100vh;
  cursor: col-resize;
  flex-shrink: 0;
  background: transparent;
  position: relative;
  z-index: 10;
  transition: background 0.15s;
  margin-left: -1px;
}
.sidebar-resizer:hover,
.sidebar-resizer.dragging {
  background: var(--primary);
  opacity: 0.5;
}

/* ── Browser panel ── */
#browser-panel {
  flex: 1;
  display: none;
  flex-direction: column;
  overflow: hidden;
  background: var(--background);
}
#browser-panel.visible {
  display: flex;
}
