/* ═══════════════════════════════════════════
   BULGAKOV v2 — ПОЛНОСТЬЮ ПЕРЕРАБОТАННЫЕ СТИЛИ
   Версия 3.0 — плавные анимации, чистые кружки
═══════════════════════════════════════════ */

:root {
  --bg:     #0a0a0a;
  --s1:     #101010;
  --s2:     #171717;
  --s3:     #1f1f1f;
  --s4:     #272727;
  --b1:     #252525;
  --b2:     #303030;
  --b3:     #3a3a3a;

  --t:      #efefef;
  --t2:     #828282;
  --t3:     #4a4a4a;

  --acc-a:  rgba(255,255,255,0.055);
  --acc-h:  rgba(255,255,255,0.09);
  --acc-p:  rgba(255,255,255,0.14);

  --danger: #c94f4f;
  --ok:     #3d9e3d;

  --r:      10px;
  --r-sm:   6px;
  --r-xs:   4px;

  /* Анимации */
  --tr:     0.18s cubic-bezier(0.4,0,0.2,1);
  --tr-s:   0.12s cubic-bezier(0.4,0,0.2,1);
  --tr-l:   0.28s cubic-bezier(0.4,0,0.2,1);
  --spring: cubic-bezier(0.34,1.56,0.64,1);

  --font:   'IBM Plex Sans', -apple-system, sans-serif;
  --font-d: 'Playfair Display', Georgia, serif;
  --font-m: 'IBM Plex Mono', monospace;
  --sw:     272px;
}

/* ══ СБРОС ══ */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--t);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { cursor: pointer; border: none; background: none; color: inherit; font-family: inherit; }
input  { font-family: inherit; outline: none; color: inherit; }
.hidden { display: none !important; }

/* ══════════════════════════════════════
   AUTH
══════════════════════════════════════ */
.auth-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); z-index: 1000;
  animation: authFadeIn 0.5s ease;
}
@keyframes authFadeIn {
  from { opacity: 0; } to { opacity: 1; }
}
.auth-card {
  width: 360px; max-width: calc(100vw - 32px);
  padding: 52px 40px;
  text-align: center;
  animation: authSlideUp 0.45s var(--spring);
}
@keyframes authSlideUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}
.auth-logo { display: flex; align-items: baseline; justify-content: center; margin-bottom: 6px; }
.logo-b    { font-family: var(--font-d); font-size: 72px; font-weight: 700; font-style: italic; line-height: 1; color: var(--t); }
.logo-rest { font-family: var(--font-d); font-size: 36px; font-weight: 400; font-style: italic; color: var(--t2); }
.auth-tagline { color: var(--t3); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 40px; }

.auth-tabs { display: flex; border-bottom: 1px solid var(--b1); margin-bottom: 22px; }
.auth-tab  {
  flex: 1; padding: 11px; font-size: 13px; font-weight: 500; color: var(--t2);
  border-bottom: 2px solid transparent;
  transition: color var(--tr), border-color var(--tr);
}
.auth-tab.active { color: var(--t); border-bottom-color: var(--t); }
.auth-step { display: none; }
.auth-step.active { display: block; animation: stepIn 0.22s ease; }
@keyframes stepIn {
  from { opacity: 0; transform: translateX(8px); }
  to   { opacity: 1; transform: translateX(0); }
}

.input-group  { margin-bottom: 11px; text-align: left; }
.input-label  {
  display: block; font-size: 10.5px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--t3); margin-bottom: 5px;
}
.auth-input {
  width: 100%;
  background: var(--s2);
  border: 1px solid var(--b1);
  color: var(--t);
  padding: 12px 15px;
  border-radius: var(--r-sm);
  font-size: 14px;
  transition: border-color var(--tr), box-shadow var(--tr);
}
.auth-input:focus {
  border-color: var(--b3);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.04);
}
.auth-input::placeholder { color: var(--t3); }

.btn-primary {
  width: 100%; padding: 13px;
  background: var(--t); color: var(--bg);
  font-size: 14px; font-weight: 600;
  border-radius: var(--r-sm);
  transition: opacity var(--tr), transform var(--tr-s), box-shadow var(--tr);
  margin-top: 8px; letter-spacing: .025em;
}
.btn-primary:hover  { opacity: .88; box-shadow: 0 4px 16px rgba(255,255,255,.1); }
.btn-primary:active { transform: scale(.97); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }

.btn-ghost {
  width: 100%; padding: 11px;
  background: transparent; color: var(--t2);
  font-size: 13px; border-radius: var(--r-sm);
  transition: color var(--tr), background var(--tr);
  margin-top: 8px;
}
.btn-ghost:hover { color: var(--t); background: var(--acc-a); }

.btn-danger {
  width: 100%; padding: 11px;
  background: transparent; color: var(--danger);
  font-size: 13px; border: 1px solid rgba(201,79,79,.22);
  border-radius: var(--r-sm);
  transition: background var(--tr), border-color var(--tr);
}
.btn-danger:hover { background: rgba(201,79,79,.07); border-color: rgba(201,79,79,.4); }

.auth-error  { font-size: 12px; color: var(--danger); margin-top: 9px; min-height: 18px; text-align: left; animation: shake .25s ease; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25%      { transform: translateX(-5px); }
  75%      { transform: translateX(5px); }
}
.auth-footer { color: var(--t3); font-size: 11px; margin-top: 36px; }

/* ══════════════════════════════════════
   APP SHELL
══════════════════════════════════════ */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ══════════════════════════════════════
   SIDEBAR
══════════════════════════════════════ */
.sidebar {
  width: var(--sw); min-width: var(--sw);
  background: var(--s1);
  border-right: 1px solid var(--b1);
  display: flex; flex-direction: column;
  height: 100%; overflow: hidden;
  position: relative; z-index: 10;
  transition: transform var(--tr-l);
}

.sidebar-top {
  display: flex; align-items: center; gap: 8px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--b1);
  min-height: 54px;
}
.app-logo-sm {
  width: 33px; height: 33px;
  background: var(--t); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-d); font-size: 21px; font-weight: 700; font-style: italic;
  color: var(--bg); flex-shrink: 0;
  transition: transform var(--tr-s), box-shadow var(--tr);
}
.app-logo-sm:hover { transform: scale(1.05); box-shadow: 0 4px 14px rgba(255,255,255,.12); }
.app-logo-sm:active { transform: scale(.95); }

.sidebar-nav { display: flex; gap: 3px; flex: 1; }
.nav-btn {
  flex: 1; padding: 8px;
  border-radius: var(--r-sm);
  color: var(--t2);
  display: flex; align-items: center; justify-content: center;
  transition: color var(--tr), background var(--tr), transform var(--tr-s);
  position: relative;
}
.nav-btn:hover  { color: var(--t); background: var(--acc-a); }
.nav-btn:active { transform: scale(.9); }
.nav-btn.active { color: var(--t); background: var(--acc-h); }
.nav-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 50%; transform: translateX(-50%);
  width: 14px; height: 2px;
  background: var(--t); border-radius: 2px;
}

.sidebar-content { flex: 1; overflow: hidden; display: flex; flex-direction: column; }

.search-wrap {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 13px;
  border-bottom: 1px solid var(--b1);
  color: var(--t3);
  transition: color var(--tr);
}
.search-wrap:focus-within { color: var(--t2); }
.search-wrap input { flex: 1; background: transparent; font-size: 13px; }
.search-wrap input::placeholder { color: var(--t3); }

.tab { display: none; flex-direction: column; flex: 1; overflow-y: auto; }
.tab.active { display: flex; animation: tabIn 0.18s ease; }
@keyframes tabIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.tab::-webkit-scrollbar { width: 3px; }
.tab::-webkit-scrollbar-thumb { background: var(--b1); border-radius: 2px; }

.sec-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 13px 5px;
  color: var(--t3); font-size: 10px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
}

.icon-btn {
  width: 27px; height: 27px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  color: var(--t2);
  transition: color var(--tr), background var(--tr), transform var(--tr-s);
  flex-shrink: 0;
}
.icon-btn:hover  { color: var(--t); background: var(--acc-a); }
.icon-btn:active { transform: scale(.85); }

.conv-list { display: flex; flex-direction: column; }

.ci {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 13px;
  cursor: pointer;
  transition: background var(--tr);
  position: relative;
  border-left: 2px solid transparent;
}
.ci:hover  { background: var(--acc-a); }
.ci.active { background: var(--acc-h); border-left-color: var(--t); }
.ci-av {
  width: 37px; height: 37px; border-radius: 50%;
  background: var(--s3); border: 1px solid var(--b1);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600;
  overflow: hidden; flex-shrink: 0; position: relative;
  transition: transform var(--tr-s);
}
.ci:hover .ci-av { transform: scale(1.04); }
.ci-av.sq { border-radius: 8px; }
.ci-av img { width: 100%; height: 100%; object-fit: cover; }

.online-dot {
  width: 9px; height: 9px;
  background: var(--ok); border-radius: 50%;
  border: 2px solid var(--s1);
  position: absolute; bottom: 0; right: 0;
  animation: onlinePop .3s var(--spring);
}
@keyframes onlinePop {
  from { transform: scale(0); }
  to   { transform: scale(1); }
}

.ci-info { flex: 1; min-width: 0; }
.ci-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-prev { font-size: 11.5px; color: var(--t2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.ci-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; }
.ci-time  { font-size: 10px; color: var(--t3); font-family: var(--font-m); }
.ci-badge {
  background: var(--t); color: var(--bg);
  font-size: 10px; font-weight: 700;
  padding: 1px 5px; border-radius: 9px; min-width: 17px; text-align: center;
  animation: badgePop .25s var(--spring);
}
@keyframes badgePop {
  from { transform: scale(0); }
  to   { transform: scale(1); }
}

/* Servers */
.server-entry  { display: flex; flex-direction: column; }
.server-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 13px; cursor: pointer;
  transition: background var(--tr);
}
.server-row:hover { background: var(--acc-a); }
.server-icon {
  width: 35px; height: 35px;
  background: var(--s3); border: 1px solid var(--b1);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
  transition: transform var(--tr-s);
}
.server-row:hover .server-icon { transform: scale(1.06); }
.server-chevron {
  margin-left: auto; color: var(--t3);
  transition: transform var(--tr); font-size: 11px;
}
.server-channels { padding-left: 48px; display: none; flex-direction: column; }
.server-channels.open { display: flex; animation: tabIn .15s ease; }
.sch {
  padding: 5px 12px; font-size: 12px; color: var(--t2);
  cursor: pointer; border-radius: var(--r-sm);
  display: flex; align-items: center; gap: 5px;
  transition: color var(--tr), background var(--tr);
}
.sch:hover  { color: var(--t); background: var(--acc-a); }
.sch.active { color: var(--t); background: var(--acc-h); }

/* Sidebar footer */
.sidebar-footer {
  border-top: 1px solid var(--b1);
  padding: 10px 11px;
  display: flex; align-items: center; gap: 6px;
}
.my-profile {
  display: flex; align-items: center; gap: 9px;
  flex: 1; cursor: pointer;
  padding: 6px 7px; border-radius: var(--r-sm);
  transition: background var(--tr); min-width: 0;
}
.my-profile:hover { background: var(--acc-a); }
.my-avatar {
  width: 31px; height: 31px; border-radius: 50%;
  background: var(--s2); border: 1px solid var(--b2);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; overflow: hidden; flex-shrink: 0;
  transition: transform var(--tr-s);
}
.my-profile:hover .my-avatar { transform: scale(1.08); }
.my-avatar img { width: 100%; height: 100%; object-fit: cover; }
.my-info   { min-width: 0; }
.my-name   { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.my-status { font-size: 11px; color: var(--ok); display: block; }

/* ══════════════════════════════════════
   MAIN CHAT AREA
══════════════════════════════════════ */
.main { flex: 1; display: flex; flex-direction: column; height: 100%; overflow: hidden; background: var(--bg); }

.empty-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--t3); gap: 10px;
  animation: authFadeIn .6s ease;
}
.empty-b    { font-family: var(--font-d); font-size: 96px; font-style: italic; font-weight: 700; color: var(--s3); line-height: 1; }
.empty-state h2 { font-family: var(--font-d); font-size: 22px; font-style: italic; color: var(--s4); }
.empty-state p  { font-size: 13px; }

.chat-view { display: flex; flex-direction: column; height: 100%; animation: chatIn .2s ease; }
@keyframes chatIn {
  from { opacity: 0; } to { opacity: 1; }
}

/* Chat header */
.chat-hdr {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 15px;
  border-bottom: 1px solid var(--b1);
  background: var(--s1); min-height: 54px;
}
.back-btn {
  display: none; width: 30px; height: 30px;
  align-items: center; justify-content: center;
  border-radius: var(--r-sm); color: var(--t2);
  transition: color var(--tr), background var(--tr);
}
.back-btn:hover { color: var(--t); background: var(--acc-a); }
.chat-hdr-info {
  display: flex; align-items: center; gap: 10px;
  flex: 1; cursor: pointer; min-width: 0;
  padding: 4px; border-radius: var(--r-sm);
  transition: background var(--tr);
}
.chat-hdr-info:hover { background: var(--acc-a); }
.chat-hdr-av {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--s2); border: 1px solid var(--b1);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; overflow: hidden; flex-shrink: 0;
  transition: transform var(--tr-s);
}
.chat-hdr-info:hover .chat-hdr-av { transform: scale(1.06); }
.chat-hdr-av img { width: 100%; height: 100%; object-fit: cover; }
.chat-hdr-av.sq { border-radius: 8px; }
.chat-hdr-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-hdr-sub  { font-size: 11.5px; color: var(--t2); }
.chat-hdr-btns { display: flex; gap: 3px; }

/* Messages */
.msgs-area {
  flex: 1; overflow-y: auto; padding: 14px 16px;
  display: flex; flex-direction: column;
  scroll-behavior: smooth;
}
.msgs-area::-webkit-scrollbar { width: 3px; }
.msgs-area::-webkit-scrollbar-thumb { background: var(--b1); border-radius: 2px; }

#msgs-list { display: flex; flex-direction: column; gap: 2px; margin-top: auto; }

.date-sep {
  display: flex; align-items: center; gap: 10px;
  color: var(--t3); font-size: 10.5px;
  margin: 14px 0 8px; font-family: var(--font-m);
}
.date-sep::before,.date-sep::after { content: ''; flex: 1; height: 1px; background: var(--b1); }

/* Message groups */
.mg { display: flex; flex-direction: column; margin: 1px 0; }
.mg.own   { align-items: flex-end; }
.mg.other { align-items: flex-start; }

.mg-hdr {
  display: flex; align-items: center; gap: 6px;
  padding: 0 4px; margin-bottom: 3px;
}
.mg.own .mg-hdr { flex-direction: row-reverse; }
.mg-av {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--s2); display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 600; overflow: hidden; flex-shrink: 0;
}
.mg-av img { width: 100%; height: 100%; object-fit: cover; }
.mg-sender { font-size: 11px; font-weight: 500; color: var(--t2); }

/* Bubbles */
.bubble {
  max-width: 62%;
  padding: 8px 12px;
  border-radius: 14px;
  word-break: break-word;
  font-size: 14px; line-height: 1.52;
  cursor: pointer;
  animation: bubbleIn .16s var(--spring);
  position: relative;
  transition: opacity var(--tr-s);
}
.bubble:hover { opacity: .93; }
@keyframes bubbleIn {
  from { opacity: 0; transform: scale(.92) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.mg.own   .bubble { background: var(--s2); border: 1px solid var(--b1); border-bottom-right-radius: 3px; }
.mg.other .bubble { background: var(--s3); border: 1px solid var(--b2); border-bottom-left-radius: 3px; }

.bubble.emoji-only { background: none !important; border: none !important; font-size: 48px; padding: 2px 4px !important; }

.msg-reply {
  background: rgba(0,0,0,.25);
  border-left: 2px solid var(--t3);
  padding: 4px 8px; border-radius: 4px;
  margin-bottom: 6px; font-size: 12px; color: var(--t2);
}
.msg-reply-name { font-weight: 600; color: var(--t); font-size: 11px; margin-bottom: 1px; }
.msg-txt   { white-space: pre-wrap; }
.msg-time  {
  font-size: 10px; color: var(--t3);
  font-family: var(--font-m);
  float: right; margin-left: 8px; margin-top: 3px;
}

/* Image */
.msg-img {
  max-width: 240px; max-height: 280px;
  border-radius: 10px; object-fit: cover; display: block; cursor: zoom-in;
  transition: transform var(--tr-s);
}
.msg-img:hover { transform: scale(1.02); }

/* File */
.msg-file { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.msg-file-icon {
  width: 38px; height: 38px;
  background: var(--s4); border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 18px;
  transition: background var(--tr);
}
.msg-file:hover .msg-file-icon { background: var(--b1); }
.msg-file-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.msg-file-sz   { font-size: 11px; color: var(--t2); margin-top: 1px; }

/* ══════════════════════════════════════
   КРУЖКИ — ПОЛНОСТЬЮ ПЕРЕРАБОТАНЫ
══════════════════════════════════════ */
.msg-circle-wrap {
  position: relative;
  width: 168px; height: 168px;
  cursor: pointer;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
/* Само видео — круглое, без встроенных контролов */
.msg-circle {
  width: 168px; height: 168px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  border: none;
  /* Убираем ЛЮБЫЕ нативные контролы */
  -webkit-media-controls: none;
}
/* Полностью скрываем все нативные элементы управления */
.msg-circle::-webkit-media-controls { display: none !important; }
.msg-circle::-webkit-media-controls-enclosure { display: none !important; }
.msg-circle::-webkit-media-controls-panel { display: none !important; }
.msg-circle::-webkit-media-controls-play-button { display: none !important; }
.msg-circle::-webkit-media-controls-timeline { display: none !important; }

/* Кастомный оверлей поверх видео */
.circle-overlay-ui {
  position: absolute; inset: 0;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0);
  transition: background var(--tr);
}
.msg-circle-wrap:hover .circle-overlay-ui { background: rgba(0,0,0,.28); }

/* Кнопка play/pause */
.circle-play-btn {
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255,255,255,.9);
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transform: scale(.7);
  transition: opacity var(--tr), transform var(--tr);
  flex-shrink: 0;
}
.msg-circle-wrap:hover .circle-play-btn,
.msg-circle-wrap.paused .circle-play-btn {
  opacity: 1;
  transform: scale(1);
}
.msg-circle-wrap.paused .circle-play-btn { opacity: .85; }
.circle-play-btn svg { color: #111; width: 18px; height: 18px; margin-left: 2px; }
.circle-play-btn.is-playing svg { margin-left: 0; }

/* Кольцо прогресса под видео */
.circle-progress-ring {
  position: absolute; inset: -3px;
  width: calc(100% + 6px); height: calc(100% + 6px);
  border-radius: 50%;
  pointer-events: none;
}
.ring-bg   { fill: none; stroke: rgba(255,255,255,.08); stroke-width: 3; }
.ring-fill {
  fill: none; stroke: rgba(255,255,255,.7);
  stroke-width: 3; stroke-linecap: round;
  transform: rotate(-90deg); transform-origin: 50% 50%;
  transition: stroke-dashoffset .1s linear;
}
/* Тонкая белая рамка */
.circle-border {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,.12);
  pointer-events: none;
}
/* Длительность */
.circle-duration {
  position: absolute; bottom: 12px; left: 50%;
  transform: translateX(-50%);
  font-size: 10px; font-family: var(--font-m);
  color: rgba(255,255,255,.75);
  background: rgba(0,0,0,.45);
  padding: 1px 6px; border-radius: 10px;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--tr);
}
.msg-circle-wrap:hover .circle-duration { opacity: 1; }

/* ══════════════════════════════════════
   ЗАПИСЬ КРУЖКА — ОВЕРЛЕЙ
══════════════════════════════════════ */
.circle-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.85);
  z-index: 400;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 20px;
  backdrop-filter: blur(10px);
  animation: authFadeIn .2s ease;
}
.circle-wrap {
  position: relative;
  width: 240px; height: 240px;
}
.circle-vid {
  width: 220px; height: 220px;
  border-radius: 50%;
  object-fit: cover;
  position: absolute; top: 10px; left: 10px;
}
/* Кольцо записи */
.circle-ring  { position: absolute; inset: 0; transform: rotate(-90deg); pointer-events: none; }
.cr-bg   { fill: none; stroke: rgba(255,255,255,.06); stroke-width: 4; }
.cr-fill {
  fill: none; stroke: var(--t);
  stroke-width: 4;
  stroke-dasharray: 691;
  stroke-dashoffset: 691;
  stroke-linecap: round;
  transition: stroke-dashoffset .1s linear;
}
/* Красная точка — идёт запись */
.rec-dot {
  position: absolute; top: 14px; right: 14px;
  width: 10px; height: 10px;
  background: #e04040; border-radius: 50%;
  display: none;
  animation: recBlink 1s infinite;
}
.recording .rec-dot { display: block; }
@keyframes recBlink {
  0%,100% { opacity: 1; } 50% { opacity: .2; }
}
.circle-rec-btns {
  display: flex; gap: 14px; align-items: center;
}

/* ══════════════════════════════════════
   TYPING INDICATOR
══════════════════════════════════════ */
.typing-row {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 6px; color: var(--t2);
  animation: bubbleIn .15s ease;
}
.t-dot {
  width: 5px; height: 5px;
  background: var(--t3); border-radius: 50%;
  animation: tdot 1.3s infinite;
}
.t-dot:nth-child(2) { animation-delay: .18s; }
.t-dot:nth-child(3) { animation-delay: .36s; }
@keyframes tdot {
  0%,60%,100% { opacity: .25; transform: scale(1); }
  30%          { opacity: 1;   transform: scale(1.35); }
}

/* ══════════════════════════════════════
   INPUT AREA
══════════════════════════════════════ */
.input-area {
  border-top: 1px solid var(--b1);
  background: var(--s1);
  padding: 9px 11px;
}
.reply-preview {
  display: flex; align-items: center; gap: 9px;
  background: var(--s2); border-radius: var(--r-sm);
  padding: 6px 9px; margin-bottom: 7px;
  font-size: 12px;
  animation: bubbleIn .15s ease;
}
.reply-line    { width: 2px; height: 28px; background: var(--t3); border-radius: 2px; flex-shrink: 0; }
.reply-body    { flex: 1; min-width: 0; }
.reply-from    { font-weight: 600; display: block; font-size: 11px; }
.reply-txt     { color: var(--t2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; font-size: 11.5px; }
.reply-close   { color: var(--t3); font-size: 13px; padding: 2px; transition: color var(--tr); }
.reply-close:hover { color: var(--t); }

.attach-row {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 4px 0; margin-bottom: 5px;
  animation: tabIn .15s ease;
}
.att-thumb {
  width: 54px; height: 54px; border-radius: 8px;
  overflow: hidden; border: 1px solid var(--b1); position: relative;
  animation: badgePop .2s var(--spring);
}
.att-thumb img,.att-thumb video { width: 100%; height: 100%; object-fit: cover; }
.att-rm {
  position: absolute; top: 2px; right: 2px;
  width: 15px; height: 15px;
  background: rgba(0,0,0,.75); color: #fff;
  border-radius: 50%; font-size: 9px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background var(--tr);
}
.att-rm:hover { background: var(--danger); }
.att-file {
  display: flex; align-items: center; gap: 5px;
  background: var(--s2); padding: 5px 9px;
  border-radius: var(--r-sm); border: 1px solid var(--b1);
  font-size: 11px; max-width: 160px;
  animation: badgePop .2s var(--spring);
}

.input-row { display: flex; align-items: flex-end; gap: 5px; }
.msg-inp-wrap {
  flex: 1;
  background: var(--s2); border: 1px solid var(--b1);
  border-radius: 11px; padding: 8px 12px;
  transition: border-color var(--tr), box-shadow var(--tr);
  max-height: 150px; overflow-y: auto;
}
.msg-inp-wrap:focus-within {
  border-color: var(--b3);
  box-shadow: 0 0 0 3px rgba(255,255,255,.03);
}
.msg-inp {
  min-height: 20px; max-height: 130px;
  overflow-y: auto; font-size: 14px; line-height: 1.5;
  outline: none; white-space: pre-wrap;
  word-break: break-word; color: var(--t);
}
.msg-inp:empty::before {
  content: attr(data-placeholder);
  color: var(--t3); pointer-events: none;
}
.send-btn {
  width: 36px; height: 36px;
  background: var(--t); color: var(--bg);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: opacity var(--tr), transform var(--tr-s), box-shadow var(--tr);
}
.send-btn:hover  { opacity: .88; box-shadow: 0 3px 12px rgba(255,255,255,.12); }
.send-btn:active { transform: scale(.88); }

/* ══════════════════════════════════════
   RIGHT PANEL
══════════════════════════════════════ */
.right-panel {
  width: 240px; min-width: 240px;
  background: var(--s1); border-left: 1px solid var(--b1);
  display: flex; flex-direction: column; overflow-y: auto;
  animation: rpSlideIn .2s ease;
}
@keyframes rpSlideIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
.rp-hdr {
  display: flex; align-items: center; justify-content: flex-end;
  padding: 10px 13px; border-bottom: 1px solid var(--b1); min-height: 54px;
}
#rp-body { padding: 18px; }
.rp-av {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--s2); margin: 0 auto 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700; overflow: hidden;
  border: 2px solid var(--b1);
  transition: transform var(--tr-s), box-shadow var(--tr);
}
.rp-av:hover { transform: scale(1.04); box-shadow: 0 0 0 3px rgba(255,255,255,.06); }
.rp-av img { width: 100%; height: 100%; object-fit: cover; }
.rp-name { text-align: center; font-size: 15px; font-weight: 600; }
.rp-user { text-align: center; font-size: 12px; color: var(--t2); margin-top: 3px; }
.rp-bio  { text-align: center; font-size: 12px; color: var(--t2); margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--b1); }
.rp-btns { display: flex; gap: 7px; margin-top: 14px; }
.rp-btn  {
  flex: 1; padding: 9px 4px;
  background: var(--s2); border: 1px solid var(--b1);
  border-radius: var(--r-sm); font-size: 11px; font-weight: 500;
  text-align: center; cursor: pointer;
  transition: background var(--tr), transform var(--tr-s);
  display: flex; flex-direction: column; align-items: center; gap: 5px;
}
.rp-btn:hover  { background: var(--s3); }
.rp-btn:active { transform: scale(.95); }

/* ══════════════════════════════════════
   EMOJI PANEL
══════════════════════════════════════ */
.emoji-panel {
  position: absolute; bottom: 74px; right: 13px;
  width: 305px; height: 265px;
  background: var(--s1); border: 1px solid var(--b1);
  border-radius: var(--r);
  z-index: 50; display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
  animation: emojiIn .18s var(--spring);
}
@keyframes emojiIn {
  from { opacity: 0; transform: scale(.92) translateY(8px); }
  to   { opacity: 1; transform: scale(1)   translateY(0); }
}
.emoji-tabs { display: flex; border-bottom: 1px solid var(--b1); }
.e-tab {
  flex: 1; padding: 10px; font-size: 12px; font-weight: 500;
  color: var(--t2); border-bottom: 2px solid transparent;
  transition: color var(--tr), border-color var(--tr);
}
.e-tab.active { color: var(--t); border-bottom-color: var(--t); }
.e-content { display: none; flex: 1; overflow-y: auto; padding: 8px; flex-wrap: wrap; gap: 2px; align-content: flex-start; }
.e-content.active { display: flex; }
.em-btn {
  width: 35px; height: 35px;
  display: flex; align-items: center; justify-content: center;
  font-size: 21px; border-radius: var(--r-sm); cursor: pointer;
  transition: background var(--tr), transform var(--tr-s);
}
.em-btn:hover  { background: var(--acc-a); transform: scale(1.2); }
.em-btn:active { transform: scale(1.05); }
.st-btn {
  width: 70px; height: 70px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm); cursor: pointer; font-size: 46px;
  transition: background var(--tr), transform var(--tr-s);
}
.st-btn:hover  { background: var(--acc-a); transform: scale(1.1); }
.st-btn:active { transform: scale(.95); }

/* ══════════════════════════════════════
   CALL OVERLAY
══════════════════════════════════════ */
.call-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.9);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(12px);
  animation: authFadeIn .25s ease;
}
.call-card {
  display: flex; flex-direction: column; align-items: center;
  gap: 16px; padding: 36px; min-width: 300px;
  animation: authSlideUp .3s var(--spring);
}
.call-av {
  width: 96px; height: 96px; border-radius: 50%;
  background: var(--s2); border: 2px solid var(--b1);
  display: flex; align-items: center; justify-content: center;
  font-size: 38px; font-weight: 700; overflow: hidden;
}
.call-av img { width: 100%; height: 100%; object-fit: cover; }

/* Пульсирующие кольца */
.call-av-wrap { position: relative; display: flex; align-items: center; justify-content: center; }
.call-ring {
  position: absolute;
  width: 96px; height: 96px; border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,.12);
  animation: callRing 2s infinite;
}
.call-ring:nth-child(2) { animation-delay: .5s; }
.call-ring:nth-child(3) { animation-delay: 1s; }
@keyframes callRing {
  0%   { transform: scale(1);   opacity: .4; }
  100% { transform: scale(2.4); opacity: 0; }
}

.call-name   { font-size: 22px; font-weight: 600; }
.call-status { font-size: 13px; color: var(--t2); }

.video-box {
  position: relative; width: 560px; max-width: 90vw;
  border-radius: var(--r); overflow: hidden; background: #000;
  box-shadow: 0 12px 40px rgba(0,0,0,.6);
}
.remote-vid { width: 100%; display: block; max-height: 360px; object-fit: cover; }
.local-vid  {
  position: absolute; bottom: 12px; right: 12px;
  width: 112px; height: 82px; object-fit: cover;
  border-radius: var(--r-sm); border: 1.5px solid rgba(255,255,255,.15);
  transition: transform var(--tr-s);
}
.local-vid:hover { transform: scale(1.04); }

.screen-box { width: 680px; max-width: 92vw; border-radius: var(--r); overflow: hidden; background: #000; }
.screen-vid { width: 100%; max-height: 430px; object-fit: contain; display: block; }

.call-btns    { display: flex; gap: 10px; align-items: center; }
.incoming-btns { display: flex; gap: 16px; }
.call-btn {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--s2); border: 1px solid var(--b1);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--tr), transform var(--tr-s), box-shadow var(--tr);
}
.call-btn:hover  { background: var(--s3); box-shadow: 0 4px 16px rgba(0,0,0,.4); }
.call-btn:active { transform: scale(.9); }
.call-btn.active { background: var(--s3); border-color: var(--t); }
.call-btn.muted  { background: rgba(201,79,79,.18); border-color: var(--danger); }
.call-end    { background: var(--danger) !important; border-color: var(--danger) !important; color: #fff; }
.call-accept { background: var(--ok)     !important; border-color: var(--ok)     !important; color: #fff; }
.call-end:hover    { box-shadow: 0 4px 18px rgba(201,79,79,.4) !important; }
.call-accept:hover { box-shadow: 0 4px 18px rgba(61,158,61,.4) !important; }

/* ══════════════════════════════════════
   MODALS
══════════════════════════════════════ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 100;
  backdrop-filter: blur(4px);
  animation: authFadeIn .15s ease;
}
.modal {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 390px; max-width: calc(100vw - 24px); max-height: 88vh;
  background: var(--s1); border: 1px solid var(--b1);
  border-radius: var(--r);
  z-index: 101;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 16px 48px rgba(0,0,0,.5);
  animation: modalIn .22s var(--spring);
}
@keyframes modalIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(.92); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.modal-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 19px; border-bottom: 1px solid var(--b1);
}
.modal-hdr h3 { font-size: 15px; font-weight: 600; }
.modal-hdr button {
  color: var(--t2); font-size: 17px; width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  transition: color var(--tr), background var(--tr);
}
.modal-hdr button:hover { color: var(--t); background: var(--acc-a); }
.modal-body { padding: 19px; overflow-y: auto; display: flex; flex-direction: column; gap: 0; }

.search-results { margin-top: 11px; display: flex; flex-direction: column; gap: 3px; }
.sr-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: var(--r-sm); cursor: pointer;
  transition: background var(--tr);
}
.sr-item:hover { background: var(--acc-a); }

.settings-av-wrap {
  display: flex; flex-direction: column; align-items: center;
  gap: 9px; margin-bottom: 20px;
}
.settings-av {
  width: 76px; height: 76px; border-radius: 50%;
  background: var(--s2); border: 2px solid var(--b1);
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 700; cursor: pointer; overflow: hidden;
  transition: border-color var(--tr), transform var(--tr-s), box-shadow var(--tr);
}
.settings-av:hover {
  border-color: var(--b3);
  transform: scale(1.04);
  box-shadow: 0 0 0 4px rgba(255,255,255,.05);
}
.settings-av img { width: 100%; height: 100%; object-fit: cover; }
.s-label {
  display: block; font-size: 10.5px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--t3); margin: 11px 0 5px;
}
.s-divider { border: none; border-top: 1px solid var(--b1); margin: 18px 0; }

/* ══════════════════════════════════════
   TOAST
══════════════════════════════════════ */
.toasts {
  position: fixed; bottom: 22px; right: 22px;
  z-index: 1000; display: flex; flex-direction: column;
  gap: 7px; pointer-events: none;
}
.toast {
  background: var(--s3); border: 1px solid var(--b2);
  padding: 10px 16px; border-radius: var(--r-sm);
  font-size: 13px; pointer-events: auto;
  max-width: 270px;
  animation: toastIn .22s var(--spring);
  box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px) scale(.9); }
  to   { opacity: 1; transform: translateX(0)    scale(1); }
}
.toast.ok  { border-color: rgba(61,158,61,.5); }
.toast.err { border-color: rgba(201,79,79,.5); }

/* ══════════════════════════════════════
   CONTEXT MENU
══════════════════════════════════════ */
.ctx-menu {
  position: fixed;
  background: var(--s3); border: 1px solid var(--b2);
  border-radius: var(--r-sm); z-index: 200;
  min-width: 160px; overflow: hidden;
  box-shadow: 0 8px 28px rgba(0,0,0,.45);
  animation: ctxIn .15s var(--spring);
}
@keyframes ctxIn {
  from { opacity: 0; transform: scale(.88); }
  to   { opacity: 1; transform: scale(1); }
}
.ctx-item {
  padding: 9px 14px; font-size: 13px; cursor: pointer;
  transition: background var(--tr);
  display: flex; align-items: center; gap: 8px;
}
.ctx-item:hover { background: var(--acc-a); }
.ctx-item.danger { color: var(--danger); }

/* ══════════════════════════════════════
   MISC
══════════════════════════════════════ */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--b1); border-top-color: var(--t);
  border-radius: 50%;
  animation: spin .65s linear infinite;
  margin: 22px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-list {
  padding: 26px 14px; color: var(--t3);
  font-size: 13px; text-align: center;
  animation: authFadeIn .25s ease;
}

::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--b1); border-radius: 2px; }

/* ══════════════════════════════════════
   МОБАЙЛ
══════════════════════════════════════ */
@media (max-width: 680px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    z-index: 20; width: 100vw;
    transform: translateX(0);
    transition: transform var(--tr-l);
  }
  .sidebar.slide-out { transform: translateX(-100%); }
  .back-btn { display: flex !important; }
  .right-panel { display: none; }
  .bubble { max-width: 84%; }
  .emoji-panel { right: 4px; width: calc(100vw - 8px); }
  .msg-circle-wrap { width: 148px; height: 148px; }
  .msg-circle { width: 148px; height: 148px; }
}
@media (min-width: 681px) { .back-btn { display: none; } }

/* ══════════════════════════════════════
   SELECTION COLOR
══════════════════════════════════════ */
::selection { background: rgba(255,255,255,.15); color: var(--t); }
