:root {
  --bg: #050816;
  --bg-soft: rgba(15, 23, 42, 0.92);
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.12);
  --accent-strong: rgba(56, 189, 248, 0.25);
  --danger: #f97373;
  --text: #f9fafb;
  --text-soft: #9ca3af;
  --border: rgba(148, 163, 184, 0.2);

  --message-font-size: 14px;
  --meta-font-size: 11px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top, #1d2435 0, #050816 55%, #000 100%);
}

body {
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.app {
  flex: 1;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0;
  min-height: 100dvh;
}

.panel {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  border-radius: 0;
  background: radial-gradient(circle at top, rgba(56, 189, 248, 0.08), transparent 60%),
    radial-gradient(circle at bottom, rgba(168, 85, 247, 0.05), transparent 55%),
    var(--bg-soft);
  border: 1px solid var(--border);
  box-shadow:
    0 20px 70px rgba(15, 23, 42, 0.85),
    inset 0 0 0 1px rgba(15, 23, 42, 0.9);
  overflow: hidden;
  backdrop-filter: blur(18px);
}

.chat-panel {
  display: grid;
  grid-template-columns: 360px 1fr;
  width: 100%;
  height: 100%;
  min-height: 0;
}

/* Login */

.login-panel {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 40px 24px;
}

.logo {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: linear-gradient(120deg, #38bdf8, #a855f7, #f97316);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  text-shadow: 0 0 24px rgba(15, 23, 42, 0.9);
}

.subtitle {
  margin: 0;
  color: var(--text-soft);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}

.login-form input {
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 10px 14px;
  font-size: 15px;
  color: var(--text);
  background: rgba(15, 23, 42, 0.9);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.login-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.3);
  background: rgba(15, 23, 42, 1);
}

.avatar-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.9);
  font-size: 13px;
  color: var(--text-soft);
}

.avatar-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.avatar-toggle {
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(15, 23, 42, 0.7);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.avatar-toggle:hover {
  background: rgba(56, 189, 248, 0.16);
  border-color: rgba(56, 189, 248, 0.5);
  transform: translateY(-1px);
}

.avatar-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.avatar-upload {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.avatar-upload-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  border: 1px dashed rgba(148, 163, 184, 0.6);
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-soft);
  transition: border-color 0.15s ease, color 0.15s ease;
}

.avatar-upload-label input[type="file"] {
  display: none;
}

.avatar-upload-label:hover {
  border-color: var(--accent);
  color: var(--text);
}

.avatar-upload-preview {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(148, 163, 184, 0.5);
  box-shadow: 0 0 12px rgba(15, 23, 42, 0.65);
}

.avatar-upload-clear {
  border: none;
  background: rgba(248, 113, 113, 0.12);
  color: #fecaca;
  font-size: 12px;
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
}

.avatar-upload-clear:hover {
  background: rgba(248, 113, 113, 0.2);
}

.avatar-crop-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 8, 22, 0.85);
  z-index: 1000;
  padding: 24px;
}

.avatar-crop-card {
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 18px;
  padding: 20px;
  max-width: 360px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.8);
}

.avatar-crop-card h3 {
  margin: 0;
  font-size: 16px;
}

.avatar-crop-card p {
  margin: 0;
  font-size: 12px;
  color: var(--text-soft);
}

.avatar-crop-area {
  width: 240px;
  height: 240px;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  background: rgba(2, 6, 23, 0.6);
  border: 2px solid rgba(148, 163, 184, 0.4);
  align-self: center;
}

.avatar-crop-area img {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: top left;
  cursor: grab;
  user-select: none;
  -webkit-user-drag: none;
}

.avatar-crop-area img:active {
  cursor: grabbing;
}

.avatar-crop-handle {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.9);
  border: 2px solid rgba(15, 23, 42, 0.9);
  cursor: nwse-resize;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.7);
}

.avatar-crop-zoom {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-soft);
}

.avatar-crop-zoom input[type="range"] {
  width: 100%;
}

.avatar-crop-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.avatar-crop-cancel,
.avatar-crop-apply {
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.avatar-crop-cancel {
  background: rgba(148, 163, 184, 0.2);
  color: var(--text);
}

.avatar-crop-apply {
  background: linear-gradient(135deg, #38bdf8, #a855f7);
  color: #0f172a;
}

.avatar-option {
  border: 1px solid transparent;
  background: transparent;
  padding: 2px;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.avatar-option img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: block;
}

.avatar-option.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
  transform: translateY(-1px) scale(1.03);
}

.avatar-upload {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px dashed rgba(148, 163, 184, 0.5);
  background: rgba(15, 23, 42, 0.85);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
}

.avatar-upload input {
  display: none;
}

.avatar-upload-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.85);
}

.avatar-upload-preview img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(148, 163, 184, 0.4);
  box-shadow: 0 0 12px rgba(15, 23, 42, 0.6);
}

.avatar-upload-clear {
  border: none;
  background: rgba(248, 113, 113, 0.18);
  color: #fecaca;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
}

.avatar-upload-clear:hover {
  background: rgba(248, 113, 113, 0.3);
}

.login-form button {
  border-radius: 999px;
  border: none;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(135deg, #38bdf8, #a855f7);
  color: #0f172a;
  box-shadow: 0 12px 28px rgba(56, 189, 248, 0.45);
  transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.1s ease;
}

.login-form button:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow: 0 16px 36px rgba(56, 189, 248, 0.55);
}

.login-form button:active {
  transform: translateY(0);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.9);
}

.color-picker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.9);
  font-size: 13px;
  color: var(--text-soft);
}

.color-picker input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  border: none;
  padding: 0;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  cursor: pointer;
  background: transparent;
}

.color-picker input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 999px;
}

.color-picker input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: 999px;
}

/* Chat layout */

.chat-panel {
  display: grid;
  grid-template-columns: 360px 1fr;
}

.sidebar {
  border-right: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.6) transparent;

  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.16), transparent 55%),
    linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(8, 16, 32, 0.98));
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sidebar-section--stretch {
  flex: 1;
  min-height: 0;
}


.sidebar h2 {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent); /* запасной вариант, если градиент не применится */

  background: linear-gradient(120deg, #38bdf8, #a855f7);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;

  text-shadow:
    0 0 12px rgba(56, 189, 248, 0.65),
    0 0 22px rgba(168, 85, 247, 0.4);
}

.sidebar h2::after {
  content: "";
  display: block;
  margin-top: 6px;
  width: 40px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    rgba(56, 189, 248, 0.95),
    rgba(168, 85, 247, 0.75)
  );
  box-shadow:
    0 0 10px rgba(56, 189, 248, 0.6),
    0 0 18px rgba(15, 23, 42, 0.9);
}

.sidebar-section-head h2 {
  margin-bottom: 0;
}

.profile-trigger {
  border: 1px solid rgba(56, 189, 248, 0.55);
  background: linear-gradient(
    120deg,
    rgba(56, 189, 248, 0.28),
    rgba(168, 85, 247, 0.24)
  );
  color: #e5f3ff;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  text-transform: uppercase;
  transition:
    transform 0.12s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
  box-shadow:
    0 0 10px rgba(56, 189, 248, 0.22),
    inset 0 0 0 1px rgba(15, 23, 42, 0.35);
}

.profile-trigger:hover {
  transform: translateY(-1px);
  border-color: rgba(125, 211, 252, 0.9);
  background: linear-gradient(
    120deg,
    rgba(56, 189, 248, 0.4),
    rgba(125, 211, 252, 0.25)
  );
  box-shadow:
    0 0 16px rgba(56, 189, 248, 0.35),
    inset 0 0 0 1px rgba(14, 116, 144, 0.28);
}

.profile-trigger:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px rgba(125, 211, 252, 0.55),
    0 0 16px rgba(56, 189, 248, 0.4);
}

.logout-button {
  border: 1px solid rgba(56, 189, 248, 0.55);
  background: linear-gradient(
    120deg,
    rgba(56, 189, 248, 0.32),
    rgba(168, 85, 247, 0.24)
  );
  color: #e5f3ff;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition:
    background 0.22s ease,
    border-color 0.22s ease,
    box-shadow 0.22s ease,
    color 0.22s ease,
    transform 0.12s ease;
  box-shadow:
    0 0 10px rgba(56, 189, 248, 0.22),
    inset 0 0 0 1px rgba(15, 23, 42, 0.35);
}

.logout-button:hover {
  background: linear-gradient(
    120deg,
    rgba(248, 113, 113, 0.44),
    rgba(239, 68, 68, 0.4),
    rgba(190, 18, 60, 0.36)
  );
  border-color: rgba(248, 113, 113, 0.78);
  color: #fff;
  box-shadow:
    0 0 16px rgba(248, 113, 113, 0.45),
    inset 0 0 0 1px rgba(127, 29, 29, 0.25);
  transform: translateY(-1px);
}

.logout-button:active {
  transform: translateY(0);
}

.logout-button:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px rgba(248, 113, 113, 0.5),
    0 0 16px rgba(248, 113, 113, 0.45);
}


.users-list {
  list-style: none;
  padding: 10px 12px 10px 8px;
  margin: 4px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-soft);
  overflow-y: auto;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.6) transparent;

  /* более яркий, контрастный фон под список ников */
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.18), transparent 55%),
    radial-gradient(circle at bottom right, rgba(168, 85, 247, 0.16), transparent 60%),
    linear-gradient(135deg, rgba(15, 23, 42, 0.98), rgba(15, 23, 42, 0.96));
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.65);
  box-shadow:
    0 0 26px rgba(15, 23, 42, 0.95),
    0 0 40px rgba(15, 23, 42, 0.97);
}

.users-list--stretch {
  flex: 1;
  min-height: 0;
}

.users-list li.is-active {
  background: linear-gradient(
    90deg,
    rgba(56, 189, 248, 0.25),
    rgba(15, 23, 42, 0.9)
  );
  border-color: rgba(56, 189, 248, 0.85);
  box-shadow:
    0 0 16px rgba(56, 189, 248, 0.4),
    0 0 28px rgba(168, 85, 247, 0.25);
  color: #e0f2fe;
}

.users-list li.is-self {
  background: linear-gradient(
    90deg,
    rgba(56, 189, 248, 0.2),
    rgba(15, 23, 42, 0.9)
  );
}

.users-list li {
  padding: 8px 12px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    rgba(15, 23, 42, 0.98),
    rgba(15, 23, 42, 0.82)
  );
  border: 1px solid rgba(148, 163, 184, 0.45);
  position: relative;

  display: inline-flex;
  align-items: center;
  gap: 10px;
  align-self: flex-start;
  max-width: 100%;

  font-weight: 700;
  letter-spacing: 0.02em;
  text-shadow:
    0 0 8px rgba(15, 23, 42, 0.9),
    0 0 14px rgba(15, 23, 42, 1);
  transition:
    transform 0.08s ease,
    box-shadow 0.12s ease,
    border-color 0.12s ease,
    background 0.12s ease;
}

.users-list--compact {
  padding: 8px 12px 8px 8px;
  gap: 6px;
}

.users-list--compact li {
  padding: 6px 10px;
  font-size: 14px;
}

.users-list li.direct-dialog-item {
  padding-right: 34px;
}

.direct-hide-button {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  border: 1px solid rgba(226, 232, 240, 0.4);
  border-radius: 999px;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.75);
  color: rgba(226, 232, 240, 0.95);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.16s ease,
    transform 0.12s ease,
    border-color 0.16s ease,
    background 0.16s ease,
    box-shadow 0.16s ease;
}

.users-list li.direct-dialog-item:hover .direct-hide-button,
.users-list li.direct-dialog-item.is-active .direct-hide-button {
  opacity: 1;
  pointer-events: auto;
}

.direct-hide-button:hover {
  transform: translateY(-50%) scale(1.06);
  border-color: rgba(248, 113, 113, 0.82);
  background: rgba(127, 29, 29, 0.8);
  box-shadow: 0 0 14px rgba(248, 113, 113, 0.35);
}

.users-list li.is-clickable {
  cursor: pointer;
}

.users-list li.is-clickable:hover {
  transform: translateY(-1px);
  background: linear-gradient(
    90deg,
    rgba(30, 41, 59, 0.98),
    rgba(15, 23, 42, 0.9)
  );
  box-shadow: 0 0 18px rgba(15, 23, 42, 0.6);
}

.public-chat-shortcut {
  width: 100%;
  margin-top: 8px;
  border-radius: 16px;
  border: 1px solid rgba(56, 189, 248, 0.7);
  background: linear-gradient(
    135deg,
    rgba(56, 189, 248, 0.4),
    rgba(168, 85, 247, 0.35)
  );
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  padding: 10px 12px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  box-shadow:
    0 0 16px rgba(56, 189, 248, 0.45),
    0 0 28px rgba(168, 85, 247, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.public-chat-shortcut:hover {
  transform: translateY(-1px);
  border-color: rgba(56, 189, 248, 0.9);
  box-shadow:
    0 0 20px rgba(56, 189, 248, 0.6),
    0 0 32px rgba(168, 85, 247, 0.45);
}

.user-avatar {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid var(--avatar-border, rgba(148, 163, 184, 0.7));
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.35),
    0 0 14px var(--avatar-glow, rgba(15, 23, 42, 0.65));
}

.message-avatar {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid var(--avatar-border, rgba(148, 163, 184, 0.7));
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.35),
    0 0 14px var(--avatar-glow, rgba(15, 23, 42, 0.65));
}

.message-avatar.is-clickable {
  cursor: pointer;
}

.user-name {
  flex: 1;
}

.user-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.2);
  color: var(--text);
  border: 1px solid rgba(56, 189, 248, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.user-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.6);
  box-shadow: 0 0 6px rgba(15, 23, 42, 0.7);
}

.user-status.is-online {
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.7);
}

.users-empty {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  opacity: 0.7;
  align-self: stretch;
  text-align: center;
}

.user-unread {
  min-width: 22px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
}


/* Chat main */

.chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0; /* важно для скролла внутри */
  position: relative;
}

.chat-header {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(to right, rgba(15, 23, 42, 0.96), rgba(15, 23, 42, 0.9));
}

.chat-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-button {
  border: none;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  border-radius: 999px;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    transform 0.1s ease;
}

.icon-button:hover {
  background: rgba(148, 163, 184, 0.15);
  transform: translateY(-1px);
}

.icon-button.muted {
  opacity: 0.6;
}

.zoom-control {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-soft);
}

.zoom-control input[type="range"] {
  width: 90px;
}

.chat-title {
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.chat-context {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.7);
}

.chat-context.is-direct {
  color: var(--text);
  border-color: rgba(56, 189, 248, 0.6);
  background: linear-gradient(
    120deg,
    rgba(56, 189, 248, 0.25),
    rgba(168, 85, 247, 0.2)
  );
  box-shadow:
    0 0 14px rgba(56, 189, 248, 0.35),
    0 0 24px rgba(168, 85, 247, 0.2);
}

.back-to-public {
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: linear-gradient(
    120deg,
    rgba(56, 189, 248, 0.35),
    rgba(168, 85, 247, 0.3)
  );
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  box-shadow:
    0 0 12px rgba(56, 189, 248, 0.35),
    0 0 24px rgba(168, 85, 247, 0.25);
}

.back-to-public:hover {
  background: linear-gradient(
    120deg,
    rgba(56, 189, 248, 0.5),
    rgba(168, 85, 247, 0.45)
  );
  border-color: rgba(56, 189, 248, 0.7);
  transform: translateY(-1px);
}

.dm-popup {
  position: fixed;
  z-index: 1200;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.8);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 180px;
}

.dm-popup.hidden {
  display: none;
}

.dm-popup .dm-title {
  font-size: 12px;
  color: var(--text-soft);
}

.dm-popup .dm-action {
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-radius: 10px;
  background: linear-gradient(
    135deg,
    rgba(56, 189, 248, 0.28),
    rgba(168, 85, 247, 0.25)
  );
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 10px;
  cursor: pointer;
  text-align: left;
  box-shadow:
    0 0 12px rgba(56, 189, 248, 0.25),
    0 0 18px rgba(168, 85, 247, 0.18);
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.dm-popup .dm-action:hover {
  transform: translateY(-1px);
  border-color: rgba(56, 189, 248, 0.6);
  box-shadow:
    0 0 16px rgba(56, 189, 248, 0.35),
    0 0 24px rgba(168, 85, 247, 0.25);
}

.dm-popup .dm-action--public {
  background: linear-gradient(
    135deg,
    rgba(34, 197, 94, 0.3),
    rgba(56, 189, 248, 0.25)
  );
  border-color: rgba(34, 197, 94, 0.4);
  box-shadow:
    0 0 12px rgba(34, 197, 94, 0.25),
    0 0 18px rgba(56, 189, 248, 0.2);
}

.dm-popup .dm-action--public:hover {
  border-color: rgba(34, 197, 94, 0.65);
  box-shadow:
    0 0 16px rgba(34, 197, 94, 0.35),
    0 0 24px rgba(56, 189, 248, 0.25);
}

.chat-status {
  font-size: 13px;
  color: var(--accent);
}

.chat-notifications {
  position: absolute;
  top: 78px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 900;
  max-width: 320px;
}

.chat-notification {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(
    135deg,
    rgba(30, 64, 175, 0.98),
    rgba(56, 189, 248, 0.9)
  );
  border: 1px solid rgba(56, 189, 248, 0.85);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow:
    0 0 18px rgba(59, 130, 246, 0.6),
    0 0 32px rgba(56, 189, 248, 0.55),
    0 8px 24px rgba(15, 23, 42, 0.6);
  animation: notification-enter 0.2s ease;
}

.chat-notification.is-leaving {
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.chat-notification__content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-notification__title {
  font-weight: 700;
  font-size: 13px;
  color: #f8fafc;
}

.chat-notification__body {
  font-size: 12px;
  color: rgba(248, 250, 252, 0.9);
}

.chat-notification__actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-notification__action {
  border: none;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  color: #0f172a;
  background: rgba(248, 250, 252, 0.95);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.chat-notification__action:hover {
  background: #ffffff;
}

.chat-notification__close {
  border: none;
  background: rgba(15, 23, 42, 0.4);
  color: rgba(248, 250, 252, 0.9);
  border-radius: 999px;
  padding: 4px 8px;
  cursor: pointer;
}

@keyframes notification-enter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.profile-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 8, 22, 0.85);
  z-index: 1500;
  padding: 24px;
}

.profile-card {
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 24px;
  padding: 28px;
  width: min(440px, 92vw);
  text-align: center;
  position: relative;
  box-shadow:
    0 20px 60px rgba(15, 23, 42, 0.85),
    0 0 24px rgba(56, 189, 248, 0.25);
}

.profile-close {
  position: absolute;
  top: 12px;
  right: 12px;
  border: none;
  background: rgba(148, 163, 184, 0.2);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 8px;
  cursor: pointer;
}

.profile-avatar {
  width: 170px;
  height: 170px;
  border-radius: 50%;
  border: 3px solid var(--profile-accent, rgba(56, 189, 248, 0.7));
  box-shadow:
    0 0 16px rgba(56, 189, 248, 0.4),
    0 0 28px rgba(15, 23, 42, 0.8);
  margin-bottom: 14px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.profile-avatar:hover {
  transform: scale(1.02);
  box-shadow:
    0 0 20px rgba(56, 189, 248, 0.5),
    0 0 36px rgba(15, 23, 42, 0.9);
}

.profile-name {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 18px;
}

.profile-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.profile-action {
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: linear-gradient(
    135deg,
    rgba(56, 189, 248, 0.25),
    rgba(168, 85, 247, 0.2)
  );
  color: var(--text);
  padding: 10px 22px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  box-shadow:
    0 0 18px rgba(56, 189, 248, 0.25),
    0 0 28px rgba(168, 85, 247, 0.2);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  min-width: 220px;
}

.profile-action--primary {
  border-color: rgba(56, 189, 248, 0.7);
  background: linear-gradient(
    135deg,
    rgba(56, 189, 248, 0.4),
    rgba(168, 85, 247, 0.3)
  );
  box-shadow:
    0 0 22px rgba(56, 189, 248, 0.35),
    0 0 32px rgba(168, 85, 247, 0.25);
}

.profile-action:hover {
  transform: translateY(-2px);
  border-color: rgba(56, 189, 248, 0.85);
  box-shadow:
    0 0 26px rgba(56, 189, 248, 0.4),
    0 0 36px rgba(168, 85, 247, 0.3);
}

.profile-avatar-view {
  position: absolute;
  inset: 0;
  background: rgba(5, 8, 22, 0.95);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.profile-avatar-view.hidden {
  display: none;
}

.profile-avatar-view img {
  max-width: 85%;
  max-height: 85%;
  border-radius: 24px;
  box-shadow:
    0 24px 60px rgba(15, 23, 42, 0.8),
    0 0 28px rgba(56, 189, 248, 0.3);
}

.profile-avatar-view .profile-avatar-view-close {
  position: absolute;
  top: 18px;
  right: 18px;
  border: none;
  background: rgba(148, 163, 184, 0.2);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 10px;
  cursor: pointer;
}

.profile-card--self {
  width: min(520px, 96vw);
  text-align: left;
}

.self-profile-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 12px;
  text-align: center;
}

.self-profile-avatar {
  display: block;
  margin: 0 auto 12px;
  width: 130px;
  height: 130px;
}

.self-profile-avatar-options {
  max-height: 140px;
  margin-bottom: 12px;
}

.self-profile-upload-label {
  display: inline-flex;
  margin: 0 auto 14px;
  min-width: 220px;
  justify-content: center;
}

.self-profile-upload-label input[type="file"] {
  display: none;
}

.self-profile-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.self-profile-field span {
  font-size: 12px;
  color: var(--text-soft);
  letter-spacing: 0.03em;
}

.self-profile-field input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(15, 23, 42, 0.55);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
}

.self-profile-field input:focus {
  outline: none;
  border-color: rgba(56, 189, 248, 0.75);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.3);
}

.self-profile-hidden-title {
  margin-top: 10px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text-soft);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hidden-dialogs-list {
  list-style: none;
  margin: 0;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
}

.hidden-dialog-item {
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 14px;
}

.hidden-dialog-item button {
  border: 1px solid rgba(56, 189, 248, 0.6);
  border-radius: 999px;
  background: linear-gradient(
    135deg,
    rgba(56, 189, 248, 0.3),
    rgba(168, 85, 247, 0.25)
  );
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
}

.hidden-dialog-empty {
  border: 1px dashed rgba(148, 163, 184, 0.4);
  border-radius: 10px;
  color: var(--text-soft);
  padding: 10px;
  text-align: center;
  font-size: 13px;
}

/* Audio player */
.audio-player {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(to right, rgba(15, 23, 42, 0.92), rgba(15, 23, 42, 0.85));
}

.audio-player.hidden {
  display: none;
}

.audio-play {
  font-size: 16px;
}

.audio-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.audio-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audio-time {
  font-size: 11px;
  color: var(--text-soft);
}

#audio-progress {
  flex: 2;
  max-width: 320px;
}

.audio-close {
  color: var(--text-soft);
}

.audio-close:hover {
  color: var(--accent);
}

/* Messages */

.messages {
  flex: 1;
  list-style: none;
  padding: 16px 18px;
  margin: 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.6) transparent;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;   /* <-- главное: больше не растягиваем по ширине */
}

.message.is-unread .message-bubble {
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.4);
}

.unread-indicator {
  position: absolute;
  right: 24px;
  bottom: 118px;
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.9), rgba(168, 85, 247, 0.9));
  color: #0f172a;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.6);
  z-index: 4;
}

.unread-indicator:hover {
  filter: brightness(1.05);
}


.messages::-webkit-scrollbar {
  width: 6px;
}

.messages::-webkit-scrollbar-track {
  background: transparent;
}

.messages::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.4);
  border-radius: 999px;
}

.sidebar::-webkit-scrollbar,
.users-list::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track,
.users-list::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb,
.users-list::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.4);
  border-radius: 999px;
}

.message {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
  font-size: var(--message-font-size);

  /* заметная анимация появления */
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  animation: message-in 0.22s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

.message-bubble {
  max-width: 70%;
  border-radius: 22px;
  padding: 8px 38px 18px 10px;
  background: var(--bubble-bg, rgba(15, 23, 42, 0.96));
  border: 2px solid var(--bubble-border, rgba(148, 163, 184, 0.3));
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.35);
}

.message .meta {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  font-size: var(--meta-font-size);
}

.message .author {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  font-weight: 600;
  color: var(--accent);
}

.message .author.is-clickable {
  cursor: pointer;
  text-decoration: none;
}

.message .author.is-clickable:hover {
  text-decoration: underline;
}

.message .text {
  word-wrap: break-word;
  white-space: pre-wrap;
}

.message-body {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 6px 8px;
}

.message-body .text {
  flex: 1 1 auto;
}

.message-status {
  margin-top: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  white-space: nowrap;
  font-size: var(--meta-font-size);
  color: var(--text-soft);
  line-height: 1;
}

.message-checks {
  color: var(--text-soft);
  font-weight: 600;
}

.message-checks.is-read {
  color: var(--accent);
}

.message-checks.is-sent {
  color: rgba(226, 232, 240, 0.7);
}

.message-time {
  color: var(--text-soft);
}

.chat-emoji {
  font-size: calc(var(--message-font-size) * 2);
  line-height: 1;
  display: inline-block;
}

.message .text a {
  color: #00e5ff;
}

.message .attachments {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}

.message-reactions {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-self: flex-end;
}

.reaction-chip {
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.85);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.reaction-chip.is-selected {
  border-color: rgba(56, 189, 248, 0.6);
  background: rgba(56, 189, 248, 0.16);
}

.reaction-trigger {
  position: absolute;
  top: 8px;
  right: 8px;
  border: none;
  border-radius: 999px;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.65);
  color: var(--text);
  cursor: pointer;
  opacity: 0;
  transform: scale(0.92);
  transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.message-bubble:hover .reaction-trigger {
  opacity: 1;
  transform: scale(1);
}

.reaction-trigger:hover {
  background: rgba(56, 189, 248, 0.2);
}

.reaction-picker {
  position: fixed;
  z-index: 50;
  display: flex;
  gap: 6px;
  padding: 8px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.95);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.75);
}

.reaction-picker.hidden {
  display: none;
}

.reaction-option {
  border: none;
  background: transparent;
  font-size: 36px;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.reaction-option:hover {
  transform: translateY(-2px);
}

.message .attachment-images {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.attachment-thumb {
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 12px;
  overflow: hidden;
  max-width: 540px;
  max-height: 420px;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.45);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.attachment-thumb:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.6);
}

.attachment-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.attachment-files {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message .attachment-item {
  font-size: 12px;
  color: var(--text-soft);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.message .attachment-item a {
  color: #7dd3fc;
  text-decoration: none;
}

.message .attachment-item a:hover {
  text-decoration: underline;
}

.message .attachment-audio {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.audio-attachment {
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.8);
  color: var(--text);
  border-radius: 12px;
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12px;
  transition: transform 0.1s ease, box-shadow 0.1s ease, border-color 0.1s ease;
}

.audio-attachment:hover {
  transform: translateY(-1px);
  border-color: rgba(56, 189, 248, 0.6);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.6);
}

.message.me .message-bubble {
  border-radius: 22px 22px 10px 22px;
}

.message:not(.me) .message-bubble {
  border-radius: 22px 22px 22px 10px;
}

.message.me .meta {
  flex-direction: row-reverse;
  text-align: right;
}

.message.me {
  margin-left: auto;
  flex-direction: row-reverse;
}

.message.system {
  margin: 10px auto;
  max-width: 70%;
  text-align: center;
  font-size: 13px;
  background: transparent;
  border: none;
  color: var(--text-soft);
  display: block;
}

.message.system-join-leave {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.03em;
}

.message.system-join-leave .system-nick {
  font-weight: 700;
}

.message.system-join-leave .system-rest {
  margin-left: 4px;
}

/* Input */

.message-form {
  border-top: 1px solid rgba(45, 212, 191, 0.35);
  padding: 16px 20px;
  display: flex;
  gap: 10px;
  background: linear-gradient(
    135deg,
    rgba(14, 40, 68, 0.96) 0%,
    rgba(23, 55, 92, 0.94) 55%,
    rgba(16, 79, 94, 0.92) 100%
  );
  box-shadow:
    0 -10px 28px rgba(10, 32, 56, 0.45),
    inset 0 1px 0 rgba(125, 211, 252, 0.14);
  align-items: center;
}

.message-form input,
.message-form textarea {
  flex: 1;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  padding: 12px 16px;
  font-size: 15px;
  background: #ffffff;
  color: #0f172a;
  outline: none;
  resize: none;
  min-height: 54px;
  max-height: 162px;
  line-height: 1.4;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
}

.message-form textarea::placeholder,
.message-form input::placeholder {
  color: #64748b;
}

.message-form input:focus,
.message-form textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.25);
  background: #ffffff;
}

.message-form .send-button {
  border-radius: 999px;
  border: none;
  width: 54px;
  height: 54px;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: linear-gradient(135deg, #38bdf8, #a855f7);
  color: #0f172a;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.9);
  transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.1s ease;
}

.message-form .send-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.95);
}

.message-form .send-button:active {
  transform: translateY(0);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.95);
}

.attach-button {
  font-size: 20px;
  width: 54px;
  height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: var(--text-soft);
}

.attach-button:hover {
  color: var(--text);
}

.emoji-button {
  font-size: 20px;
  width: 54px;
  height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: var(--text-soft);
}

.emoji-button:hover {
  color: var(--text);
}

.emoji-panel {
  position: absolute;
  right: 16px;
  bottom: 120px;
  width: min(420px, calc(100% - 32px));
  max-height: 420px;
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.98), rgba(30, 41, 59, 0.96));
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-radius: 16px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.92),
    inset 0 0 0 1px rgba(255, 255, 255, 0.03);
  display: flex;
  flex-direction: column;
  z-index: 5;
  backdrop-filter: blur(18px);
}

.emoji-panel-header {
  display: flex;
  gap: 8px;
  padding: 10px 12px 6px;
}

.emoji-tab {
  border: none;
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-soft);
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.emoji-tab.active {
  background: linear-gradient(120deg, rgba(56, 189, 248, 0.35), rgba(168, 85, 247, 0.35));
  color: var(--text);
  box-shadow: 0 8px 18px rgba(56, 189, 248, 0.2);
}

.emoji-panel-search {
  padding: 0 12px 10px;
}

.emoji-panel-search input {
  width: 100%;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  padding: 8px 12px;
  background: rgba(15, 23, 42, 0.85);
  color: var(--text);
  font-size: 13px;
}

.emoji-panel-body {
  padding: 0 10px 12px;
  overflow: hidden;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.emoji-grid,
.sticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
  gap: 6px;
  overflow-y: auto;
  padding: 4px 2px 0;
  max-height: 300px;
}

.emoji-item {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 4px;
  border-radius: 10px;
  transition: background 0.15s ease, transform 0.12s ease;
}

.emoji-item:hover {
  background: rgba(148, 163, 184, 0.2);
  transform: translateY(-1px);
}

.sticker-item {
  border: none;
  background: rgba(148, 163, 184, 0.08);
  border-radius: 12px;
  padding: 6px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
}

.sticker-item:hover {
  background: rgba(148, 163, 184, 0.2);
  transform: translateY(-1px);
}

.sticker-item img {
  width: 100%;
  height: auto;
  display: block;
}

.message.sticker .text {
  display: flex;
  justify-content: flex-start;
}

.message.sticker .sticker-message {
  width: 140px;
  max-width: 160px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.55);
  padding: 6px;
}

.message.sticker .sticker-message img {
  width: 100%;
  height: auto;
  display: block;
}

.attachment-count {
  font-size: 12px;
  color: var(--text-soft);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.8);
}

.attachment-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 16px 12px;
  border-top: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.92);
}

.attachment-preview .attachment-thumb {
  max-width: 120px;
  max-height: 90px;
  border-radius: 10px;
}

.attachment-preview .attachment-file {
  font-size: 12px;
  color: var(--text-soft);
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.8);
}

/* Utils */

.hidden {
  display: none !important;
}

/* Responsive */

@media (max-width: 720px) {
  .panel {
    max-width: 100%;
    min-height: 100%;
    border-radius: 0;
  }

  .chat-panel {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr auto;
  }

  .sidebar {
    order: 2;
    border-right: none;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }

  .sidebar-section {
    flex: 1 1 100%;
  }

  .users-list {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }

  .users-list li {
    font-size: 12px;
  }
}

.bots-toggle {
  display: none !important;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-soft);
  margin: 4px 0 6px;
}

.bots-toggle input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--accent);
}

.users-list li.fake-bot {
  opacity: 0.7;
  font-style: italic;
}


@keyframes message-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* превью ответа над полем ввода */
.reply-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.04);
  border-left: 3px solid var(--reply-accent, var(--accent));
  padding: 6px 10px;
  margin: 6px 0;
  border-radius: 8px;
  font-size: 12px;
}

.reply-preview.hidden {
  display: none;
}

.reply-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 100%;
  overflow: hidden;
}

.reply-info .reply-author {
  font-weight: 600;
  color: var(--reply-accent, var(--accent));
}

.reply-info .reply-text {
  color: var(--text-soft);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.reply-cancel {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  color: var(--text-soft);
  margin-left: 8px;
}

.reply-cancel:hover {
  color: var(--accent);
}

/* цитата внутри самого сообщения */
.reply-block {
  border-left: 2px solid var(--reply-accent, var(--accent));
  padding-left: 8px;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--text-soft);
  opacity: 0.9;
}

.reply-block.is-clickable {
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.reply-block.is-clickable:hover {
  opacity: 1;
}

.reply-block .reply-author {
  font-weight: 600;
  color: var(--reply-accent, var(--accent));
}

.reply-block .reply-author.is-clickable {
  cursor: pointer;
}

.reply-block .reply-author.is-clickable:hover {
  text-decoration: underline;
}

.reply-block .reply-snippet {
  color: var(--text-soft);
}

.mention-chip {
  background: none;
  border: none;
  padding: 0;
  margin: 0 4px 0 0;
  font: inherit;
  font-weight: 700;
  color: var(--mention-color, var(--accent));
  cursor: pointer;
  text-decoration: none;
}

.mention-chip:hover {
  text-decoration: underline;
}

.message.message-highlight {
  position: relative;
}

.message.message-highlight::before {
  content: "";
  position: absolute;
  inset: -6px -8px;
  border-radius: 20px;
  background: var(--highlight-bg, rgba(56, 189, 248, 0.18));
  box-shadow:
    inset 0 0 0 1px var(--highlight-border, rgba(56, 189, 248, 0.35)),
    0 0 18px var(--highlight-border, rgba(56, 189, 248, 0.35));
  z-index: 0;
  opacity: 1;
  transition: opacity 0.6s ease, box-shadow 0.6s ease;
}

.message.message-highlight > * {
  position: relative;
  z-index: 1;
}

.message-highlight .message-bubble {
  box-shadow:
    0 0 18px rgba(56, 189, 248, 0.45),
    0 0 32px rgba(168, 85, 247, 0.3);
  border-color: rgba(56, 189, 248, 0.85);
  transition: box-shadow 0.6s ease, border-color 0.6s ease;
}

.message.message-highlight.is-fading::before {
  opacity: 0;
  box-shadow: none;
}

.message-highlight.is-fading .message-bubble {
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.35);
  border-color: var(--bubble-border, rgba(148, 163, 184, 0.3));
}

/* Lightbox */
.media-lightbox {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  background: rgba(2, 6, 18, 0.88);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5000;
  padding: 24px;
  cursor: zoom-out;
}

.media-lightbox.hidden {
  display: none;
}

.lightbox-content {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
}

.media-lightbox img {
  max-width: min(1500px, 92vw);
  max-height: calc(100dvh - 90px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  cursor: zoom-out;
}

.lightbox-close {
  position: absolute;
  top: -16px;
  right: -16px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  background: linear-gradient(145deg, #ffffff, #e8edf9);
  color: #0b1220;
  font-size: 24px;
  font-weight: 800;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  cursor: pointer;
  box-shadow:
    0 12px 28px rgba(2, 6, 18, 0.7),
    0 0 0 1px rgba(15, 23, 42, 0.15);
  transition:
    transform 0.14s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
}

.lightbox-close:hover {
  background: linear-gradient(
    140deg,
    rgba(255, 255, 255, 0.98),
    rgba(254, 226, 226, 0.95)
  );
  box-shadow:
    0 16px 34px rgba(2, 6, 18, 0.78),
    0 0 0 2px rgba(248, 113, 113, 0.45);
  transform: translateY(-1px) scale(1.04);
}

.lightbox-close:active {
  transform: translateY(0) scale(0.99);
}

body.lightbox-open {
  overflow: hidden;
}
