:root {
  --bg: #14161d;
  --bg-2: #1c1f28;
  --bg-3: #262a36;
  --line: #333846;
  --txt: #f2ece9;
  --txt-dim: #9a94a3;
  --accent: #f191ab;
  --accent-2: #f6c9a8;
  --own: linear-gradient(135deg, #f191ab, #e8798f);
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

html[data-theme="light"] {
  --bg: #f6f1ee;
  --bg-2: #ffffff;
  --bg-3: #f0e9e6;
  --line: #e2d7d2;
  --txt: #241c20;
  --txt-dim: #8a7d84;
  --accent: #e8798f;
  --accent-2: #f0a982;
  --own: linear-gradient(135deg, #f8b3c4, #f291a8);
}


/* Глазурь — светлая пончиковая */
html[data-theme="glaze"] {
  --bg: #fff0f5;
  --bg-2: #ffffff;
  --bg-3: #ffe3ee;
  --line: #ffc9dd;
  --txt: #45222f;
  --txt-dim: #a2707f;
  --accent: #ff6fa8;
  --accent-2: #ffb26b;
  --own: linear-gradient(135deg, #ff9ec4, #ff6fa8);
}

/* Шоколад — тёмная тёплая */
html[data-theme="choco"] {
  --bg: #2a1a14;
  --bg-2: #38241b;
  --bg-3: #472f23;
  --line: #5b3d2d;
  --txt: #f7e6d5;
  --txt-dim: #bd9a80;
  --accent: #e8a86b;
  --accent-2: #f3cfa0;
  --own: linear-gradient(135deg, #c98a5b, #a5673a);
  --own-txt: #fff6ec;
}

/* Ягодный — насыщенная */
html[data-theme="berry"] {
  --bg: #2a0f28;
  --bg-2: #3a1737;
  --bg-3: #4c2049;
  --line: #632a5f;
  --txt: #fce6f6;
  --txt-dim: #c191ba;
  --accent: #ff6fb5;
  --accent-2: #b76bff;
  --own: linear-gradient(135deg, #e05fa0, #a34bd6);
  --own-txt: #fff;
}

/* Неон — киберпанк с бегущим свечением */
html[data-theme="neon"] {
  --bg: #0a0612;
  --bg-2: #150d24;
  --bg-3: #1f1436;
  --line: #33215a;
  --txt: #f0e9ff;
  --txt-dim: #9b86c9;
  --accent: #ff2bd6;
  --accent-2: #29e5ff;
  --own: linear-gradient(135deg, #ff2bd6, #7b2bff);
  --own-txt: #fff;
}

/* Сакура — светлая розовая с лепестками */
html[data-theme="sakura"] {
  --bg: #fff5f7;
  --bg-2: #ffffff;
  --bg-3: #fdeaef;
  --line: #f6d3dc;
  --txt: #3b2129;
  --txt-dim: #a3808c;
  --accent: #ff7fa6;
  --accent-2: #ffc2d4;
  --own: linear-gradient(135deg, #ffb3c9, #ff8fb0);
}

/* Кофе — тёплая коричневая */
html[data-theme="coffee"] {
  --bg: #1a1310;
  --bg-2: #241a15;
  --bg-3: #33251d;
  --line: #46332a;
  --txt: #f5eae1;
  --txt-dim: #b09585;
  --accent: #d9a066;
  --accent-2: #c17f4a;
  --own: linear-gradient(135deg, #c98f56, #a5673a);
  --own-txt: #fffaf4;
}

/* Северное сияние */
html[data-theme="aurora"] {
  --bg: #06111a;
  --bg-2: #0b1c28;
  --bg-3: #12293a;
  --line: #1d3d52;
  --txt: #e4f6f5;
  --txt-dim: #7ba7ad;
  --accent: #5df2b0;
  --accent-2: #7cc6ff;
  --own: linear-gradient(135deg, #38d9a9, #4dabf7);
  --own-txt: #04231c;
}

/* Матрица — зелёный терминал с падающим кодом */
html[data-theme="matrix"] {
  --bg: #030803;
  --bg-2: #071207;
  --bg-3: #0c1d0c;
  --line: #14361a;
  --txt: #c8ffd0;
  --txt-dim: #5f9a68;
  --accent: #37f24f;
  --accent-2: #12c96a;
  --own: linear-gradient(135deg, #1fa84a, #0d7a37);
  --own-txt: #eaffef;
}

/* Морская — тёмная синь с анимированными волнами */
html[data-theme="sea"] {
  --bg: #071a2b;
  --bg-2: #0c2438;
  --bg-3: #123249;
  --line: #1c4763;
  --txt: #e6f3fb;
  --txt-dim: #7fa3ba;
  --accent: #3fd0d4;
  --accent-2: #56a8e0;
  --own: linear-gradient(135deg, #2aa9c9, #1d7fb5);
  --own-txt: #f2fbff;
}

/* Закат — тёплая, анимированный градиент */
html[data-theme="sunset"] {
  --bg: #21131c;
  --bg-2: #2c1a24;
  --bg-3: #3a2330;
  --line: #4d3040;
  --txt: #fbeef2;
  --txt-dim: #b6919f;
  --accent: #ff8a5c;
  --accent-2: #ffb26b;
  --own: linear-gradient(135deg, #ff8a5c, #e8617f);
}

/* Лес — спокойная зелёная */
html[data-theme="forest"] {
  --bg: #0f1b16;
  --bg-2: #16261f;
  --bg-3: #1e3329;
  --line: #2a4738;
  --txt: #e8f4ec;
  --txt-dim: #8bab99;
  --accent: #4fce8f;
  --accent-2: #a3d977;
  --own: linear-gradient(135deg, #3fb87c, #2f9d8f);
  --own-txt: #f0fff7;
}

/* Космос — фиолетовая с мерцающими звёздами */
html[data-theme="space"] {
  --bg: #0b0a1a;
  --bg-2: #141230;
  --bg-3: #1d1a42;
  --line: #2d2860;
  --txt: #eae7ff;
  --txt-dim: #948dc4;
  --accent: #a78bfa;
  --accent-2: #f0abfc;
  --own: linear-gradient(135deg, #8b5cf6, #c084fc);
  --own-txt: #fdfbff;
}

/* Молоко — очень светлая, минимальная */
html[data-theme="milk"] {
  --bg: #fbfaf8;
  --bg-2: #ffffff;
  --bg-3: #f1efec;
  --line: #e5e2dd;
  --txt: #1f1d1b;
  --txt-dim: #8b8681;
  --accent: #d98da4;
  --accent-2: #c9b28d;
  --own: linear-gradient(135deg, #f4d3dd, #eebccb);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--txt);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  overflow: hidden;
}
.hidden { display: none !important; }
input, textarea, button { font: inherit; color: inherit; }
input, textarea {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
  width: 100%;
}
input:focus, textarea:focus { border-color: var(--accent); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #2c3346; border-radius: 8px; }

/* ---------- Вход ---------- */
.auth {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(1000px 600px at 15% -10%, rgba(241,145,171,.22), transparent 60%),
    radial-gradient(900px 600px at 110% 110%, rgba(246,201,168,.18), transparent 60%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: rgba(22,25,35,.85);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 28px 24px;
  box-shadow: 0 24px 60px rgba(0,0,0,.45);
}
.brand { font-size: 30px; font-weight: 700; letter-spacing: -.5px; display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 46px; height: 46px; }
.empty-logo { width: 96px; height: 96px; opacity: .85; margin: 0 auto; }
.brand-sub { color: var(--txt-dim); margin: 6px 0 22px; font-size: 14px; }
.tabs { display: flex; gap: 6px; background: var(--bg-3); padding: 4px; border-radius: 12px; margin-bottom: 18px; }
.tab { flex: 1; background: none; border: 0; padding: 10px; border-radius: 9px; color: var(--txt-dim); cursor: pointer; }
.tab.active { background: var(--bg); color: var(--txt); font-weight: 600; }
.form { display: grid; gap: 10px; }
.btn-primary {
  background: var(--own); border: 0; border-radius: 12px; padding: 13px;
  font-weight: 700; cursor: pointer; color: #2a1a20;
}
.btn-primary:active { transform: scale(.985); }
.btn-ghost { background: var(--bg-3); border: 1px solid var(--line); border-radius: 12px; padding: 13px 16px; cursor: pointer; }
.auth-error { color: #ff7b7b; font-size: 13px; min-height: 18px; margin-top: 12px; }

/* ---------- Каркас ---------- */
.app { height: 100%; display: grid; grid-template-columns: 330px 1fr; }
.sidebar { border-right: 1px solid var(--line); background: var(--bg-2); display: flex; flex-direction: column; min-height: 0; }
.side-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.me { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.me-txt { min-width: 0; }
.me-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-status { font-size: 12px; color: #4ade80; }
.icon-btn {
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 12px;
  width: 40px; height: 40px; font-size: 18px; cursor: pointer; flex: 0 0 auto;
  display: grid; place-items: center;
}
.icon-btn:active { background: #283047; }
.side-actions { display: flex; gap: 8px; padding: 12px 14px; }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; font-weight: 700; color: #fff; font-size: 16px;
  background: var(--own); position: relative; overflow: visible;
  background-size: cover; background-position: center;
}
.avatar.big { width: 76px; height: 76px; font-size: 28px; }
.avatar.img { color: transparent; }
.avatar.online::after {
  content: ''; position: absolute; right: -1px; bottom: -1px;
  width: 12px; height: 12px; border-radius: 50%; background: #4ade80; border: 2px solid var(--bg-2);
}

/* ---------- Список чатов ---------- */
.chat-list { flex: 1; overflow-y: auto; padding: 4px 8px 16px; min-height: 0; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 10px 10px;
  border-radius: 14px; cursor: pointer;
}
.row:hover { background: var(--bg-3); }
.row.active { background: var(--bg-3); }
.row-txt { flex: 1; min-width: 0; }
.row-top { display: flex; justify-content: space-between; gap: 8px; }
.row-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-time { font-size: 11px; color: var(--txt-dim); flex: 0 0 auto; }
.row-last { font-size: 13px; color: var(--txt-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  background: var(--accent); color: #2a1a20; font-size: 11px; font-weight: 700;
  min-width: 20px; height: 20px; border-radius: 10px; display: grid; place-items: center; padding: 0 6px;
}
.list-title { padding: 12px 12px 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--txt-dim); }

/* ---------- Чат ---------- */
.chat { display: flex; flex-direction: column; min-height: 0; position: relative; }
.empty { flex: 1; display: grid; place-content: center; text-align: center; color: var(--txt-dim); gap: 12px; padding: 20px; }
.empty-emoji { font-size: 54px; }
.room { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.room-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--bg-2); }
.room-title { font-weight: 600; }
.room-sub { font-size: 12px; color: var(--txt-dim); }
.back { display: none; }

.messages {
  flex: 1; overflow-y: auto; padding: 18px 16px 8px;
  display: flex; flex-direction: column; gap: 4px;
  background: radial-gradient(900px 500px at 80% 0%, rgba(241,145,171,.07), transparent 60%);
  position: relative;
}
.messages.has-bg::before {
  content: ''; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background-image: var(--chat-bg); background-size: cover; background-position: center;
  opacity: var(--chat-bg-opacity, .35);
}
.messages > * { position: relative; z-index: 1; }
.day { align-self: center; font-size: 12px; color: var(--txt-dim); background: var(--bg-3); padding: 4px 12px; border-radius: 10px; margin: 12px 0 8px; }
.msg { max-width: 74%; display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.msg.own { align-self: flex-end; align-items: flex-end; }
.msg-author { font-size: 12px; color: var(--accent); padding: 0 8px; }
.bubble {
  background: var(--bg-3); padding: 9px 13px; border-radius: 18px 18px 18px 6px;
  word-wrap: break-word; white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg.own .bubble { background: var(--own); border-radius: 18px 18px 6px 18px; color: #2a1a20; }
.msg.own .bubble a { color: #7a2340; }
.bubble a { color: #ffd7e2; }
.msg-time { font-size: 11px; color: var(--txt-dim); padding: 0 8px; }
.msg.sticker .bubble { background: none !important; padding: 0; font-size: 68px; line-height: 1; }
.bubble img { max-width: min(320px, 70vw); border-radius: 12px; display: block; }

.typing { padding: 4px 20px 8px; font-size: 12px; color: var(--txt-dim); }

.composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px calc(10px + var(--safe-b));
  border-top: 1px solid var(--line); background: var(--bg-2);
  position: relative; z-index: 20;
}
.composer textarea { resize: none; max-height: 140px; border-radius: 20px; }
.send-btn {
  background: var(--own); border: 0; border-radius: 50%; width: 44px; height: 44px;
  font-size: 17px; cursor: pointer; color: #2a1a20; flex: 0 0 auto;
}
.stickers {
  position: absolute; bottom: calc(66px + var(--safe-b)); left: 0; right: 0;
  background: var(--bg-2); border-top: 1px solid var(--line);
  padding: 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 6px; max-height: 42vh; overflow-y: auto;
}
.stickers button { background: none; border: 0; font-size: 34px; cursor: pointer; padding: 6px; border-radius: 12px; }
.stickers button:hover { background: var(--bg-3); }

/* ---------- Модалка / тост ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: 20px; padding: 22px; width: 100%; max-width: 400px; }
.modal-card h3 { margin: 0 0 14px; }
.group-people { max-height: 40vh; overflow-y: auto; margin: 12px 0; display: grid; gap: 4px; }
.group-people label { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; cursor: pointer; }
.group-people label:hover { background: var(--bg-3); }
.group-people input { width: auto; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 28px; z-index: 100;
  background: #2b3348; border: 1px solid var(--line); padding: 12px 18px; border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0,0,0,.4);
}

/* ---------- Мобильная раскладка ---------- */
@media (max-width: 780px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; }
  .app.room-open .sidebar { display: none; }
  .app:not(.room-open) .chat { display: none; }
  .back { display: grid; }
  .msg { max-width: 86%; }
}

/* ---------- Настройки ---------- */
.modal-card.wide { max-width: 460px; max-height: 88vh; overflow-y: auto; }
.set-block { padding: 14px 0; border-top: 1px solid var(--line); }
.set-block:first-of-type { border-top: 0; padding-top: 4px; }
.set-title { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--txt-dim); margin-bottom: 12px; }
.set-hint { font-size: 13px; color: var(--txt-dim); margin-bottom: 10px; line-height: 1.45; }
.set-avatar-row { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.set-avatar-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-ghost.small { padding: 9px 13px; font-size: 14px; }
.theme-row { display: flex; gap: 8px; }
.theme-btn {
  flex: 1; padding: 14px 10px; border-radius: 14px; cursor: pointer;
  background: var(--bg-3); border: 2px solid var(--line); color: var(--txt); font: inherit;
}
.theme-btn.active { border-color: var(--accent); }
.bg-presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; margin-bottom: 12px; }
.bg-presets button {
  height: 58px; border-radius: 12px; border: 2px solid var(--line);
  cursor: pointer; background-size: cover; background-position: center; padding: 0;
}
.bg-presets button.active { border-color: var(--accent); }

/* ---------- Голосовые ---------- */
.voice { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.voice-play {
  width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer; flex: 0 0 auto;
  background: rgba(255,255,255,.22); color: inherit; font-size: 15px;
}
.msg:not(.own) .voice-play { background: var(--bg-2); }
.voice-mid { flex: 1; min-width: 0; }
.voice-bar { height: 4px; border-radius: 3px; background: rgba(255,255,255,.3); overflow: hidden; }
.msg:not(.own) .voice-bar { background: var(--line); }
.voice-bar i { display: block; height: 100%; width: 0; background: currentColor; border-radius: 3px; }
.voice-time { font-size: 12px; opacity: .8; margin-top: 4px; }

/* запись */
.rec-panel {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px calc(10px + var(--safe-b));
  border-top: 1px solid var(--line); background: var(--bg-2);
}
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: #ff5a5a; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.rec-time { font-variant-numeric: tabular-nums; }
.rec-grow { flex: 1; color: var(--txt-dim); font-size: 13px; }

/* ---------- Видеокружочки ---------- */
.msg.circle .bubble { background: none !important; padding: 0; }
.circle-video {
  width: 216px; height: 216px; border-radius: 50%; object-fit: cover;
  background: #000; cursor: pointer; border: 3px solid var(--accent);
}
.circle-rec-wrap { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.82); display: grid; place-items: center; }
.circle-rec-inner { text-align: center; }
.circle-preview {
  width: 260px; height: 260px; border-radius: 50%; object-fit: cover;
  border: 4px solid var(--accent); background: #000; transform: scaleX(-1);
}
.circle-rec-btns { margin-top: 22px; display: flex; gap: 12px; justify-content: center; }

/* ---------- Звонки ---------- */
.call-overlay {
  position: fixed; inset: 0; z-index: 95; background: #0c0e13;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
}
.call-overlay video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #0c0e13; }
.call-overlay video.self {
  position: absolute; right: 16px; top: 16px; width: 132px; height: 176px;
  border-radius: 16px; inset: auto; border: 2px solid rgba(255,255,255,.25); transform: scaleX(-1); z-index: 2;
}
.call-info { position: relative; z-index: 3; text-align: center; color: #fff; }
.call-name { font-size: 26px; font-weight: 700; }
.call-status { color: #b9b2bd; margin-top: 6px; }
.call-btns { position: relative; z-index: 3; display: flex; gap: 16px; }
.call-btn {
  width: 62px; height: 62px; border-radius: 50%; border: 0; cursor: pointer; font-size: 24px;
  background: #2b3348; color: #fff;
}
.call-btn.hang { background: #e0384f; }
.call-btn.accept { background: #2fb457; }
.call-btn.off { background: #4a4351; }
.msg.call .bubble { font-size: 14px; opacity: .92; }
.head-actions { display: flex; gap: 8px; }

/* ---------- Минималистичные иконки ---------- */
.icon-btn svg, .send-btn svg { width: 21px; height: 21px; display: block; }
.icon-btn { color: var(--txt-dim); }
.icon-btn:hover { color: var(--txt); }
.send-btn { display: grid; place-items: center; }
.send-btn svg { width: 19px; height: 19px; }

/* ---------- Выпадающее меню ---------- */
.pop-menu {
  position: absolute; z-index: 40; min-width: 216px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px;
  padding: 6px; box-shadow: 0 18px 44px rgba(0,0,0,.45);
  left: 12px; bottom: calc(68px + var(--safe-b));
}
.pop-menu.head { left: auto; right: 12px; top: 62px; bottom: auto; }
.pop-menu button {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: none; border: 0; color: var(--txt); font: inherit; text-align: left;
  padding: 11px 12px; border-radius: 11px; cursor: pointer;
}
.pop-menu button:hover { background: var(--bg-3); }
.pop-menu button svg { width: 19px; height: 19px; flex: 0 0 auto; color: var(--accent); }
.pop-menu .sep { height: 1px; background: var(--line); margin: 5px 8px; }

/* ---------- Панель стикеров ---------- */
.stickers { grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); }
.stick-head {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 8px;
  padding: 2px 4px 8px; font-size: 12px; color: var(--txt-dim);
  text-transform: uppercase; letter-spacing: .5px;
}
.stick-head button {
  margin-left: auto; font-size: 13px; text-transform: none; letter-spacing: 0;
  background: var(--bg-3); border: 1px solid var(--line); color: var(--txt);
  padding: 7px 12px; border-radius: 10px; cursor: pointer;
}
.stick-item { position: relative; }
.stick-item img { width: 100%; height: 62px; object-fit: contain; display: block; }
.stick-item .del {
  position: absolute; top: -4px; right: -4px; width: 22px; height: 22px; border-radius: 50%;
  background: #e0384f; color: #fff; border: 0; font-size: 13px; cursor: pointer;
  display: none; place-items: center; padding: 0; line-height: 1;
}
.stick-item:hover .del { display: grid; }
.msg.imgsticker .bubble { background: none !important; padding: 0; }
.msg.imgsticker img { width: 168px; height: auto; max-height: 168px; object-fit: contain; }

/* ============ Анимированные фоны тем ============ */
/* Общий слой анимации поверх фона приложения */
#theme-fx {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
}
.app, .auth { position: relative; z-index: 1; }
html[data-anim="off"] #theme-fx { display: none; }

/* --- Морские волны --- */
#theme-fx .wave {
  position: absolute; left: -50%; width: 200%; height: 52vh; bottom: -14vh;
  background-repeat: repeat-x; background-size: 50% 100%;
  opacity: .5;
  animation: waveMove 14s linear infinite, waveBob 7s ease-in-out infinite alternate;
}
#theme-fx .wave.w2 { height: 44vh; bottom: -10vh; opacity: .34; animation-duration: 20s, 9s; animation-direction: reverse, alternate; }
#theme-fx .wave.w3 { height: 36vh; bottom: -6vh; opacity: .22; animation-duration: 28s, 11s; }
@keyframes waveMove { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@keyframes waveBob { from { margin-bottom: 0; } to { margin-bottom: 26px; } }

/* --- Звёздное небо на canvas (космос / сияние) --- */
#theme-fx canvas.sky { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* --- Плавающий градиент (закат / лес) --- */
#theme-fx .glow {
  position: absolute; width: 62vmax; height: 62vmax; border-radius: 50%;
  filter: blur(60px); opacity: .30;
  animation: floatA 22s ease-in-out infinite alternate;
}
#theme-fx .glow.g2 { animation: floatB 28s ease-in-out infinite alternate; opacity: .24; }
@keyframes floatA { from { transform: translate(-18vw, -14vh) scale(1); } to { transform: translate(14vw, 12vh) scale(1.18); } }
@keyframes floatB { from { transform: translate(52vw, 58vh) scale(1.1); } to { transform: translate(24vw, 22vh) scale(.9); } }

/* --- Мягкие пузырьки (морская, дополнительно) --- */
#theme-fx .bub {
  position: absolute; bottom: -8vh; border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, rgba(255,255,255,.5), rgba(255,255,255,.06) 60%, transparent 70%);
  animation: rise linear infinite;
}
@keyframes rise {
  from { transform: translateY(0) scale(.7); opacity: 0; }
  12% { opacity: .8; }
  to { transform: translateY(-118vh) scale(1.15); opacity: 0; }
}

/* уважение к системной настройке «меньше движения» */
@media (prefers-reduced-motion: reduce) {
  #theme-fx * { animation: none !important; }
}

/* полупрозрачные панели, чтобы анимация просвечивала */
html[data-anim="on"] .sidebar { background: color-mix(in srgb, var(--bg-2) 86%, transparent); }
html[data-anim="on"] .room-head,
html[data-anim="on"] .composer { background: color-mix(in srgb, var(--bg-2) 88%, transparent); }
html[data-anim="on"] .messages { background: transparent; }

/* сетка выбора темы */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.theme-card {
  border: 2px solid var(--line); border-radius: 14px; cursor: pointer; overflow: hidden;
  background: var(--bg-3); padding: 0; color: var(--txt); font: inherit;
}
.theme-card.active { border-color: var(--accent); }
.theme-card i { display: block; height: 44px; }
.theme-card span { display: block; padding: 7px 4px; font-size: 12.5px; }
.theme-card b { font-size: 10px; font-weight: 600; opacity: .7; display: block; padding-bottom: 5px; }
.set-switch { display: flex; align-items: center; gap: 10px; margin-top: 12px; cursor: pointer; }
.set-switch input { width: auto; }

/* ============ Плавность и отклик на нажатие ============ */
:root { --ease: cubic-bezier(.22,.61,.36,1); }

html { transition: none; }
body, .sidebar, .room-head, .composer, .modal-card, .pop-menu, .stickers,
.auth-card, .chat-list, .messages {
  transition: background-color .32s var(--ease), color .32s var(--ease),
              border-color .32s var(--ease);
}

/* кнопки: наведение и нажатие */
.icon-btn, .send-btn, .btn-primary, .btn-ghost, .theme-card,
.pop-menu button, .stickers button, .bg-presets button, .call-btn, .voice-play {
  transition: transform .14s var(--ease), background-color .2s var(--ease),
              border-color .2s var(--ease), color .2s var(--ease), box-shadow .2s var(--ease),
              opacity .2s var(--ease);
}
.icon-btn:active, .send-btn:active, .btn-primary:active, .btn-ghost:active,
.pop-menu button:active, .stickers button:active, .bg-presets button:active,
.theme-card:active, .voice-play:active { transform: scale(.9); }
.call-btn:active { transform: scale(.88); }
.send-btn:hover { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 22%, transparent); }
.theme-card:hover, .bg-presets button:hover { transform: translateY(-2px); }

/* волна от нажатия */
.icon-btn, .send-btn, .btn-primary, .btn-ghost, .theme-card, .pop-menu button,
.call-btn, .row { position: relative; overflow: hidden; }
.ripple {
  position: absolute; border-radius: 50%; pointer-events: none;
  background: currentColor; opacity: .26; transform: scale(0);
  animation: rippleGo .55s var(--ease) forwards;
}
@keyframes rippleGo { to { transform: scale(2.6); opacity: 0; } }

/* строки чатов */
.row { transition: background-color .2s var(--ease), transform .14s var(--ease); }
.row:active { transform: scale(.985); }

/* появление сообщений */
.msg { animation: msgIn .26s var(--ease) both; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.msg.own { animation-name: msgInOwn; }
@keyframes msgInOwn { from { opacity: 0; transform: translateY(8px) scale(.985); } }

/* меню и панели */
.pop-menu:not(.hidden) { animation: popIn .18s var(--ease) both; transform-origin: bottom left; }
.pop-menu.head:not(.hidden) { transform-origin: top right; }
@keyframes popIn { from { opacity: 0; transform: scale(.94) translateY(6px); } }
.stickers:not(.hidden) { animation: slideUp .22s var(--ease) both; }
@keyframes slideUp { from { opacity: 0; transform: translateY(18px); } }

/* модалки */
.modal:not(.hidden) { animation: fadeIn .2s var(--ease) both; }
.modal:not(.hidden) .modal-card { animation: cardIn .26s var(--ease) both; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes cardIn { from { opacity: 0; transform: translateY(16px) scale(.97); } }

/* тост */
.toast:not(.hidden) { animation: toastIn .26s var(--ease) both; }
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(14px); } }

/* смена комнаты */
.room:not(.hidden) { animation: fadeIn .22s var(--ease) both; }

/* переключение чата на телефоне */
@media (max-width: 780px) {
  .app.room-open .chat { animation: slideInRight .24s var(--ease) both; }
  @keyframes slideInRight { from { opacity: .4; transform: translateX(22px); } }
}

/* звонки */
.call-overlay { animation: fadeIn .25s var(--ease) both; }
.call-btn.accept { animation: pulseBtn 1.6s ease-in-out infinite; }
@keyframes pulseBtn {
  50% { box-shadow: 0 0 0 14px rgba(47,180,87,.16); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ============ Истории ============ */
.stories-bar {
  display: flex; gap: 12px; padding: 12px 14px 10px; overflow-x: auto;
  border-bottom: 1px solid var(--line); scrollbar-width: none;
}
.stories-bar::-webkit-scrollbar { display: none; }
.story-chip { flex: 0 0 auto; width: 64px; text-align: center; cursor: pointer; }
.story-ring {
  width: 58px; height: 58px; border-radius: 50%; padding: 2.5px; margin: 0 auto;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  transition: transform .16s var(--ease);
}
.story-chip:active .story-ring { transform: scale(.92); }
.story-ring.seen { background: var(--line); }
.story-ring .avatar { width: 100%; height: 100%; border: 2.5px solid var(--bg-2); }
.story-chip span {
  display: block; font-size: 11.5px; color: var(--txt-dim); margin-top: 5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.story-add .story-ring { background: var(--bg-3); display: grid; place-items: center; border: 1.5px dashed var(--line); }
.story-add .story-ring svg { width: 22px; height: 22px; color: var(--accent); }

.story-view {
  position: fixed; inset: 0; z-index: 120; background: #05060a;
  display: flex; flex-direction: column; animation: fadeIn .2s var(--ease) both;
}
.story-progress { display: flex; gap: 4px; padding: 10px 12px 0; }
.story-progress i {
  flex: 1; height: 3px; border-radius: 2px; background: rgba(255,255,255,.28); overflow: hidden;
}
.story-progress i b { display: block; height: 100%; width: 0; background: #fff; border-radius: 2px; }
.story-top { display: flex; align-items: center; gap: 10px; padding: 12px 14px; color: #fff; z-index: 2; }
.story-top .icon-btn { background: rgba(255,255,255,.12); border-color: transparent; color: #fff; }
.story-who { flex: 1; min-width: 0; }
.story-who > div:first-child { font-weight: 600; }
.story-when { font-size: 12px; opacity: .7; }
.story-body { flex: 1; display: grid; place-items: center; overflow: hidden; }
.story-body img, .story-body video { max-width: 100%; max-height: 100%; object-fit: contain; }
.story-caption {
  color: #fff; text-align: center; padding: 14px 24px 26px; font-size: 15px; min-height: 10px;
  text-shadow: 0 2px 10px rgba(0,0,0,.6);
}
.story-nav { position: absolute; inset: 60px 0 70px; display: flex; z-index: 1; }
.story-prev, .story-next { flex: 1; }
.story-views { font-size: 12px; opacity: .75; }

/* --- Падающие лепестки (сакура) --- */
#theme-fx .petal {
  position: absolute; top: -6vh; border-radius: 60% 20% 60% 20%;
  background: linear-gradient(135deg, #ffb3c9, #ff7fa6);
  opacity: .65; animation: fall linear infinite;
}
@keyframes fall {
  from { transform: translateY(-10vh) rotate(0deg); }
  to { transform: translateY(112vh) rotate(540deg); }
}

/* --- Бегущее неоновое свечение --- */
#theme-fx .neon {
  position: absolute; width: 140%; height: 3px; left: -20%;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent-2), transparent);
  filter: blur(2px); opacity: .5;
  animation: neonSlide 6s linear infinite;
}
@keyframes neonSlide { from { transform: translateX(-40%); } to { transform: translateX(40%); } }

/* --- Матричный дождь --- */
#theme-fx .rain {
  position: absolute; top: -20vh; font: 700 15px/1.15 monospace; color: #37f24f;
  white-space: pre; opacity: .55; text-shadow: 0 0 8px #37f24f;
  animation: rainFall linear infinite;
}
@keyframes rainFall { to { transform: translateY(135vh); } }

/* --- Сияние (aurora) --- */
#theme-fx .aur {
  position: absolute; left: -25%; width: 150%; height: 46vh; top: -8vh;
  background: linear-gradient(90deg, transparent, #5df2b0aa, #7cc6ffaa, #b78cffaa, transparent);
  filter: blur(46px); opacity: .38;
  animation: aurWave 16s ease-in-out infinite alternate;
}
#theme-fx .aur.a2 { top: 8vh; animation-duration: 22s; animation-direction: alternate-reverse; opacity: .26; }
@keyframes aurWave {
  from { transform: translateX(-8%) skewY(-3deg) scaleY(1); }
  to { transform: translateX(8%) skewY(3deg) scaleY(1.25); }
}

/* ============ Панель смайликов (вкладки, поиск) ============ */
.stickers {
  display: flex; flex-direction: column; gap: 0; padding: 0;
  max-height: 46vh; overflow: hidden;
  box-shadow: 0 -12px 32px rgba(0,0,0,.22);
  border-radius: 18px 18px 0 0;
}
.emoji-head {
  padding: 10px 10px 6px; border-bottom: 1px solid var(--line);
  background: var(--bg-2); position: sticky; top: 0; z-index: 2;
  border-radius: 18px 18px 0 0;
}
.emoji-tabs {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding-bottom: 6px;
}
.emoji-tabs::-webkit-scrollbar { display: none; }
.emoji-tab {
  flex: 0 0 auto; width: 38px; height: 34px; border: 0; border-radius: 11px;
  background: transparent; font-size: 19px; line-height: 1; cursor: pointer;
  position: relative; opacity: .62;
  transition: transform .18s var(--ease), background-color .2s var(--ease), opacity .2s var(--ease);
}
.emoji-tab:hover { background: var(--bg-3); opacity: .9; transform: translateY(-1px); }
.emoji-tab.active { opacity: 1; background: var(--bg-3); }
.emoji-tab.active::after {
  content: ''; position: absolute; left: 50%; bottom: -5px; width: 16px; height: 2.5px;
  border-radius: 2px; background: var(--accent); transform: translateX(-50%);
  animation: tabBar .26s var(--ease) both;
}
@keyframes tabBar { from { width: 0; opacity: 0; } }
.emoji-search {
  width: 100%; margin-top: 4px; padding: 8px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg-3); color: var(--txt);
  font-size: 14px; outline: none;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.emoji-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.emoji-grid {
  flex: 1; overflow-y: auto; padding: 10px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 2px;
  overscroll-behavior: contain;
}
.emoji-grid button {
  background: none; border: 0; font-size: 27px; line-height: 1.15; cursor: pointer;
  padding: 5px; border-radius: 11px;
  animation: emojiIn .26s var(--ease) both;
  transition: transform .16s var(--ease), background-color .18s var(--ease);
}
@keyframes emojiIn { from { opacity: 0; transform: scale(.6); } }
.emoji-grid button:hover { background: var(--bg-3); transform: scale(1.22); }
.emoji-grid button:active { transform: scale(.86); }
.emoji-empty { grid-column: 1/-1; text-align: center; padding: 24px; color: var(--txt-dim); font-size: 14px; }
@media (max-width: 780px) {
  .emoji-grid { grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); }
  .stickers { max-height: 52vh; }
}
.stickers:not(.hidden) { animation: sheetUp .3s cubic-bezier(.16,.84,.34,1) both; }
@keyframes sheetUp { from { opacity: 0; transform: translateY(26px); } }

/* ============ Реакции на сообщения ============ */
.msg { position: relative; }
.msg-reacts { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 4px; }
.msg-reacts.empty { display: none; }
.msg-reacts:not(.empty) { margin-top: 3px; }
.react-chip {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 999px; padding: 2px 8px; cursor: pointer;
  font-size: 14px; line-height: 1.35; color: var(--txt);
  transition: transform .16s var(--ease), background-color .2s var(--ease), border-color .2s var(--ease);
}
.react-chip b { font-size: 11.5px; font-weight: 600; opacity: .85; }
.react-chip:hover { transform: translateY(-1.5px); }
.react-chip:active { transform: scale(.9); }
.react-chip.mine {
  background: color-mix(in srgb, var(--accent) 22%, var(--bg-3));
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}
.react-chip.pop { animation: chipPop .38s cubic-bezier(.18,.9,.3,1.2) both; }
@keyframes chipPop {
  0% { opacity: 0; transform: scale(.3) translateY(6px); }
  62% { transform: scale(1.16) translateY(-2px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* кнопка «поставить реакцию» — появляется при наведении */
.react-btn {
  position: absolute; top: 2px; border: 0; background: var(--bg-2);
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; color: var(--txt-dim);
  opacity: 0; pointer-events: none; transform: scale(.7);
  box-shadow: 0 2px 8px rgba(0,0,0,.16);
  transition: opacity .2s var(--ease), transform .2s var(--ease), color .2s var(--ease);
}
.react-btn svg { width: 15px; height: 15px; }
.msg:not(.own) .react-btn { right: -32px; }
.msg.own .react-btn { left: -32px; }
.msg:hover .react-btn { opacity: 1; pointer-events: auto; transform: scale(1); }
.react-btn:hover { color: var(--accent); transform: scale(1.12); }
@media (max-width: 780px), (hover: none) { .react-btn { display: none; } }

/* всплывающая панель выбора реакции */
.react-picker {
  position: fixed; z-index: 90; display: flex; justify-content: space-around;
  gap: 2px; padding: 6px 8px; border-radius: 999px;
  background: var(--bg-2); border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0,0,0,.3);
  opacity: 0; transform: scale(.82) translateY(6px);
  transform-origin: bottom center;
  transition: opacity .2s var(--ease), transform .26s cubic-bezier(.18,.9,.3,1.25);
}
.react-picker.open { opacity: 1; transform: scale(1) translateY(0); }
.react-picker.closing { opacity: 0; transform: scale(.85) translateY(4px); }
.react-picker button {
  background: none; border: 0; cursor: pointer; font-size: 26px; line-height: 1;
  padding: 3px 4px; border-radius: 50%;
  animation: reactIn .34s cubic-bezier(.18,.9,.3,1.3) both;
  transition: transform .18s var(--ease);
}
@keyframes reactIn { from { opacity: 0; transform: scale(.2) translateY(10px); } }
.react-picker button:hover { transform: scale(1.38) translateY(-4px); }
.react-picker button:active { transform: scale(1.05); }

/* ============ Реакции на истории ============ */
.story-reacts {
  display: flex; justify-content: center; gap: 4px;
  padding: 8px 12px calc(14px + var(--safe-b)); z-index: 3;
}
.story-reacts button {
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.16);
  backdrop-filter: blur(8px);
  width: 42px; height: 42px; border-radius: 50%; cursor: pointer;
  font-size: 22px; line-height: 1;
  animation: reactIn .36s cubic-bezier(.18,.9,.3,1.3) both;
  transition: transform .2s var(--ease), background-color .2s var(--ease), border-color .2s var(--ease);
}
.story-reacts button:hover { transform: translateY(-5px) scale(1.14); background: rgba(255,255,255,.2); }
.story-reacts button:active { transform: scale(.88); }
.story-reacts button.mine {
  background: color-mix(in srgb, var(--accent) 45%, transparent);
  border-color: #fff;
}
.story-reacts button.bump { animation: bump .42s cubic-bezier(.2,.9,.3,1.4); }
@keyframes bump {
  0% { transform: scale(1); } 40% { transform: scale(1.45) rotate(-8deg); }
  70% { transform: scale(.92) rotate(4deg); } 100% { transform: scale(1) rotate(0); }
}
.story-react-sum {
  display: flex; align-items: center; justify-content: center; gap: 3px;
  color: #fff; font-size: 14px; z-index: 3; padding-top: 2px;
  animation: fadeIn .3s var(--ease) both;
}
.story-react-sum .sr-e { font-size: 17px; }
.story-react-sum b { font-size: 12.5px; opacity: .8; margin-left: 3px; }
.story-nav { inset: 60px 0 130px; }

/* взлетающие сердечки */
.fly-heart {
  position: fixed; z-index: 95; pointer-events: none; font-size: 26px;
  animation: flyUp 1.5s cubic-bezier(.22,.61,.36,1) forwards;
}
@keyframes flyUp {
  0% { opacity: 0; transform: translate(-50%, 0) scale(.4); }
  16% { opacity: 1; transform: translate(-50%, -22px) scale(var(--sc, 1)); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx, 0px)), -190px) scale(calc(var(--sc, 1) * .8)); }
}

/* ============ Кружочек: стоп после проигрывания ============ */
.msg.circle .bubble { position: relative; }
.circle-video { transition: filter .3s var(--ease), transform .25s var(--ease); }
.msg.circle-idle .circle-video { filter: brightness(.82); }
.msg.circle .bubble::after {
  content: ''; position: absolute; inset: 0; margin: auto;
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(0,0,0,.42) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23fff'%3E%3Cpath d='M8 5.5l11 6.5-11 6.5z'/%3E%3C/svg%3E") center/20px no-repeat;
  backdrop-filter: blur(2px); pointer-events: none;
  opacity: 0; transform: scale(.7);
  transition: opacity .25s var(--ease), transform .3s cubic-bezier(.18,.9,.3,1.3);
}
.msg.circle.circle-idle .bubble::after { opacity: 1; transform: scale(1); }

/* ============ Общая полировка плавности ============ */
.icon-btn, .send-btn, .btn-primary, .btn-ghost, .theme-card,
.pop-menu button, .emoji-grid button, .bg-presets button, .call-btn, .voice-play,
.react-chip, .story-reacts button {
  transition-timing-function: cubic-bezier(.18,.86,.32,1.02);
  will-change: transform;
}
.messages { scroll-behavior: smooth; }
.msg { animation: msgIn .34s cubic-bezier(.18,.86,.32,1.02) both; }
@keyframes msgIn { from { opacity: 0; transform: translateY(12px) scale(.97); } }
@keyframes msgInOwn { from { opacity: 0; transform: translateY(12px) scale(.97); } }
.story-chip { transition: transform .2s var(--ease); }
.story-chip:hover { transform: translateY(-3px); }
.story-ring { transition: transform .22s cubic-bezier(.18,.9,.3,1.25), background .3s var(--ease); }
.chat-list .row { animation: rowIn .3s var(--ease) both; }
@keyframes rowIn { from { opacity: 0; transform: translateX(-10px); } }
.story-view:not(.hidden) { animation: storyIn .3s cubic-bezier(.16,.84,.34,1) both; }
@keyframes storyIn { from { opacity: 0; transform: scale(.96); } }
.story-body img, .story-body video { animation: fadeIn .35s var(--ease) both; }

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


/* ============ Панель смайликов строго ПОВЕРХ переписки ============ */
/* было: панель «проваливалась» под сообщения, т.к. у пузырей z-index:1,
   а у самой панели z-index не был задан вообще */
#stickers.stickers {
  z-index: 45;
  background: var(--bg-2);
  border-top: 1px solid var(--line);
  box-shadow: 0 -14px 36px rgba(0,0,0,.34);
}
/* внутренние блоки панели тоже красим — чтобы сквозь них не читались сообщения */
#stickers .emoji-head { background: var(--bg-2); }
#stickers .emoji-grid { background: var(--bg-2); }
/* при включённом анимированном фоне панели делаются полупрозрачными —
   для этой панели прозрачность отменяем, иначе снова просвечивает диалог */
html[data-anim="on"] #stickers.stickers,
html[data-anim="on"] #stickers .emoji-head,
html[data-anim="on"] #stickers .emoji-grid { background: var(--bg-2); }
/* меню «+» и меню звонков — над панелью */
.pop-menu { z-index: 60; }


/* ============ Аватарки-пончики ============ */
.avatar.donut { background: transparent !important; overflow: hidden; padding: 0; }
.avatar.donut svg { width: 100%; height: 100%; display: block; }
.avatar .av-ini { display: grid; place-items: center; width: 100%; height: 100%; }
.avatar.group-av { display: grid; place-items: center; }
.avatar.donut.online::after, .avatar.online::after { z-index: 2; }

/* ============ Вкладки сайдбара: Чаты / Контакты ============ */
.side-tabs {
  display: flex; gap: 4px; padding: 0 12px 8px;
  border-bottom: 1px solid var(--line);
}
.side-tab {
  flex: 1; padding: 9px 8px; border: 0; border-radius: 12px 12px 0 0;
  background: transparent; color: var(--txt-dim); font-size: 14px; font-weight: 600;
  cursor: pointer; position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: color .2s var(--ease), background-color .2s var(--ease);
}
.side-tab:hover { background: var(--bg-3); color: var(--txt); }
.side-tab.active { color: var(--accent); }
.side-tab.active::after {
  content: ''; position: absolute; left: 12%; right: 12%; bottom: -1px; height: 2.5px;
  border-radius: 2px; background: var(--accent);
  animation: tabBar .28s var(--ease) both;
}
.tab-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
  display: inline-grid; place-items: center;
  animation: chipPop .4s cubic-bezier(.18,.9,.3,1.2) both;
}

/* ============ Контакты и заявки ============ */
.req-btns { display: flex; gap: 6px; flex: 0 0 auto; margin-left: auto; }
.req-btns button {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--bg-3); cursor: pointer; display: grid; place-items: center;
  color: var(--txt-dim);
  transition: transform .16s var(--ease), background-color .2s var(--ease),
              color .2s var(--ease), border-color .2s var(--ease);
}
.req-btns button svg { width: 17px; height: 17px; }
.req-btns button:hover { transform: translateY(-2px) scale(1.06); }
.req-btns button:active { transform: scale(.9); }
.req-btns button:disabled { opacity: .45; cursor: default; transform: none; }
.req-ok:hover { background: #2fbf71; border-color: #2fbf71; color: #fff; }
.req-no:hover { background: #e8536b; border-color: #e8536b; color: #fff; }
.req-add:hover, .req-write:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.row.req {
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  animation: reqIn .38s cubic-bezier(.18,.86,.32,1.02) both;
}
@keyframes reqIn { from { opacity: 0; transform: translateX(-14px); } }
.list-hint { padding: 14px 18px; color: var(--txt-dim); font-size: 13.5px; line-height: 1.5; }

/* ============ Кнопка и окно «О Разработчике» ============ */
.brand-btn { padding: 0; overflow: hidden; }
.brand-btn img {
  width: 26px; height: 26px; object-fit: contain; display: block;
  transition: transform .3s cubic-bezier(.18,.9,.3,1.3);
}
.brand-btn:hover img { transform: rotate(-12deg) scale(1.14); }

.about-pop {
  position: fixed; inset: 0; z-index: 140;
  background: rgba(0,0,0,.5); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 22px;
  opacity: 0; transition: opacity .22s var(--ease);
}
.about-pop.open { opacity: 1; }
.about-card {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 24px; padding: 26px 30px 28px; text-align: center;
  max-width: 320px; width: 100%;
  box-shadow: 0 24px 60px rgba(0,0,0,.4);
  transform: scale(.86) translateY(14px);
  transition: transform .34s cubic-bezier(.18,.9,.3,1.24);
}
.about-pop.open .about-card { transform: scale(1) translateY(0); }
.about-logo {
  width: 96px; height: 96px; object-fit: contain; margin-bottom: 12px;
  animation: donutFloat 3.6s ease-in-out infinite;
}
@keyframes donutFloat {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-9px) rotate(4deg); }
}
.about-title { font-size: 19px; font-weight: 700; color: var(--txt); }
.about-aka {
  margin-top: 7px; font-size: 15px; font-weight: 600;
  color: var(--accent);
}
.about-love {
  margin-top: 10px; font-size: 14.5px; color: var(--txt-dim); line-height: 1.5;
}
.about-emoji { display: inline-block; animation: donutSpin 4.5s linear infinite; }
@keyframes donutSpin {
  0%,72% { transform: rotate(0); } 100% { transform: rotate(360deg); }
}

/* ============ Плывущие пончики (пончиковые темы) ============ */
.fx-donut {
  position: absolute; bottom: -14vh; pointer-events: none;
  animation: donutRise linear infinite;
}
.fx-donut svg { width: 100%; height: 100%; display: block; }
@keyframes donutRise {
  0%   { transform: translateY(0) translateX(0) rotate(0); }
  50%  { transform: translateY(-62vh) translateX(26px) rotate(calc(var(--spin, 180deg) / 2)); }
  100% { transform: translateY(-124vh) translateX(-14px) rotate(var(--spin, 180deg)); }
}

/* ============ Полный экран на телефоне ============ */
html, body { overscroll-behavior: none; }
@supports (height: 100dvh) {
  html, body, .app, .auth { height: 100dvh; }
}
@media (max-width: 780px) {
  .side-tabs { padding: 0 10px 8px; }
  .about-card { padding: 22px 22px 24px; }
  .about-logo { width: 84px; height: 84px; }
}


/* ============ Полный экран: вырез камеры и системные панели ============ */
/* Приложение в APK рисуется под строкой состояния и панелью навигации,
   поэтому шапки и нижние панели сами отступают на безопасную зону. */
.side-head { padding-top: calc(14px + var(--safe-t)); }
.room-head { padding-top: calc(10px + var(--safe-t)); }
.auth { padding-top: var(--safe-t); padding-bottom: var(--safe-b); }
.story-top { padding-top: calc(12px + var(--safe-t)); }
.story-progress { padding-top: calc(10px + var(--safe-t)); }
.call-overlay { padding-top: var(--safe-t); padding-bottom: var(--safe-b); }
.app { padding-left: var(--safe-l); padding-right: var(--safe-r); }

@media (max-width: 780px) {
  /* на телефоне шапка комнаты тоже уходит под вырез */
  .app.room-open .room-head { padding-top: calc(10px + var(--safe-t)); }
  /* панель смайликов не должна залезать под панель навигации */
  #stickers.stickers { padding-bottom: var(--safe-b); }
}
