:root {
  --bg: #060911;
  --bg-soft: #0a0f1a;
  --surface: rgba(17, 23, 35, 0.72);
  --surface-solid: #111723;
  --surface-2: rgba(255, 255, 255, 0.045);
  --border: rgba(255, 255, 255, 0.075);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #e9eff8;
  --muted: #8a98ad;
  --accent: #4f9cf9;
  --accent-2: #8b7bff;
  --mint: #4be3b0;
  --danger: #ff6b81;
  --radius: 14px;
  --ease: cubic-bezier(0.2, 0.8, 0.3, 1);
}

* { box-sizing: border-box; }

@supports not selector(::-webkit-scrollbar) {
  * {
    scrollbar-width: thin;
    scrollbar-color: rgba(126, 168, 255, 0.45) transparent;
  }
}

*::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}

*::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(126, 168, 255, 0.5), rgba(150, 130, 255, 0.5));
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  border-width: 2px;
  background: linear-gradient(180deg, rgba(126, 168, 255, 0.85), rgba(150, 130, 255, 0.85));
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:active {
  border-width: 1px;
  background: linear-gradient(180deg, rgba(126, 168, 255, 1), rgba(150, 130, 255, 1));
  background-clip: padding-box;
}

*::-webkit-scrollbar-corner {
  background: transparent;
}

*::-webkit-scrollbar-button {
  display: none;
  height: 0;
  width: 0;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Noto Color Emoji", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

::selection {
  background: rgba(79, 156, 249, 0.35);
  color: #fff;
}

/* ================= живой фон ================= */

.aurora {
  position: fixed;
  inset: -10%;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  transform: translate3d(var(--px, 0px), var(--py, 0px), 0);
}

.blob {
  position: absolute;
  display: block;
  border-radius: 50%;
  filter: blur(72px);
  opacity: 0.55;
  will-change: transform;
}

.blob.one {
  width: 46vw;
  height: 46vw;
  left: -6vw;
  top: -10vw;
  background: radial-gradient(circle at 35% 35%, #2b7bff, #123a8a 65%, transparent 72%);
  animation: driftOne 24s ease-in-out infinite alternate;
}

.blob.two {
  width: 40vw;
  height: 40vw;
  right: -8vw;
  top: 2vw;
  background: radial-gradient(circle at 60% 40%, #8b7bff, #4b2c95 65%, transparent 72%);
  animation: driftTwo 29s ease-in-out infinite alternate;
}

.blob.three {
  width: 38vw;
  height: 38vw;
  left: 18vw;
  bottom: -14vw;
  background: radial-gradient(circle at 50% 50%, #21d4c0, #0d6b62 62%, transparent 72%);
  opacity: 0.42;
  animation: driftThree 33s ease-in-out infinite alternate;
}

.blob.four {
  width: 26vw;
  height: 26vw;
  right: 12vw;
  bottom: -8vw;
  background: radial-gradient(circle at 50% 50%, #b14dff, #5d1f96 62%, transparent 72%);
  opacity: 0.36;
  animation: driftFour 21s ease-in-out infinite alternate;
}

.veil {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(1200px 700px at 50% 0%, rgba(6, 9, 17, 0) 0%, rgba(6, 9, 17, 0.55) 60%, rgba(6, 9, 17, 0.9) 100%),
    linear-gradient(180deg, rgba(6, 9, 17, 0.35), rgba(6, 9, 17, 0.75));
}

@keyframes driftOne {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(7vw, 5vh, 0) scale(1.12); }
}

@keyframes driftTwo {
  from { transform: translate3d(0, 0, 0) scale(1.05); }
  to { transform: translate3d(-6vw, 7vh, 0) scale(0.95); }
}

@keyframes driftThree {
  from { transform: translate3d(0, 0, 0) scale(0.96); }
  to { transform: translate3d(9vw, -6vh, 0) scale(1.1); }
}

@keyframes driftFour {
  from { transform: translate3d(0, 0, 0) scale(1.1); }
  to { transform: translate3d(-8vw, -5vh, 0) scale(0.92); }
}

/* ================= авторизация ================= */

.auth {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px;
}

.auth-card {
  position: relative;
  width: 100%;
  max-width: 404px;
  padding: 28px 26px 22px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(22, 29, 44, 0.86), rgba(13, 18, 29, 0.92));
  border: 1px solid var(--border-strong);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.03) inset,
    0 1px 0 rgba(255, 255, 255, 0.06) inset;
  backdrop-filter: blur(18px);
  animation: cardIn 0.6s var(--ease) both;
  overflow: hidden;
}

.auth-card::before {
  content: "";
  position: absolute;
  inset: -40% -60%;
  background: conic-gradient(from 0deg, transparent 0deg, rgba(79, 156, 249, 0.5) 60deg, transparent 130deg, rgba(139, 123, 255, 0.45) 220deg, transparent 300deg);
  animation: spin 14s linear infinite;
  opacity: 0.5;
  z-index: -1;
}

.auth-card::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 21px;
  background: linear-gradient(180deg, rgba(20, 27, 41, 0.97), rgba(11, 16, 26, 0.99));
  z-index: -1;
}

@keyframes spin {
  to { transform: rotate(1turn); }
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.auth-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 22px;
}

.logo-dot {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 24px rgba(79, 156, 249, 0.45);
  flex: none;
  display: grid;
  place-items: center;
  animation: logoFloat 6s ease-in-out infinite;
}

.logo-dot::after {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 5px;
  border: 2px solid rgba(6, 10, 20, 0.75);
  border-bottom-color: transparent;
  transform: rotate(45deg);
}

.logo-pulse {
  position: absolute;
  inset: -6px;
  border-radius: 18px;
  border: 1px solid rgba(79, 156, 249, 0.5);
  animation: haloPulse 3s ease-out infinite;
}

@keyframes logoFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@keyframes haloPulse {
  0% { opacity: 0.7; transform: scale(0.9); }
  70% { opacity: 0; transform: scale(1.35); }
  100% { opacity: 0; transform: scale(1.35); }
}

.auth-brand h1 {
  margin: 0;
  font-size: 19px;
  letter-spacing: -0.01em;
  background: linear-gradient(90deg, #ffffff, #b9cdff 60%, #cfc4ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.auth-brand p {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.tabs {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: rgba(255, 255, 255, 0.04);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 9px;
  border-radius: 9px;
  font-size: 14px;
  transition: color 0.2s var(--ease), background 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.tab:hover { color: var(--text); }

.tab.active {
  background: linear-gradient(180deg, rgba(79, 156, 249, 0.22), rgba(79, 156, 249, 0.1));
  color: #fff;
  box-shadow: 0 0 0 1px rgba(79, 156, 249, 0.32) inset, 0 6px 18px rgba(79, 156, 249, 0.18);
}

.form {
  display: grid;
  gap: 12px;
  animation: fadeUp 0.35s var(--ease) both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.field {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.field input {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 14.5px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.25s var(--ease), background 0.2s var(--ease);
}

.field input:hover { background: rgba(255, 255, 255, 0.05); }

.field input:focus {
  border-color: rgba(79, 156, 249, 0.75);
  background: rgba(79, 156, 249, 0.06);
  box-shadow: 0 0 0 3px rgba(79, 156, 249, 0.16), 0 0 22px rgba(79, 156, 249, 0.18);
}

.primary {
  position: relative;
  border: 0;
  border-radius: 11px;
  padding: 12px 18px;
  background: linear-gradient(135deg, #5aa6ff, var(--accent) 45%, var(--accent-2));
  color: #050b16;
  font-weight: 650;
  font-size: 14.5px;
  overflow: hidden;
  transition: transform 0.12s var(--ease), box-shadow 0.25s var(--ease), filter 0.2s var(--ease);
  box-shadow: 0 10px 26px rgba(79, 156, 249, 0.25);
}

.primary > span { position: relative; z-index: 1; }

.primary::after {
  content: "";
  position: absolute;
  top: 0;
  left: -60%;
  width: 40%;
  height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: skewX(-18deg);
  transition: left 0.55s var(--ease);
}

.primary:hover { filter: brightness(1.05); box-shadow: 0 14px 34px rgba(79, 156, 249, 0.34); }
.primary:hover::after { left: 130%; }
.primary:active { transform: translateY(1px) scale(0.995); }
.primary:disabled { opacity: 0.6; cursor: default; }

.ghost {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 10px;
  padding: 11px 16px;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}

.ghost:hover { background: rgba(255, 255, 255, 0.05); border-color: var(--border-strong); }

.form-error {
  margin: 2px 0 0;
  min-height: 18px;
  font-size: 13px;
  color: var(--danger);
}

.auth-note {
  margin: 16px 0 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
  text-align: center;
}

/* ================= приложение ================= */

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 296px 1fr;
  height: 100dvh;
  animation: fadeIn 0.45s var(--ease) both;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: linear-gradient(180deg, rgba(15, 21, 33, 0.82), rgba(10, 15, 24, 0.88));
  border-right: 1px solid var(--border);
  backdrop-filter: blur(16px);
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 10px;
}

.me {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: #06101f;
  background: linear-gradient(135deg, #7cc0ff, #a99bff);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12) inset, 0 4px 14px rgba(79, 156, 249, 0.25);
  flex: none;
  text-transform: uppercase;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.avatar:hover { transform: scale(1.06); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2) inset, 0 6px 18px rgba(79, 156, 249, 0.4); }

.me-text { min-width: 0; display: grid; }

.me-text strong {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.icon {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), transform 0.2s var(--ease);
}

.icon:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  transform: translateY(-1px);
}

.search-wrap {
  position: relative;
  padding: 4px 14px 10px;
}

.search-wrap input {
  width: 100%;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.search-wrap input:focus {
  border-color: rgba(79, 156, 249, 0.6);
  box-shadow: 0 0 0 3px rgba(79, 156, 249, 0.12);
}

.search-results {
  position: absolute;
  left: 14px;
  right: 14px;
  top: 46px;
  z-index: 20;
  background: rgba(19, 25, 38, 0.97);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 6px;
  max-height: 300px;
  overflow: auto;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.6);
  animation: dropIn 0.18s var(--ease) both;
}

@keyframes dropIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.search-item {
  display: flex;
  gap: 9px;
  align-items: center;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px;
  border-radius: 9px;
  transition: background 0.15s var(--ease), transform 0.15s var(--ease);
}

.search-item:hover {
  background: rgba(79, 156, 249, 0.12);
  transform: translateX(2px);
}

.search-item small {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
}

.search-empty {
  padding: 10px;
  font-size: 13px;
  color: var(--muted);
}

.rooms {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 8px 12px;
}

.rooms-title {
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 8px 6px;
}

.room-group { display: grid; gap: 2px; }

.room {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 9px 10px;
  border-radius: 11px;
  text-align: left;
  color: var(--text);
  transition: background 0.18s var(--ease), transform 0.18s var(--ease);
  animation: roomIn 0.3s var(--ease) both;
}

.room:hover {
  background: rgba(255, 255, 255, 0.05);
  transform: translateX(2px);
}

.room.active {
  background: linear-gradient(90deg, rgba(79, 156, 249, 0.18), rgba(139, 123, 255, 0.08));
  box-shadow: 0 0 0 1px rgba(79, 156, 249, 0.22) inset;
}

.room.active::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 12%;
  bottom: 12%;
  width: 3px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 12px rgba(79, 156, 249, 0.8);
  animation: barIn 0.25s var(--ease) both;
}

@keyframes barIn {
  from { transform: scaleY(0.2); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@keyframes roomIn {
  from { opacity: 0; transform: translateX(-6px); }
  to { opacity: 1; transform: none; }
}

.room-body {
  min-width: 0;
  flex: 1;
  display: grid;
}

.room-title {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-sub {
  font-size: 11.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #050b16;
  font-size: 11.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex: none;
  animation: badgePulse 2.4s ease-in-out infinite;
  box-shadow: 0 0 14px rgba(79, 156, 249, 0.55);
}

@keyframes badgePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(79, 156, 249, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(79, 156, 249, 0); }
}

.sidebar-foot {
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border);
}

.link {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  padding: 0;
  transition: color 0.2s var(--ease);
}

.link:hover { color: var(--accent); }

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: linear-gradient(180deg, rgba(8, 12, 20, 0.35), rgba(6, 9, 17, 0.62));
  backdrop-filter: blur(6px);
}

.main-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(12, 17, 27, 0.55);
  backdrop-filter: blur(14px);
}

.burger { display: none; }

.room-info { min-width: 0; flex: 1; }

.room-info h2 {
  margin: 0;
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-info p {
  margin: 1px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.presence {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: #b9f7e2;
  background: rgba(75, 227, 176, 0.09);
  border: 1px solid rgba(75, 227, 176, 0.22);
  transition: transform 0.2s var(--ease);
}

.presence:hover { transform: translateY(-1px); }

.presence i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 10px var(--mint);
  animation: dotPulse 2s ease-in-out infinite;
}

.presence b { font-weight: 650; }

@keyframes dotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.82); }
}

.conn {
  font-size: 12px;
  color: var(--muted);
  transition: color 0.25s var(--ease);
}

.conn.on {
  color: var(--mint);
  animation: dotPulse 2.6s ease-in-out infinite;
}

.conn.off { color: var(--danger); }

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 20px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.empty {
  margin: auto;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  max-width: 340px;
  animation: fadeUp 0.5s var(--ease) both;
}

.day-sep {
  align-self: center;
  margin: 14px 0 8px;
  font-size: 11.5px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  padding: 3px 12px;
  border-radius: 999px;
  backdrop-filter: blur(6px);
  animation: fadeIn 0.3s var(--ease) both;
}

.msg {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  padding: 5px 0;
  max-width: 780px;
  animation: msgIn 0.34s var(--ease) both;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(10px) scale(0.99); filter: blur(2px); }
  to { opacity: 1; transform: none; filter: blur(0); }
}

.msg.own { grid-template-columns: minmax(0, 1fr) 34px; }
.msg.own .msg-body { justify-items: end; }
.msg.own .msg-head { flex-direction: row-reverse; }
.msg-avatar { grid-row: span 2; }
.msg.own .msg-avatar { grid-column: 2; grid-row: span 2; }

.msg-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
}

.msg-head strong { color: var(--text); font-size: 13px; font-weight: 650; }

.bubble {
  max-width: 100%;
  width: fit-content;
  display: grid;
  gap: 8px;
  background: rgba(24, 31, 45, 0.85);
  border: 1px solid var(--border);
  border-radius: 13px 13px 13px 4px;
  padding: 8px 12px;
  font-size: 14.5px;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), transform 0.2s var(--ease);
}

.bubble-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.bubble-meta {
  display: flex;
  justify-content: flex-start;
  margin-top: -5px;
  font-size: 11px;
  line-height: 1;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.msg.own .bubble-meta { justify-content: flex-end; }

.msg.own .bubble.has-preview .bubble-text { text-align: right; }

.bubble.media-only { padding: 5px; }

.bubble:hover {
  border-color: var(--border-strong);
  background: rgba(28, 36, 52, 0.92);
}

.msg.own .bubble {
  background: linear-gradient(135deg, rgba(79, 156, 249, 0.2), rgba(139, 123, 255, 0.14));
  border-color: rgba(79, 156, 249, 0.3);
  border-radius: 13px 13px 4px 13px;
  box-shadow: 0 6px 22px rgba(79, 156, 249, 0.12);
}

.msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12.5px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text);
  align-self: start;
  text-transform: uppercase;
  overflow: hidden;
}

.msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.msg-avatar.ghost {
  background: transparent;
  border-color: transparent;
}

.typing {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px 8px;
  font-size: 12.5px;
  color: var(--muted);
  min-height: 20px;
  animation: fadeIn 0.2s var(--ease) both;
}

.typing-dots { display: inline-flex; gap: 3px; }

.typing-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: typingBounce 1.1s ease-in-out infinite;
}

.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.composer {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--border);
  background: rgba(12, 17, 27, 0.62);
  backdrop-filter: blur(14px);
}

.composer-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.composer textarea {
  flex: 1;
  resize: none;
  max-height: 180px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 11px 13px;
  font-size: 14.5px;
  line-height: 1.45;
  outline: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.25s var(--ease), background 0.2s var(--ease);
}

.composer textarea:focus {
  border-color: rgba(79, 156, 249, 0.6);
  background: rgba(79, 156, 249, 0.05);
  box-shadow: 0 0 0 3px rgba(79, 156, 249, 0.12), 0 0 26px rgba(79, 156, 249, 0.12);
}

.composer textarea::-webkit-scrollbar { width: 8px; }
.composer textarea::-webkit-scrollbar-thumb { border-width: 2px; }
.composer textarea::-webkit-scrollbar-thumb:hover { border-width: 1px; }

.send {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 12px;
  flex: none;
  opacity: 0.55;
  transition: opacity 0.25s var(--ease), transform 0.2s var(--ease), box-shadow 0.25s var(--ease);
}

.send svg { stroke: #050b16; }

.composer.has-text .send {
  opacity: 1;
  box-shadow: 0 8px 26px rgba(79, 156, 249, 0.45);
}

.composer.has-text .send:hover { transform: translateY(-2px) rotate(-4deg); }

/* ================= модалка и тост ================= */

.modal {
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(22, 29, 44, 0.98), rgba(13, 18, 29, 0.99));
  color: var(--text);
  padding: 22px;
  width: min(420px, calc(100vw - 32px));
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.65);
}

.modal[open] { animation: cardIn 0.28s var(--ease) both; }

.modal::backdrop { background: rgba(3, 6, 12, 0.62); backdrop-filter: blur(4px); }

.modal h3 { margin: 0 0 16px; font-size: 17px; }

.modal .form { gap: 14px; }

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

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: rgba(21, 28, 42, 0.97);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 11px;
  font-size: 13.5px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(79, 156, 249, 0.12) inset;
  z-index: 50;
  animation: toastIn 0.3s var(--ease) both;
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 12, 0.55);
  backdrop-filter: blur(2px);
  z-index: 5;
  animation: fadeIn 0.2s var(--ease) both;
}

/* ================= адаптив ================= */

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 288px;
    z-index: 10;
    transform: translateX(-102%);
    transition: transform 0.26s var(--ease);
    box-shadow: 24px 0 60px rgba(0, 0, 0, 0.5);
  }

  .sidebar.open { transform: none; }

  .burger { display: grid; }

  .messages { padding: 14px 12px 6px; }

  .composer { padding: 10px 12px 12px; }

  .typing { padding: 0 12px 6px; }

  .msg { max-width: 100%; }

  .presence { padding: 3px 8px; font-size: 11px; }

  .blob { filter: blur(56px); opacity: 0.45; }
}

/* ================= доступность ================= */

/* ================= аватарки, ответы, удаление ================= */

.avatar { overflow: hidden; position: relative; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.avatar-big {
  width: 64px;
  height: 64px;
  font-size: 22px;
}

.avatar-edit {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.avatar-actions {
  display: grid;
  gap: 6px;
  justify-items: start;
}

.avatar-actions .ghost {
  padding: 8px 14px;
  font-size: 13px;
}

.avatar-actions .link { font-size: 12.5px; }

.reply-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(79, 156, 249, 0.26);
  border-left: 3px solid var(--accent);
  background: rgba(79, 156, 249, 0.08);
  animation: fadeUp 0.2s var(--ease) both;
}

.reply-body {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.reply-author {
  font-size: 12px;
  font-weight: 650;
  color: var(--accent);
}

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

.msg { position: relative; }

.msg-actions {
  position: absolute;
  top: 2px;
  right: 0;
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: 9px;
  background: rgba(15, 21, 33, 0.94);
  border: 1px solid var(--border);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.15s var(--ease), transform 0.15s var(--ease);
  z-index: 2;
}

.msg.own .msg-actions { right: 42px; }

.msg:hover .msg-actions,
.msg-actions:focus-within {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

.msg-action {
  border: 0;
  background: transparent;
  color: var(--muted);
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.msg-action:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }
.msg-action.danger:hover { background: rgba(255, 107, 129, 0.18); color: var(--danger); }
.msg-action svg { width: 15px; height: 15px; }

.quote {
  display: grid;
  gap: 1px;
  padding: 6px 9px;
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: rgba(79, 156, 249, 0.1);
  font-size: 12.5px;
  max-width: 100%;
  cursor: pointer;
  transition: background 0.15s var(--ease);
}

.quote:hover { background: rgba(79, 156, 249, 0.18); }

.quote-author {
  font-weight: 650;
  color: var(--accent);
  font-size: 12px;
}

.quote-text {
  color: var(--text);
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg.flash .bubble {
  animation: flashPulse 1.1s var(--ease);
}

@keyframes flashPulse {
  0% { box-shadow: 0 0 0 0 rgba(79, 156, 249, 0.6); }
  100% { box-shadow: 0 0 0 14px rgba(79, 156, 249, 0); }
}

.popmenu {
  position: fixed;
  z-index: 60;
  display: grid;
  padding: 6px;
  border-radius: 12px;
  background: rgba(20, 27, 40, 0.98);
  border: 1px solid var(--border-strong);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  animation: dropIn 0.15s var(--ease) both;
}

.popmenu button {
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  white-space: nowrap;
}

.popmenu button:hover { background: rgba(79, 156, 249, 0.14); }

.popmenu button[data-scope="all"] { color: var(--danger); }
.popmenu button[data-scope="all"]:hover { background: rgba(255, 107, 129, 0.14); }

@media (max-width: 820px) {
  .avatar-big { width: 56px; height: 56px; }
  .msg.own .msg-actions { right: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  .aurora { transform: none; }
  .blob { animation: none; }
  .msg.flash .bubble { animation: none; }
}

/* ================= живой слой и инструменты ================= */

.bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.cursor-glow {
  position: fixed;
  left: 0;
  top: 0;
  width: 520px;
  height: 520px;
  margin: -260px 0 0 -260px;
  border-radius: 50%;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.45s ease;
  will-change: transform;
  background: radial-gradient(circle, rgba(79, 156, 249, 0.13), rgba(139, 123, 255, 0.06) 45%, transparent 70%);
}

.tool {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 11px;
  font-size: 17px;
  line-height: 1;
  color: var(--text);
  transition: transform 0.18s var(--ease), background 0.18s var(--ease), border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

.tool:hover {
  transform: translateY(-2px);
  background: rgba(79, 156, 249, 0.14);
  border-color: rgba(79, 156, 249, 0.35);
  box-shadow: 0 8px 20px rgba(79, 156, 249, 0.18);
}

.tool:active { transform: translateY(0) scale(0.96); }
.tool svg { width: 17px; height: 17px; }

.emoji-panel {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 78px;
  max-height: 238px;
  overflow-y: auto;
  padding: 10px;
  border-radius: 14px;
  background: rgba(18, 24, 37, 0.98);
  border: 1px solid var(--border-strong);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  z-index: 30;
  animation: dropIn 0.18s var(--ease) both;
  scrollbar-width: thin;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  gap: 2px;
}

.emoji {
  border: 0;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  padding: 7px 0;
  border-radius: 8px;
  transition: background 0.15s var(--ease), transform 0.15s var(--ease);
}

.emoji:hover {
  background: rgba(79, 156, 249, 0.18);
  transform: scale(1.16);
}

.attach-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.attach-item {
  position: relative;
  width: 74px;
  height: 74px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
  animation: fadeUp 0.22s var(--ease) both;
}

.attach-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.attach-item.uploading::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(79, 156, 249, 0.35), transparent);
  animation: shimmer 1.1s linear infinite;
}

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

.attach-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 0;
  background: rgba(0, 0, 0, 0.66);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background 0.15s var(--ease), transform 0.15s var(--ease);
}

.attach-remove:hover { background: rgba(255, 107, 129, 0.85); transform: scale(1.08); }

.msg-files {
  display: grid;
  gap: 6px;
  margin-top: 0;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  max-width: 100%;
}

.msg-file {
  display: block;
  border-radius: 11px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: rgba(10, 15, 24, 0.6);
}

.msg-file img {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  transition: transform 0.4s var(--ease);
}

.msg-file:hover img { transform: scale(1.05); }

.link-card {
  display: flex;
  gap: 10px;
  margin-top: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(15, 21, 33, 0.78);
  text-decoration: none;
  color: inherit;
  max-width: 430px;
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.link-card:hover {
  border-color: rgba(79, 156, 249, 0.45);
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.link-thumb {
  position: relative;
  width: 96px;
  height: 96px;
  flex: none;
  background: #0b1220;
}

.link-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.link-play::after {
  content: "▶";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 21px;
  color: #fff;
  background: rgba(0, 0, 0, 0.28);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.7);
}

.link-body {
  padding: 8px 10px;
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 3px;
}

.link-site {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-title {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.link-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (max-width: 820px) {
  .link-thumb { width: 78px; height: 78px; }
  .msg-files { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
  .emoji-panel { left: 12px; right: 12px; bottom: 74px; max-height: 200px; }
}
