/* Цветовая палитра: глубокий темный и яркий фиолетовый */
:root {
  --bg-dark: #09090b;
  --bg-card: rgba(24, 24, 27, 0.7);
  --accent: #8b5cf6;
  --accent-light: #a78bfa;
  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --danger: #ef4444;
  --glass: rgba(24, 24, 27, 0.6);
  --glass-border: rgba(255, 255, 255, 0.08);
  --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* Фон с градиентом и размытием */
.bg-mesh {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  background: 
    radial-gradient(circle at 10% 10%, rgba(139, 92, 246, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 90% 90%, rgba(139, 92, 246, 0.15) 0%, transparent 50%),
    var(--bg-dark);
  filter: blur(80px);
}

/* Скрытые элементы */
.hidden {
  display: none !important;
}

/* Splash Screen */
#splash-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg-dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.8s ease, visibility 0.8s ease;
}

#splash-screen.fade-out {
  opacity: 0;
  visibility: hidden;
}

.splash-logo {
  width: 80px;
  height: 80px;
  margin-bottom: 24px;
  filter: drop-shadow(0 0 15px var(--accent));
  animation: pulse 2s infinite ease-in-out;
}

.loader {
  width: 140px;
  height: 3px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.loader-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 40%;
  background: var(--accent);
  border-radius: 10px;
  animation: loading 1.5s infinite ease-in-out;
}

@keyframes loading {
  0% { left: -40%; }
  100% { left: 100%; }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 15px var(--accent)); }
  50% { transform: scale(1.05); filter: drop-shadow(0 0 25px var(--accent)); }
}

/* Welcome Screen */
.welcome-container {
  max-width: 480px;
  width: 100%;
  margin: auto;
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  gap: 48px;
  animation: fadeIn 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.welcome-header {
  text-align: center;
}

.welcome-header .logo-wrapper {
  width: 88px;
  height: 88px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(139, 92, 246, 0.2));
  border: 1px solid rgba(139, 92, 246, 0.3);
  box-shadow: 0 0 30px rgba(139, 92, 246, 0.15);
  border-radius: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  color: var(--accent);
}

.welcome-header .app-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 12px;
  background: linear-gradient(180deg, #fff 0%, #a1a1aa 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.welcome-header .muted {
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.mode-selection {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.mode-card {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 24px;
  border-radius: 24px;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.mode-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(139, 92, 246, 0.05), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.mode-card:hover {
  transform: translateY(-4px);
  border-color: rgba(139, 92, 246, 0.4);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.mode-card:hover::before {
  opacity: 1;
}

.mode-icon {
  width: 56px;
  height: 56px;
  background: rgba(139, 92, 246, 0.1);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.mode-card:hover .mode-icon {
  transform: scale(1.1) rotate(-5deg);
  background: rgba(139, 92, 246, 0.2);
}

.mode-content {
  flex: 1;
}

.mode-title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.mode-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.mode-arrow {
  color: var(--text-secondary);
  opacity: 0.3;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.mode-card:hover .mode-arrow {
  opacity: 1;
  transform: translateX(4px);
  color: var(--accent);
}

.welcome-footer {
  text-align: center;
}

.security-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 100px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
}

.security-badge svg {
  color: #22c55e;
}

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

/* Glassmorphism */
.glass {
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
}

/* Основные контейнеры */
.view {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  overflow-y: auto;
  scrollbar-width: none;
}

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

.view::-webkit-scrollbar {
  display: none;
}

/* About Section Styles */
.about-container {
  gap: 32px;
  padding-top: 20px;
}

.about-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 40px;
}

.about-card {
  display: flex;
  gap: 16px;
  padding: 20px;
  border-radius: 20px;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  transition: var(--transition);
}

.about-card:hover {
  border-color: rgba(139, 92, 246, 0.3);
  transform: translateY(-2px);
  background: rgba(139, 92, 246, 0.05);
}

.card-icon {
  font-size: 24px;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(139, 92, 246, 0.1);
  border-radius: 14px;
}

.card-info h3 {
  margin: 0 0 6px 0;
  font-size: 17px;
  color: var(--text-primary);
}

.card-info p {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 14px;
}

.btn-sm svg {
  margin-right: 8px;
}

.welcome-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* Градиентный фон для чата */
#chat-view {
  background:
    radial-gradient(1200px circle at 110% -10%, rgba(139, 92, 246, 0.24) 0%, transparent 46%),
    radial-gradient(900px circle at -10% 110%, rgba(139, 92, 246, 0.20) 0%, transparent 50%),
    linear-gradient(180deg, rgba(139, 92, 246, 0.12) 0%, rgba(9, 9, 11, 0.82) 35%, rgba(9, 9, 11, 1) 100%);
}

.main-action-btn {
  background: var(--accent) !important;
  border: none !important;
  height: 56px;
  font-size: 16px !important;
  font-weight: 700 !important;
  border-radius: 16px !important;
  box-shadow: 0 12px 30px rgba(139, 92, 246, 0.4) !important;
  transition: var(--transition) !important;
}

.main-action-btn:hover {
  background: var(--accent-light) !important;
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 18px 40px rgba(139, 92, 246, 0.5) !important;
}

.main-action-btn:active {
  transform: translateY(-1px) scale(0.98);
}

.muted {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
}

/* Кнопки */
.btn {
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
}

.btn.primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 4px 14px 0 rgba(139, 92, 246, 0.3);
}

.btn.primary:hover {
  background: var(--accent-light);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border-color: var(--glass-border);
}

.btn.ghost:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn.danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.2);
}

.btn.danger:hover {
  background: var(--danger);
  color: white;
}

.btn.icon {
  padding: 8px 10px;
  min-width: 0;
}

.btn[disabled],
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

/* Шапка чата */
.topbar {
  padding: 16px 24px;
  padding-top: calc(16px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--glass-border);
}

.topbar .left, .topbar .right {
  display: flex;
  align-items: center;
  gap: 16px;
}

#call-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  padding: 0;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: .55;
  filter: grayscale(0.35);
  visibility: visible;
  pointer-events: auto;
  transition: opacity .18s ease, filter .18s ease;
}
#call-btn.available {
  opacity: 1;
  filter: none;
}

#call-btn.calling {
  position: relative;
  box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.5);
  animation: callPulse 1.4s infinite;
}
@keyframes callPulse {
  0% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4); transform: translateY(0) scale(1); }
  70% { box-shadow: 0 0 0 12px rgba(139, 92, 246, 0); transform: translateY(-1px) scale(1.02); }
  100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0); transform: translateY(0) scale(1); }
}

.room-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.room-name {
  font-weight: 700;
  font-size: 16px;
  line-height: 1.2;
}

.room-code-badge {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
  padding: 2px 6px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', 'Roboto Mono', monospace;
  font-size: 10px;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  width: fit-content;
}

.room-code-badge.hidden {
  display: none;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  margin-top: 4px;
}

.status-indicator.online {
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e;
}

/* Сообщения */
.messages {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none; /* Firefox */
}

.empty-state {
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
  max-width: 280px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .4s ease, transform .4s ease;
  z-index: 1;
}

.empty-state.show {
  opacity: 1;
  pointer-events: auto;
}

.empty-state-icon {
  margin-bottom: 24px;
  color: var(--accent);
  opacity: 0.3;
  animation: pulse-logo 4s ease-in-out infinite;
}

.empty-state p {
  font-size: 19px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  opacity: 0.85;
}

.empty-state span {
  font-size: 14px;
  color: var(--text-secondary);
  opacity: 0.6;
}

@keyframes pulse-logo {
  0%, 100% { transform: scale(1); opacity: 0.25; }
  50% { transform: scale(1.08); opacity: 0.4; }
}

.messages::-webkit-scrollbar {
  display: none; /* Chrome, Safari */
}

.selection-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  margin-bottom: 8px;
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
}
.selection-bar.show {
  display: flex;
}
.selection-bar .sel-info {
  font-weight: 700;
  color: var(--text-primary);
}
.selection-bar .sel-label {
  margin-left: 6px;
  margin-right: 6px;
  font-weight: 600;
  color: var(--text-secondary);
}
.selection-bar .sel-count {
  font-weight: 800;
  color: var(--text-primary);
}
.selection-bar .sel-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 12px;
  box-shadow: 0 6px 18px rgba(139, 92, 246, 0.35);
}
.selection-bar .sel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 900px) {
  .selection-bar {
    padding: 9px 12px;
    gap: 10px;
    border-radius: 12px;
  }
  .selection-bar .sel-info {
    font-size: 14px;
  }
  .selection-bar .btn {
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 14px;
  }
}

@media (max-width: 600px) {
  .selection-bar {
    padding: 8px 10px;
    gap: 8px;
    border-radius: 10px;
  }
  .selection-bar .sel-label {
    display: none;
  }
  .selection-bar .sel-info {
    font-size: 13px;
  }
  .selection-bar .sel-mark {
    width: 16px;
    height: 16px;
    font-size: 11px;
  }
  .selection-bar .btn {
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 13px;
  }
}

.msg {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.4;
  position: relative;
  animation: msgPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.msg.selected {
  box-shadow: 0 0 0 2px var(--accent), 0 6px 20px rgba(139, 92, 246, 0.2);
}
.msg .sel-check {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-weight: 800;
  font-size: 12px;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-dark);
  box-shadow: 0 6px 18px rgba(139, 92, 246, 0.35);
  transform: scale(0.9);
  transition: transform .18s ease, opacity .18s ease;
}
.msg.selected .sel-check {
  display: inline-flex;
  transform: scale(1);
}

@keyframes msgPop {
  from { opacity: 0; transform: scale(0.9) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.msg-in {
  align-self: flex-start;
  background: var(--bg-card);
  border-radius: 18px;
}

.msg-out {
  align-self: flex-end;
  background: var(--accent);
  color: white;
  border-radius: 18px;
}

.reply {
  display: block;
  padding: 6px 10px;
  margin-bottom: 8px;
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}
.msg-out .reply {
  background: rgba(255, 255, 255, 0.18);
  border-left-color: rgba(255, 255, 255, 0.9);
}
.reply-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-light);
  margin-bottom: 2px;
}
.msg-out .reply-name {
  color: rgba(255, 255, 255, 0.9);
}
.reply-text {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-out .reply-text {
  color: rgba(255, 255, 255, 0.92);
}

.msg.flash-highlight {
  animation: msgFlash .8s ease;
}
@keyframes msgFlash {
  0% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.0); transform: translateY(0) scale(1); }
  30% { box-shadow: 0 0 0 6px rgba(139, 92, 246, 0.25); transform: translateY(-1px) scale(1.01); }
  60% { box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18); transform: translateY(0) scale(1); }
  100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.0); }
}

.msg-img {
  padding: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
}

.msg-img img {
  max-width: 320px;
  border-radius: 12px;
  display: block;
  cursor: zoom-in;
}

.msg-img .caption {
  margin-top: 6px;
  font-size: 13px;
  opacity: 0.85;
}

.msg-name {
  font-size: 10px;
  font-weight: 700;
  display: block;
  margin-bottom: 4px;
}

.msg-in .msg-name {
  color: var(--accent-light);
}

.msg-out .msg-name {
  color: rgba(255, 255, 255, 0.8);
}

.msg-sys {
  align-self: center;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.msg .msg-body {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 8px;
}
.msg .msg-text {
  min-width: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.msg .meta {
  margin-left: 4px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  opacity: 0.85;
}
.msg .time {
  font-size: 10px;
  opacity: 0.75;
  line-height: 1;
}
.msg .edited {
  font-size: 10px;
  opacity: 0.75;
  line-height: 1;
}
.msg-out .meta { opacity: 0.85; }
.ticks {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  width: 24px;
  height: 16px;
  color: rgba(255, 255, 255, 0.98);
}
.ticks svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 16px;
  height: 16px;
  opacity: 0;
  transition: opacity .18s ease;
}
.ticks .tick2 {
  left: 6px;
  top: -1px;
}
.msg-out .ticks .tick1 { opacity: 1; }
.msg-out.status-read .ticks .tick2 { opacity: 1; }
.msg-in .ticks { display: none; }

.msg-img .meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 6px;
}

/* Upload placeholder with progress */
.upload-placeholder {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
}
.upload-progress {
  position: relative;
  width: 180px;
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  overflow: hidden;
}
.msg-in .upload-progress { background: rgba(0,0,0,0.08); }
.upload-progress .bar {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, var(--accent) 0%, #7c3aed 100%);
  border-radius: 6px;
  transition: width .18s ease;
}
.upload-label {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.msg-file .file-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.msg-file .file-card {
  min-width: 0;
  flex: 1;
  display: grid;
  grid-template-columns: 32px 1fr;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
}
.msg-in.msg-file .file-card {
  background: rgba(0,0,0,0.06);
}
.msg-file .file-icon {
  width: 28px;
  height: 34px;
  color: var(--accent);
}
.msg-file .file-icon text {
  fill: #fff;
  font-weight: 700;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}
.msg-file .file-name {
  font-size: 14px;
  line-height: 1.2;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-file .file-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: auto;
  white-space: nowrap;
}
.msg-file .file-link {
  text-decoration: none;
  color: inherit;
}
.file-icon.pdf { color: #ef4444; }
.file-icon.doc, .file-icon.docx { color: #3b82f6; }
.file-icon.xls, .file-icon.xlsx { color: #10b981; }
.file-icon.ppt, .file-icon.pptx { color: #f59e0b; }
.file-icon.zip, .file-icon.rar, .file-icon\.7z { color: #f59e0b; }
.file-icon.txt, .file-icon.md { color: #9ca3af; }
.file-icon.audio { color: #8b5cf6; }
.file-icon.video { color: #14b8a6; }
.file-icon.code { color: #06b6d4; }

/* Voice message */
.msg-voice .voice-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.msg-voice .voice-play {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.msg-in.msg-voice .voice-play {
  background: rgba(0,0,0,0.06);
  border-color: rgba(0,0,0,0.1);
  color: var(--text-primary);
}
.msg-voice .voice-track {
  width: 200px;
  height: 22px;
  background: transparent;
  border-radius: 6px;
  position: relative;
  overflow: hidden;
}
.msg-voice .voice-peaks {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(48, 1fr);
  align-items: center;
  gap: 1px;
  z-index: 1;
  opacity: 0.9;
}
.msg-voice .voice-peak {
  width: 100%;
  height: 20%;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 1px;
  transform-origin: center;
  transition: opacity 0.18s linear, background-color 0.18s linear;
}
.msg-voice .voice-peak.played {
  background: rgba(255, 255, 255, 0.98);
}
.msg-in.msg-voice .voice-peak {
  background: rgba(255, 255, 255, 0.38);
}
.msg-in.msg-voice .voice-peak.played {
  background: rgba(255, 255, 255, 0.95);
}
.msg-in.msg-voice.playing .voice-peak.played {
  background: var(--accent);
}
.msg-voice .voice-prog {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0%;
  background: transparent;
  opacity: 0;
  z-index: 2;
}
.msg-in.msg-voice .voice-prog { opacity: 0; }
.msg-voice .voice-time {
  font-size: 12px;
  opacity: 0.9;
  white-space: nowrap;
}

/* Larger play/stop on mobile for better tap targets */
@media (max-width: 600px), (hover: none) and (pointer: coarse) {
  .msg-voice .voice-play {
    width: 40px;
    height: 40px;
  }
  .msg-voice .voice-play svg {
    width: 22px;
    height: 22px;
  }
  .msg-voice .voice-track {
    width: 180px;
  }
}

/* Unheard indicator for voice */
.msg-voice .voice-unheard {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: none;
}
.msg-voice.unheard .voice-unheard {
  display: inline-block;
}
.msg-in.msg-voice .voice-unheard {
  background: var(--accent);
}

/* Нижняя панель */
.bottombar {
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--glass-border);
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.input-wrap {
  flex: 1;
  position: relative;
}

.reply-preview {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  padding: 6px 10px;
  margin-bottom: 0;
  box-sizing: border-box;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity .18s ease, transform .18s ease;
}
.reply-preview.show {
  opacity: 1;
  transform: translateY(0);
}
.reply-preview.hide {
  opacity: 0;
  transform: translateY(-6px);
}
.reply-preview-text {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reply-preview-close {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-primary);
  border-radius: 8px;
  cursor: pointer;
  transition: background-color .2s ease, color .2s ease, transform .2s ease, box-shadow .2s ease;
}
.reply-preview-close svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.reply-preview-close:hover {
  background: rgba(139, 92, 246, 0.16);
  color: #fff;
  box-shadow: 0 6px 16px rgba(139, 92, 246, 0.25);
}
.reply-preview-close:active {
  transform: scale(0.96);
  background: rgba(139, 92, 246, 0.22);
  color: #fff;
}

.input {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 16px;
  color: white;
  outline: none;
  transition: var(--transition);
}

.input.has-prefix {
  padding-left: 44px;
}

.input.has-suffix {
  padding-right: 48px;
}

.input:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
}

.topbar .online-count {
  font-size: 12px;
  font-weight: 600;
}

#open-profile-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  padding: 0;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.input-suffix {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: block;
  width: 32px;
  height: 32px;
  pointer-events: none;
}
.input-suffix .btn {
  width: 32px;
  height: 32px;
  min-width: 0;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  box-shadow: none;
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: auto;
  transition: transform .22s ease, opacity .22s ease, background-color .2s ease, color .2s ease, box-shadow .2s ease;
}
.input-suffix #send-btn {
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
  z-index: 2;
}
.input-suffix #voice-btn {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
  z-index: 3;
}
.input-wrap.has-text .input-suffix #send-btn {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}
.input-wrap.has-text .input-suffix #voice-btn {
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
}
.input-suffix #send-btn {
  padding: 0;
}
.input-suffix .btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.1);
}
.input-suffix .btn:focus-visible {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.15);
}
.input-suffix .btn svg {
  width: 18px;
  height: 18px;
  opacity: 0.92;
  transition: transform .24s ease, opacity .24s ease;
}
.input-suffix .btn:hover svg {
  transform: scale(1.05);
  opacity: 1;
}

.input-wrap.has-text .input-suffix #send-btn {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}
.input-wrap.has-text .input-suffix #send-btn:hover {
  background: var(--accent-light);
  box-shadow: 0 6px 16px rgba(139, 92, 246, 0.4);
}
.input-wrap.has-text .input-suffix #send-btn[disabled] {
  opacity: 0.75;
  cursor: not-allowed;
}

.input-icon {
  position: absolute;
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 8px;
  opacity: 0.9;
  transition: background-color .25s ease, color .25s ease, box-shadow .25s ease, opacity .25s ease, transform .2s ease;
}

.input-icon:hover {
  color: var(--text-primary);
  background: rgba(139, 92, 246, 0.16);
  box-shadow: 0 6px 16px rgba(139, 92, 246, 0.2);
  opacity: 1;
}

.input-icon:focus-visible {
  color: var(--text-primary);
  background: rgba(139, 92, 246, 0.2);
  box-shadow: 0 6px 18px rgba(139, 92, 246, 0.25);
}

.input-icon:active {
  transform: translateY(-50%) scale(0.96);
}

.input-icon svg {
  transition: transform .24s ease, opacity .24s ease;
  opacity: 0.92;
}

.input-icon:hover svg {
  transform: translateY(-1px) scale(1.02);
  opacity: 1;
}
@media (max-width: 900px) {
  .bottombar {
    gap: 10px;
  }
  .input.has-prefix {
    padding-left: 44px;
  }
}

@media (max-width: 600px) {
  .bottombar {
    gap: 8px;
  }
  .input.has-prefix {
    padding-left: 60px;
  }
  .input.has-suffix {
    padding-right: 112px;
  }
  .input-suffix {
    width: 44px;
    height: 44px;
  }
  .input-suffix .btn {
    width: 44px;
    height: 44px;
  }
  .input-suffix .btn svg {
    width: 22px;
    height: 22px;
  }
  #attach-img-btn {
    width: 44px;
    height: 44px;
    left: 10px;
  }
  #attach-img-btn svg {
    width: 22px;
    height: 22px;
  }
}

#typing-indicator {
  padding: 0 24px 8px;
  font-size: 12px;
  color: var(--accent-light);
}

#send-btn {
  padding: 10px;
  border-radius: 12px;
}

#voice-btn { position: relative; }
#voice-btn.recording {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.3);
  color: #ef4444;
}
#voice-btn.locked {
  background: rgba(139, 92, 246, 0.16);
  border-color: rgba(139, 92, 246, 0.35);
  color: var(--accent);
}

#voice-btn .rec-viz {
  position: absolute;
  inset: 6px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  align-items: end;
  gap: 2px;
  pointer-events: none;
}
#voice-btn .rec-viz .bar {
  width: 100%;
  height: 3px;
  background: currentColor;
  border-radius: 1px;
  transform-origin: bottom;
  transform: scaleY(0.2);
  transition: transform 80ms linear;
}

#voice-btn .rec-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity .12s ease, transform .12s ease;
  color: #ef4444;
}
#voice-btn.cancelling .rec-hint {
  opacity: 1;
  transform: scale(1);
}

.rec-tips {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%) translateY(4px);
  font-size: 11px;
  line-height: 1;
  color: var(--text-secondary);
  background: rgba(0,0,0,0.5);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 6px 8px;
  white-space: normal;
  text-align: center;
  max-width: min(280px, calc(100vw - 24px));
  opacity: 0;
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none;
}
.rec-tips.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
@media (hover: hover) and (pointer: fine) {
  .rec-tips { display: none; }
}

/* Профиль пользователя */
#profile-view {
  position: fixed;
  top: 0;
  right: -100%;
  width: 350px;
  height: calc(var(--app-vh, 1vh) * 100);
  z-index: 1000;
  transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  scrollbar-width: none;
}
#profile-view::-webkit-scrollbar {
  display: none;
}

#profile-view.active {
  right: 0;
}

.profile-content {
  height: 100%;
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Персонализация: отдельный сайдбар */
#personalize-view {
  position: fixed;
  top: 0;
  right: -100%;
  width: 350px;
  height: calc(var(--app-vh, 1vh) * 100);
  z-index: 1000;
  transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  scrollbar-width: none;
}
#personalize-view::-webkit-scrollbar {
  display: none;
}
#personalize-view.active {
  right: 0;
}
.verify-content {
  height: 100%;
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#verify-view {
  position: fixed;
  top: 0;
  right: -100%;
  width: 350px;
  height: calc(var(--app-vh, 1vh) * 100);
  z-index: 1000;
  transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  scrollbar-width: none;
}
#verify-view::-webkit-scrollbar {
  display: none;
}
#verify-view.active {
  right: 0;
}
.personalize-content {
  height: 100%;
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.personalize-content .profile-name {
  align-self: center;
}
.personalize-content .section-actions .btn {
  width: 100%;
}

#close-profile-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 6px;
  border-radius: 50%;
}

.profile-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  margin-bottom: 20px;
  box-shadow: 0 10px 25px rgba(139, 92, 246, 0.3);
}

.profile-name {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.profile-status {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.profile-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Раздел «Персонализация» */
.profile-section {
  width: 100%;
  margin-top: 8px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
}
.section-title {
  margin: 0 0 10px 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .6px;
}
.section-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.section-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
}
.verify-section .section-actions .btn {
  width: 100%;
  justify-content: center;
}

#encryption-status {
  background: rgba(255, 255, 255, 0.03);
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--glass-border);
  transition: var(--transition);
}

#encryption-status .encryption-title {
  margin: 0 0 8px 0;
  font-size: 12px;
  color: var(--text-secondary);
}

#encryption-label {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

#encryption-label.active {
  color: #22c55e;
}

#lock-icon {
  filter: none;
  transition: var(--transition);
}

#encryption-label.active #lock-icon {
  filter: drop-shadow(0 0 4px #22c55e);
}

#encryption-label.danger {
  color: #ef4444;
}
#encryption-label.danger #lock-icon {
  filter: drop-shadow(0 0 4px #ef4444);
}

#change-name-btn,
#leave-room-btn {
  justify-content: center;
}

#leave-room-btn {
  color: var(--danger);
}

/* Новые действия в профиле */
#clear-btn {
  color: var(--danger);
}

#copy-invite-btn {
  color: var(--text-primary);
}

.profile-actions .btn {
  width: 100%;
  justify-content: center;
  text-align: center;
}

/* Кастомное модальное окно */
#modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

#modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

#modal-content {
  max-width: 400px;
  width: 100%;
  padding: 32px;
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#modal-content.is-image {
  max-width: min(92vw, 1000px);
  max-height: 88vh;
  width: auto;
  padding: 16px;
}

#modal-overlay.active #modal-content {
  transform: scale(1) translateY(0);
}

#modal-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

#modal-description {
  margin: 0;
  font-size: 14px;
}

#modal-media {
  margin: 10px 0 6px;
}
#modal-content.is-image #modal-media {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  place-items: center;
}

#modal-media img {
  max-width: 100%;
  max-height: 50vh;
  border-radius: 12px;
  display: block;
}

#modal-content.is-image #modal-media img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

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

.modal-actions .btn {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .modal-actions {
    flex-direction: column-reverse;
  }
  .modal-actions .btn {
    width: 100%;
    flex: none;
  }
}


/* Выбор режима записи (в модальном окне) */
.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 480px) {
  .choice-grid {
    grid-template-columns: 1fr;
  }
}
.choice-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  border-radius: 12px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  cursor: pointer;
  transition: background-color .18s ease, transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.choice-card:hover {
  background: rgba(139, 92, 246, 0.12);
  box-shadow: 0 6px 16px rgba(139, 92, 246, 0.25);
}
.choice-card.selected {
  border-color: var(--accent);
  box-shadow: 0 6px 16px rgba(139, 92, 246, 0.25);
}
.choice-title {
  font-weight: 700;
  color: var(--text-primary);
}
.choice-desc {
  font-size: 13px;
  color: var(--text-secondary);
}
.choice-check {
  align-self: flex-end;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 2px solid var(--glass-border);
  color: var(--text-secondary);
}
.choice-card.selected .choice-check {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}
@media (max-width: 600px) {
  .choice-grid {
    grid-template-columns: 1fr;
  }
}

/* Call Overlay */
#call-overlay {
  position: fixed;
  inset: 0;
  z-index: 10050;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
#call-overlay.active {
  opacity: 1;
  visibility: visible;
}
#call-card {
  max-width: 420px;
  width: 100%;
  padding: 28px;
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.call-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed, #22d3ee);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 36px;
  position: relative;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  --speak: 0;
}
.call-avatar::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  box-shadow: 0 0 calc(18px * var(--speak)) rgba(139, 92, 246, 0.6), 0 0 calc(36px * var(--speak)) rgba(34, 211, 238, 0.25);
  opacity: calc(var(--speak));
  transform: scale(calc(0.9 + 0.25 * var(--speak)));
  transition: opacity .28s ease-out, transform .28s ease-out, box-shadow .28s ease-out;
}
.call-avatar::before {
  content: "";
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  border: 2px solid rgba(34, 211, 238, 0.45);
  opacity: calc(var(--speak) * .7);
  transform: scale(calc(0.84 + 0.44 * var(--speak)));
  transition: opacity .36s ease-out, transform .36s ease-out;
}
.call-name {
  font-size: 20px;
  font-weight: 600;
}
.call-status {
  font-size: 14px;
  color: var(--muted-foreground);
}
.call-eq {
  width: 100%;
  height: 36px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  align-items: end;
  gap: 6px;
  padding: 6px 2px 0;
  filter: saturate(1.2);
  animation: eqGlow 3.6s ease-in-out infinite alternate;
}
.call-eq .bar {
  width: 100%;
  height: 6px;
  background: linear-gradient(180deg, #22d3ee 0%, #7c3aed 100%);
  border-radius: 3px;
  transform-origin: bottom;
  transform: scaleY(0.1);
  transition: transform 120ms linear;
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.35);
}
@keyframes eqGlow {
  0% { filter: saturate(1) brightness(1); }
  100% { filter: saturate(1.25) brightness(1.08); }
}
.call-actions {
  margin-top: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
}
.call-actions .btn {
  width: 100%;
}
.btn.ghost.toggled {
  background: var(--glass-bg);
  border-color: var(--accent);
  color: var(--accent);
}

.call-participants {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 8px;
}
.call-participant {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
}
.call-participant .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, #7c3aed, #22d3ee);
  transition: transform .18s ease;
}
.call-participant.speaking .avatar {
  transform: scale(1.06);
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.45);
}
.call-participant .name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.call-participant .status {
  font-size: 12px;
  color: var(--text-secondary);
}
.call-count {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
}

.speaking-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  font-size: 10px;
  letter-spacing: .3px;
}
.speaking-badge.hidden {
  display: none;
}
.speaking-badge svg {
  width: 12px;
  height: 12px;
}

@media (max-width: 600px) {
  #modal-content.is-image {
    max-width: 96vw;
    max-height: 88vh;
    padding: 12px;
  }
  #modal-content.is-image #modal-media img {
    max-height: 100%;
  }
}

#modal-input-container {
  margin: 4px 0;
}
#modal-input.input.error {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.08);
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.15);
}
#modal-description.error {
  color: var(--danger);
}
@keyframes inputShake {
  0% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
  100% { transform: translateX(0); }
}
#modal-input.shake {
  animation: inputShake 0.28s ease;
}

#modal-alt-btn {
  display: inline-flex;
}

/* Удалённые сообщения (модалка) */
.deleted-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  width: 100%;
  justify-items: center;
}
.deleted-item {
  width: 100%;
  max-width: 440px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  justify-items: center;
  gap: 8px;
}
.deleted-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: .6px;
}
.deleted-sub {
  font-size: 12px;
  color: var(--text-secondary);
  opacity: .8;
}
.deleted-preview {
  width: 100%;
  max-width: 420px;
  text-align: left;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  opacity: .9;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.deleted-preview .deleted-thumb {
  display: block;
  width: 160px;
  height: 120px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 6px 16px rgba(0,0,0,0.35);
  border: 1px solid var(--glass-border);
}
.deleted-preview .deleted-cap {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}
.deleted-preview .deleted-file-name {
  font-weight: 700;
  color: var(--text-primary);
}
.deleted-preview .deleted-file-size {
  margin-left: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}
.deleted-item .btn {
  min-width: 160px;
}

/* Метка «восстановлено» в метаданных сообщения */
.msg .meta .restored {
  font-size: 10px;
  opacity: .75;
}
.msg .meta .restorer {
  font-size: 10px;
  opacity: .65;
}

/* Панель действий в модалке удалённых */
.deleted-toolbar {
  width: 100%;
  max-width: 440px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  justify-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.deleted-count {
  font-size: 12px;
  color: var(--text-secondary);
  opacity: .85;
  justify-self: start;
}
.deleted-item.selected {
  border-color: var(--accent);
  box-shadow: 0 6px 18px rgba(139,92,246,.25);
}
.btn.sm {
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
}
.deleted-confirm {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 0;
}

/* Toasts */
#toast-container {
  position: fixed;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 11000;
  pointer-events: none;
}

#toast-container.pos-bottom-right {
  right: 24px;
  bottom: calc(24px + env(safe-area-inset-bottom));
  align-items: flex-end;
}

#toast-container.pos-bottom-center {
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  align-items: center;
}

#toast-container.pos-top-center {
  left: 50%;
  top: calc(24px + env(safe-area-inset-top));
  transform: translateX(-50%);
  align-items: center;
}

.toast {
  min-width: 220px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--accent);
  border: 1px solid rgba(0, 0, 0, 0.5);
  color: #fff;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  transform: translateY(12px) scale(0.98);
  opacity: 0;
  transition: transform .38s cubic-bezier(0.22, 1, 0.36, 1), opacity .38s ease;
  will-change: transform, opacity;
  pointer-events: auto;
}

.toast.show {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.toast.accent {
  background: var(--accent);
  border-color: rgba(0, 0, 0, 0.5);
}

.toast.success {
  border-color: rgba(34, 197, 94, 0.4);
}

.toast.danger {
  border-color: rgba(239, 68, 68, 0.5);
}

.toast-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast-icon {
  width: 16px;
  height: 16px;
  color: #fff;
  opacity: 0.95;
  flex: 0 0 16px;
}

.toast-text {
  line-height: 1.2;
}

#mode-badge {
  display: flex;
}
#mode-badge .badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 12px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  font-size: 12px;
}
.ctx-menu {
  position: fixed;
  z-index: 11050;
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 6px;
  min-width: 160px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(6px) scale(0.98);
  transition: transform .22s cubic-bezier(0.22, 1, 0.36, 1), opacity .22s ease;
}
.ctx-menu .item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  font-weight: 600;
}
.ctx-menu .item:hover {
  background: rgba(255, 255, 255, 0.08);
}
.ctx-menu .item.danger {
  color: var(--danger);
}
.ctx-menu.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.ctx-menu.closing {
  opacity: 0;
  transform: translateY(6px) scale(0.98);
}

#copy-invite-btn.pulse-once {
  position: relative;
  animation: btnPulse .42s cubic-bezier(0.22, 1, 0.36, 1);
}

#copy-invite-btn.pulse-once::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 14px;
  border: 2px solid rgba(139, 92, 246, 0.6);
  opacity: 0.8;
  animation: ring .48s ease-out forwards;
  pointer-events: none;
}

@keyframes btnPulse {
  0% { transform: scale(1); }
  25% { transform: scale(0.98); }
  60% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

@keyframes ring {
  0% { transform: scale(0.92); opacity: 0.9; }
  100% { transform: scale(1.12); opacity: 0; }
}

#copy-invite-btn svg.nudge {
  animation: iconNudge .42s cubic-bezier(0.22, 1, 0.36, 1);
  transform-origin: 50% 50%;
}

@keyframes iconNudge {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  30% { transform: translateY(-1px) rotate(-10deg); }
  60% { transform: translateY(0) rotate(8deg); }
  100% { transform: translateY(0) rotate(0deg); opacity: 1; }
}

/* Адаптивность */
@media (max-width: 900px) {
  .topbar {
    padding: 14px 18px;
    padding-top: calc(14px + env(safe-area-inset-top));
  }
  .bottombar {
    padding: 14px 18px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }
  .messages {
    padding: 18px;
  }
  .room-name {
    font-size: 16px;
  }
  #profile-view {
    width: 80%;
  }
  #personalize-view {
    width: 80%;
  }
}

@media (max-width: 600px) {
  #profile-view {
    width: 100%;
  }
  #personalize-view {
    width: 100%;
  }
  .center-card {
    width: 90%;
    padding: 30px 20px;
  }
  .topbar {
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top));
  }
  .messages {
    padding: 16px;
  }
  .bottombar {
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
  .msg {
    max-width: 90%;
    font-size: 14px;
  }
  .input {
    padding: 12px 14px;
  }
}

/* Форма аватара: всегда круг без растяжения */
.profile-avatar,
.call-avatar {
  aspect-ratio: 1 / 1;
  flex-shrink: 0;
}
