:root {
  --bg: #0e1016;
  --panel: #161922;
  --panel2: #1d212c;
  --line: #2a2f3d;
  --text: #e8eaf0;
  --muted: #8a91a3;
  --accent: #ffcc33;
  --accent2: #4f8cff;
  --out: #2b4d8f;
  --in: #232836;
  --danger: #ff5c6c;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@supports (height: 100dvh) { html, body { height: 100dvh; } }
body {
  touch-action: manipulation;          /* двойное касание больше не увеличивает страницу */
  overscroll-behavior: none;
  background: radial-gradient(1200px 600px at 80% -10%, #1b2236 0%, var(--bg) 60%);
  color: var(--text);
  font: 15px/1.45 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  display: flex; flex-direction: column; overflow: hidden;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea {
  font: inherit; color: var(--text); background: var(--panel2);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; width: 100%;
}
input:focus, textarea:focus { border-color: var(--accent2); }

/* ---------- ЗАГРУЗКА ---------- */
/* Фон — картинка loader.jpg. Знак «?» стоит ровно там, где он был на картинке,
   и вращается вокруг своей оси. В конце загрузки «?» вырастает больше экрана. */
#loader {
  position: fixed; inset: 0; z-index: 100; background: #000; overflow: hidden;
  container-type: size;
}
#loader.hide { display: none; }

.loader-stage {
  position: absolute; inset: 0;
  background: #000 url("loader.jpg") center / cover no-repeat;
  /* масштаб картинки при background-size: cover (картинка 1672×941) */
  --k: max(calc(100vw / 1672), calc(100vh / 941));
  --k: max(calc(100cqw / 1672), calc(100cqh / 941));
  animation: bgIn 1s ease-out both;
}
@keyframes bgIn { from { opacity: 0; transform: scale(1.06); } to { opacity: 1; transform: none; } }

/* точка, где был «?» на картинке: центр картинки + (2; 30) пикселей */
.q-pos {
  position: absolute;
  left: calc(50% + 2 * var(--k));
  top:  calc(50% + 30 * var(--k));
  width: 0; height: 0;
  perspective: calc(900 * var(--k));
}
.q-glow {
  position: absolute; left: 0; top: 0;
  width: calc(330 * var(--k)); height: calc(330 * var(--k));
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 190, 60, .55) 0%, rgba(255, 150, 20, .22) 38%, rgba(255, 120, 0, 0) 70%);
  animation: glow 1.6s ease-in-out infinite;
}
@keyframes glow { 50% { opacity: .55; transform: translate(-50%, -50%) scale(.9); } }

.qmark {
  position: absolute; left: 0; top: 0;
  font-family: Georgia, "Times New Roman", serif; font-weight: 900;
  font-size: calc(300 * var(--k)); line-height: 1;
  color: #ffd04a;
  background: linear-gradient(180deg, #fff1a8 0%, #ffcc33 45%, #e89a10 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 calc(14 * var(--k)) rgba(255, 196, 60, .95)) drop-shadow(0 0 calc(40 * var(--k)) rgba(255, 140, 0, .6));
  transform-style: preserve-3d;
  animation: spinSelf 1.8s linear infinite;
  will-change: transform;
}
/* вращение вокруг СВОЕЙ вертикальной оси, как монета */
@keyframes spinSelf {
  from { transform: translate(-50%, -50%) rotateY(0deg); }
  to   { transform: translate(-50%, -50%) rotateY(360deg); }
}

.loader-text {
  position: absolute; left: 0; right: 0; bottom: 7%; text-align: center;
  letter-spacing: 12px; font-weight: 800; font-size: 20px; color: #ffcc33;
  text-shadow: 0 0 12px rgba(0, 0, 0, .9), 0 0 18px rgba(255, 180, 40, .5);
  animation: pulse 1.4s infinite;
}
@keyframes pulse { 50% { opacity: .35; } }

/* ---- финал загрузки: «?» вырастает больше экрана, всё растворяется ---- */
#loader.zoom { animation: loaderOut 1.2s ease-in forwards; }
#loader.zoom .loader-text { opacity: 0; transition: opacity .25s; }
#loader.zoom .q-pos { animation: zoomQ 1.2s cubic-bezier(.6, 0, .9, .4) forwards; }
@keyframes zoomQ { from { transform: scale(1); } to { transform: scale(30); } }
@keyframes loaderOut {
  0%, 60% { opacity: 1; }
  100%    { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .qmark, .q-glow, .loader-stage, #loader.zoom .q-pos { animation: none; }
}

/* ---------- ШАПКА ---------- */
.topbar {
  height: 56px; flex: 0 0 56px; display: flex; align-items: center; justify-content: center;
  border-bottom: 1px solid var(--line); background: rgba(14,16,22,.8); backdrop-filter: blur(6px);
}
.logo { font-weight: 900; font-size: 24px; letter-spacing: 6px; }
.logo-q { color: var(--accent); font-family: Georgia, serif; margin-right: 8px; display: inline-block; animation: wiggle 4s infinite; }
@keyframes wiggle { 0%,90%,100% { transform: rotate(0); } 93% { transform: rotate(-15deg); } 96% { transform: rotate(15deg); } }

/* ---------- АВТОРИЗАЦИЯ ---------- */
#auth { flex: 1; display: flex; align-items: center; justify-content: center; padding: 20px; overflow: auto; }
.auth-card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.tabs { display: flex; background: var(--panel2); border-radius: 12px; padding: 4px; margin-bottom: 20px; }
.tab { flex: 1; border: 0; background: none; padding: 10px; border-radius: 9px; color: var(--muted); font-weight: 600; }
.tab.active { background: var(--accent); color: #1a1a1a; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.btn { border: 0; border-radius: 10px; padding: 11px 16px; font-weight: 700; }
.btn.primary { background: var(--accent); color: #1a1a1a; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--danger); color: #fff; padding: 6px 10px; font-size: 12px; }
.btn.ghost { background: var(--panel2); padding: 6px 10px; font-size: 12px; }
.error { color: var(--danger); min-height: 20px; margin-top: 12px; font-size: 14px; }

/* ---------- ПРИЛОЖЕНИЕ ---------- */
#app { flex: 1; display: flex; min-height: 0; }
.sidebar { width: 340px; flex: 0 0 340px; border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.me { display: flex; align-items: center; gap: 12px; padding: 14px; border-bottom: 1px solid var(--line); }
.me-info { flex: 1; min-width: 0; }
.name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar-btn { border: 0; padding: 0; background: none; border-radius: 50%; position: relative; }

.icon-btn { border: 0; background: none; font-size: 18px; padding: 6px 8px; border-radius: 8px; color: var(--muted); }
.icon-btn:hover { background: var(--panel2); color: var(--text); }
.search { padding: 12px 14px; display: flex; gap: 6px; align-items: center; }
.new-group { flex: 0 0 auto; color: var(--accent); display: flex; }
.list-title { padding: 6px 16px; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.list { flex: 1; overflow-y: auto; min-height: 0; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; cursor: pointer; border-left: 3px solid transparent; }
.item:hover { background: var(--panel2); }
.item.active { background: var(--panel2); border-left-color: var(--accent); }
.item-body { flex: 1; min-width: 0; }
.item-top { display: flex; justify-content: space-between; gap: 8px; }
.item-last { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { background: var(--accent); color: #1a1a1a; font-size: 12px; font-weight: 800; border-radius: 10px; padding: 1px 7px; }
.empty-list { padding: 20px; color: var(--muted); text-align: center; font-size: 14px; }

.avatar { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 50%; object-fit: cover; display: flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; font-size: 18px; position: relative; }
.avatar.sm { width: 36px; height: 36px; flex-basis: 36px; font-size: 15px; }
.avatar.xl { width: 120px; height: 120px; flex-basis: 120px; font-size: 48px; }
.avatar-wrap.clickable, .avatar.clickable, .clickable { cursor: pointer; }
.avatar-wrap.clickable:hover .avatar { filter: brightness(1.15); }
.avatar-wrap { position: relative; }
.online-dot { position: absolute; right: 0; bottom: 0; width: 12px; height: 12px; background: #3ddc84; border: 2px solid var(--panel); border-radius: 50%; }

.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); text-align: center; padding: 20px; }
.big-q { font-family: Georgia, serif; font-size: 90px; color: var(--accent); opacity: .25; font-weight: 900; }
.chat-box { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.back { display: none; }
.chat-head-user { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; cursor: pointer; border-radius: 10px; }
.chat-head-user:hover .name { color: var(--accent); }
.chat-head-text { min-width: 0; }
#chatStatus.online, .p-status.online { color: #3ddc84; }
.messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.msg { position: relative; max-width: min(640px, 78%); padding: 8px 12px 6px; border-radius: var(--radius); word-wrap: break-word; overflow-wrap: anywhere; }
.msg.out { align-self: flex-end; background: var(--out); border-bottom-right-radius: 4px; }
.msg.in  { align-self: flex-start; background: var(--in); border-bottom-left-radius: 4px; }
.msg .text { white-space: pre-wrap; }
.meta {
  float: right; position: relative; top: 6px; margin-left: 10px;
  display: inline-flex; align-items: center; gap: 2px;
  font-size: 11px; line-height: 1; color: rgba(255,255,255,.55); white-space: nowrap; user-select: none;
}
.meta-row { display: flex; justify-content: flex-end; margin-top: 2px; }
.meta-row .meta { float: none; top: 0; }
.ticks { display: inline-flex; color: rgba(255,255,255,.6); }
.ticks.read { color: #7fd1ff; }
.from-name { font-size: 13px; font-weight: 700; margin-bottom: 2px; }
.msg .pic { max-width: 100%; max-height: 320px; border-radius: 10px; display: block; margin-bottom: 6px; cursor: zoom-in; }
.msg .file { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; background: rgba(0,0,0,.2); padding: 8px 10px; border-radius: 10px; margin-bottom: 4px; }
.msg .file:hover { background: rgba(0,0,0,.35); }
.fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.fsize { font-size: 12px; color: var(--muted); }
.day-sep { align-self: center; font-size: 12px; color: var(--muted); background: var(--panel); padding: 3px 12px; border-radius: 12px; margin: 8px 0; }

.composer { display: flex; align-items: flex-end; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: var(--panel); }
.composer textarea { resize: none; max-height: 200px; }
.send { padding: 10px 16px; }
.file-chip { display: flex; align-items: center; gap: 8px; padding: 6px 14px; background: var(--panel2); font-size: 13px; border-top: 1px solid var(--line); }
.file-chip span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress { height: 4px; background: var(--panel2); }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width .15s; }

/* ---------- ВЫХОД ---------- */
.logout { display: flex; align-items: center; justify-content: center; }
.logout:hover { color: var(--danger); }
.logout:disabled { opacity: .5; cursor: wait; }

/* ---------- ПРОСМОТР ФОТО ---------- */
.viewer {
  position: fixed; inset: 0; z-index: 150; background: rgba(0, 0, 0, .92);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn .15s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } }
.viewer-img {
  max-width: calc(100vw - 140px); max-height: calc(100vh - 110px);
  object-fit: contain; border-radius: 6px; box-shadow: 0 20px 60px rgba(0,0,0,.6);
  animation: popIn .18s ease-out; user-select: none;
}
@keyframes popIn { from { transform: scale(.94); opacity: 0; } }
.viewer-top {
  position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: linear-gradient(rgba(0,0,0,.7), transparent);
}
.viewer-name { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-top .icon-btn { color: #fff; text-decoration: none; font-size: 20px; }
.viewer-nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 52px; height: 52px;
  border: 0; border-radius: 50%; background: rgba(255,255,255,.1); color: #fff; font-size: 34px; line-height: 1;
}
.viewer-nav:hover { background: rgba(255,255,255,.22); }
.viewer-nav.prev { left: 16px; }
.viewer-nav.next { right: 16px; }

/* ---------- РЕАКЦИИ ---------- */
.reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reacts:empty { display: none; }
.rchip {
  display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 8px;
  border: 1px solid transparent; border-radius: 13px; background: rgba(0,0,0,.25); color: var(--text); font-size: 13px;
}
.rchip:hover:not(:disabled) { background: rgba(0,0,0,.4); }
.rchip.mine { background: rgba(255, 204, 51, .18); border-color: rgba(255, 204, 51, .7); }
.rchip:disabled { cursor: default; }
.rchip .rn { font-weight: 700; font-size: 12px; }
.ri { font-size: 16px; line-height: 1; display: inline-block; }
.ri-img { width: 18px; height: 18px; }
.ri-q {
  font-family: Georgia, serif; font-weight: 900; font-size: 18px;
  color: #ffcc33; text-shadow: 0 0 6px rgba(255, 190, 40, .9), 0 1px 0 #b8860b;
}
.ri-txt {
  font-size: 11px; font-weight: 800; letter-spacing: .5px; color: #ff4d5e;
  text-shadow: 0 0 6px rgba(255, 40, 60, .6);
}

/* кнопка «поставить реакцию» сбоку от сообщения */
.react-btn {
  position: absolute; bottom: 4px; width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel); color: var(--accent);
  font-family: Georgia, serif; font-weight: 900; font-size: 15px; padding: 0;
  opacity: 0; transition: opacity .12s;
}
.msg.in .react-btn  { right: -36px; }
.msg.out .react-btn { left: -36px; }
.msg:hover .react-btn { opacity: 1; }

/* меню выбора реакции */
.react-picker {
  position: fixed; z-index: 160; display: flex; gap: 2px; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 24px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); animation: popIn .12s ease-out;
}
.pick {
  width: 40px; height: 40px; border: 0; border-radius: 50%; background: none;
  display: flex; align-items: center; justify-content: center; padding: 0; transition: transform .1s;
}
.pick:hover { background: var(--panel2); transform: scale(1.18); }
.pick .ri { font-size: 22px; }
.pick .ri-q { font-size: 26px; }
.pick .ri-img { width: 26px; height: 26px; }
.pick .ri-txt { font-size: 10px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line); padding: 10px 18px; border-radius: 12px; z-index: 200; box-shadow: 0 10px 30px rgba(0,0,0,.4); }

/* ---------- МОБИЛЬНЫЕ ---------- */
@media (max-width: 760px) {
  input, textarea, select { font-size: 16px; }
  .composer { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .sidebar { width: 100%; flex-basis: 100%; }
  #app.in-chat .sidebar { display: none; }
  #app:not(.in-chat) .chat { display: none; }
  .back { display: inline-block; }
  .msg { max-width: 88%; }
  .viewer-nav { display: none; }
  .react-btn { display: none; }
}

/* ---------- КОМПОЗЕР: микрофон / отправка ---------- */
.composer .send { display: none; }
.composer .mic {
  display: flex; align-items: center; justify-content: center; padding: 10px 14px;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: transform .15s, background .15s;
}
.composer.typing .send { display: inline-block; }
.composer.typing .mic { display: none; }

/* ---------- ЗАПИСЬ ГОЛОСОВОГО (пока кнопка зажата) ---------- */
.rec-info { display: none; flex: 1; align-items: center; gap: 10px; min-height: 44px; padding: 0 6px; overflow: hidden; }
.composer.recording .rec-info { display: flex; }
.composer.recording #attachBtn, .composer.recording textarea { display: none; }
.composer.recording .mic { background: var(--danger); color: #fff; transform: scale(1.2); box-shadow: 0 0 0 6px rgba(255,92,108,.22); margin-left: 6px; }
.composer.rec-cancel .mic { background: #555; box-shadow: none; transform: scale(1.1); }
.composer.rec-cancel .rec-hint { color: var(--danger); }
.rec-dot { width: 12px; height: 12px; flex: 0 0 12px; border-radius: 50%; background: var(--danger); animation: recBlink 1s infinite; }
@keyframes recBlink { 50% { opacity: .25; } }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 44px; }
.rec-hint { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--muted); font-size: 14px; }

/* ---------- ГОЛОСОВОЕ: плеер ---------- */
.voice { display: flex; align-items: center; gap: 10px; min-width: 230px; padding: 2px 0 4px; }
.vplay {
  width: 42px; height: 42px; flex: 0 0 42px; border: 0; border-radius: 50%;
  background: var(--accent); color: #1a1a1a; font-size: 16px; padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.vplay:hover { filter: brightness(1.08); }
/* значок «играть» — треугольник */
.vplay::before {
  content: ""; width: 0; height: 0; margin-left: 4px;
  border-style: solid; border-width: 9px 0 9px 15px; border-color: transparent transparent transparent #1a1a1a;
}
/* значок «пауза» — две полоски */
.voice.is-playing .vplay::before {
  margin-left: 0; width: 5px; height: 16px; border: 0; background: #1a1a1a; box-shadow: 8px 0 0 #1a1a1a;
  transform: translateX(-4px);
}
/* загрузка — крутящийся кружок */
.voice.is-loading .vplay::before {
  margin: 0; width: 16px; height: 16px; border: 3px solid rgba(0,0,0,.25); border-top-color: #1a1a1a;
  border-radius: 50%; animation: vspin .7s linear infinite;
}
@keyframes vspin { to { transform: rotate(360deg); } }
.vmid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.wave { display: flex; align-items: center; gap: 2px; height: 28px; cursor: pointer; }
.wave span { flex: 1; min-width: 2px; border-radius: 2px; background: rgba(255,255,255,.3); transition: background .1s; }
.wave span.on { background: var(--accent); }
.vtime { font-size: 12px; color: rgba(255,255,255,.65); font-variant-numeric: tabular-nums; }

/* ---------- ОКНО ПРОФИЛЯ ---------- */
.modal {
  position: fixed; inset: 0; z-index: 120; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fadeIn .15s ease-out;
}
.modal-win {
  position: relative; width: 100%; max-width: 400px; max-height: 100%; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 26px 22px 22px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5); animation: popIn .15s ease-out;
}
.modal-x { position: absolute; top: 10px; right: 10px; }
.p-head { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; margin-bottom: 16px; }
.p-head .avatar-wrap { margin-bottom: 8px; }
.p-head .online-dot { width: 20px; height: 20px; right: 6px; bottom: 6px; border-width: 3px; }
.p-name { font-size: 22px; font-weight: 800; overflow-wrap: anywhere; }
.p-status { font-size: 14px; color: var(--muted); }
.p-section { border-top: 1px solid var(--line); padding: 12px 2px; }
.p-label { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 4px; }
.p-bio { white-space: pre-wrap; overflow-wrap: anywhere; }
.p-btn { width: 100%; margin-top: 8px; }
.p-form textarea { resize: vertical; min-height: 80px; }
.p-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.p-row.center { justify-content: center; margin-bottom: 6px; }

@media (max-width: 760px) {
  .modal { padding: 0; align-items: flex-end; }
  .modal-win { max-width: none; border-radius: 20px 20px 0 0; }
  .voice { min-width: 200px; }
}

/* ---------- ШАПКА ЧАТА: кнопки звонка ---------- */
.head-btn { display: flex; align-items: center; color: var(--accent); }
.head-btn:hover { color: var(--accent); }

/* ---------- ГРУППЫ ---------- */
.avatar.group { border-radius: 30%; }
.gicon { font-size: 12px; }
.call-live { color: #3ddc84 !important; font-weight: 700; }
.picker { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--panel2); border: 1px solid var(--line); border-radius: 14px; padding: 3px 4px 3px 10px; font-size: 13px; }
.chip-x { border: 0; background: none; color: var(--muted); padding: 0 4px; font-size: 12px; }
.chip-x:hover { color: var(--danger); }
.pick-results { max-height: 220px; overflow-y: auto; border-radius: 10px; }
.pick-results:empty { display: none; }
.item.compact { padding: 8px 6px; border-radius: 10px; border-left: 0; }
.members { max-height: 320px; overflow-y: auto; }
.tag-owner { font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--accent); color: #1a1a1a; margin-left: 6px; font-weight: 700; }
.online-text { color: #3ddc84; }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn.danger-text { background: none; color: var(--danger); border: 1px solid rgba(255,92,108,.4); }
.btn.danger-text:hover { background: rgba(255,92,108,.1); }
.p-row.two { gap: 8px; margin: 8px 0; }
.p-row.two .btn { flex: 1; }
.center-text { text-align: center; color: var(--muted); }
.full-ico { font-size: 44px; }

/* полоска «Идёт звонок» в группе */
.call-bar { display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: rgba(61,220,132,.1); border-bottom: 1px solid var(--line); }
.cb-text { flex: 1; font-size: 14px; }
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: #3ddc84; animation: recBlink 1.2s infinite; }

/* ---------- ЗВОНОК ---------- */
.call-view {
  position: fixed; inset: 0; z-index: 140; background: #07080c;
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.call-top { display: flex; align-items: center; gap: 10px; padding: 12px 16px; }
.call-title-box { flex: 1; min-width: 0; text-align: center; }
.call-title { font-weight: 800; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-status { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.call-min { position: absolute; left: 10px; top: calc(10px + env(safe-area-inset-top)); font-size: 26px; }
.call-grid { flex: 1; min-height: 0; display: grid; gap: 8px; padding: 8px; }
.call-grid.n1 { grid-template: 1fr / 1fr; }
.call-grid.n2 { grid-template: 1fr / 1fr 1fr; }
.call-grid.n3, .call-grid.n4 { grid-template: 1fr 1fr / 1fr 1fr; }
.tile { position: relative; background: #151821; border-radius: 16px; overflow: hidden; min-height: 0; }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; }
.tile video.mirror { transform: scaleX(-1); }
.tile-ph { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; }
.tile.novid video { opacity: 0; }          /* не display:none — иначе на iPhone пропадает звук */
.tile.novid .tile-ph { display: flex; }
.tile.connecting .tile-ph .avatar { animation: pulse 1.4s infinite; }
.tile-name {
  position: absolute; left: 10px; bottom: 10px; display: flex; gap: 6px; align-items: center;
  background: rgba(0,0,0,.55); padding: 4px 10px; border-radius: 10px; font-size: 13px; max-width: calc(100% - 20px);
}
.tile-conn { color: var(--muted); }
.tile .online-dot, .incoming .online-dot { display: none; }
.call-queue { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 20px; }
.call-controls { display: flex; justify-content: center; gap: 18px; padding: 16px 16px 24px; }
.cbtn {
  width: 60px; height: 60px; border-radius: 50%; border: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.14); color: #fff; font-size: 24px; transition: background .15s, transform .1s;
}
.cbtn:hover { background: rgba(255,255,255,.24); }
.cbtn:active { transform: scale(.94); }
.cbtn.off { background: #fff; color: #111; }
.cbtn:disabled { opacity: .35; cursor: default; }
.cbtn.hang { background: #e5394b; }
.cbtn.hang:hover { background: #ff4d5e; }
.cbtn.accept { background: #2fbf63; }
.cbtn.accept:hover { background: #3ddc84; }
.call-pill {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 90;
  border: 0; border-radius: 20px; background: #2fbf63; color: #fff; font-weight: 700; padding: 8px 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); max-width: calc(100vw - 20px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* входящий звонок */
.incoming { position: fixed; inset: 0; z-index: 145; background: rgba(0,0,0,.75); display: flex; align-items: center; justify-content: center; animation: fadeIn .15s; }
.incoming-win { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 30px; text-align: center; }
.incoming-win .avatar { animation: pulse 1.4s infinite; }
.incoming-name { font-size: 24px; font-weight: 800; margin-top: 10px; }
.incoming-btns { display: flex; gap: 28px; margin-top: 26px; }

/* уведомление о звонке в группе */
.gc-note {
  position: fixed; right: 16px; bottom: 90px; z-index: 95; display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid #2fbf63; border-radius: 14px; padding: 10px 10px 10px 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); max-width: calc(100vw - 32px); animation: popIn .15s;
}
.gc-text { font-size: 14px; }

@media (max-width: 760px) {
  .call-grid.n2 { grid-template: 1fr 1fr / 1fr; }
  .cbtn { width: 56px; height: 56px; }
  .call-controls { gap: 14px; }
  .gc-note { left: 16px; right: 16px; bottom: 84px; }
  .head-btn { padding: 6px; }
}

/* ---------- ЗВОНОК: одно большое окно + маленькие в углу ---------- */
.call-grid { position: relative; }
.call-grid.spot { display: block; }
.call-grid.spot .tile.big { position: absolute; inset: 8px; cursor: zoom-out; }
.call-grid:not(.spot) .tile { cursor: zoom-in; }
.thumbs {
  position: absolute; right: 16px; bottom: 16px; z-index: 3;
  display: flex; flex-direction: column; gap: 8px;
  touch-action: none; cursor: grab; user-select: none;
}
.thumbs:active { cursor: grabbing; }
.thumbs.hidden { display: none; }
.tile.small {
  width: 200px; height: 130px; flex: 0 0 auto; border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.6); border: 2px solid rgba(255,255,255,.18); cursor: pointer;
}
.tile.small:hover { border-color: var(--accent); }
.tile.small .tile-ph .avatar { width: 56px; height: 56px; flex-basis: 56px; font-size: 22px; }
.tile.small .tile-name { left: 6px; bottom: 6px; padding: 2px 8px; font-size: 11px; }
.tile.small .tile-conn { display: none; }
.call-fs { position: absolute; right: 10px; top: calc(10px + env(safe-area-inset-top)); }
@media (max-width: 760px) {
  .tile.small { width: 96px; height: 140px; }
  .thumbs { right: 12px; bottom: 12px; }
}

/* ---------- ИЗБРАННОЕ ---------- */
.avatar.saved { background: linear-gradient(135deg, #ffcc33, #e89a10); color: #1a1a1a; }
.chat-head-user.no-click { cursor: default; }
.chat-head-user.no-click:hover .name { color: inherit; }

/* ---------- СООБЩЕНИЕ О ЗВОНКЕ ---------- */
.msg.call-msg { display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; min-width: 220px; }
.msg.call-msg:hover { filter: brightness(1.08); }
.call-ico {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: rgba(61,220,132,.18); color: #3ddc84;
}
.call-ico.bad { background: rgba(255,92,108,.18); color: var(--danger); }
.call-body { flex: 1; min-width: 0; }
.call-title { font-weight: 700; }
.call-title.bad { color: #ff8a95; }
.call-sub { font-size: 12px; color: rgba(255,255,255,.6); font-variant-numeric: tabular-nums; }
.msg.call-msg .reacts { position: absolute; bottom: -14px; right: 8px; }
.item-last.missed { color: #ff8a95; }

/* ---------- ОКНО «ПРИЛОЖЕНИЕ» ---------- */
.app-ico { width: 88px; height: 88px; border-radius: 22px; box-shadow: 0 8px 30px rgba(255,170,40,.25); }
.ok-text { color: #3ddc84; font-weight: 700; margin-bottom: 4px; }
.link-btn { display: block; text-align: center; text-decoration: none; }
.steps { margin: 4px 0 0; padding-left: 20px; line-height: 1.7; }
.me .icon-btn { display: flex; align-items: center; }

/* ---------- КОД ИЗ ПИСЬМА ---------- */
.code-head { text-align: center; display: flex; flex-direction: column; gap: 4px; }
.code-ico { font-size: 40px; }
.code-title { font-size: 20px; font-weight: 800; }
.code-input { text-align: center; font-size: 30px !important; letter-spacing: 10px; font-weight: 800; padding: 12px !important; font-variant-numeric: tabular-nums; }
.check { flex-direction: row !important; align-items: center; gap: 8px !important; cursor: pointer; }
.check input { width: auto; }
.code-links { display: flex; justify-content: space-between; gap: 10px; }
.link-btn2 { border: 0; background: none; color: var(--accent2); padding: 4px 0; font-size: 14px; }
.link-btn2:disabled { color: var(--muted); cursor: default; }
.small-note { text-align: center; font-size: 12px; }

/* ---------- НАСТРОЙКИ ---------- */
.side-foot { border-top: 1px solid var(--line); padding: 8px 10px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
.settings-btn { width: 100%; display: flex; align-items: center; gap: 10px; border: 0; background: none; color: var(--muted); padding: 10px 12px; border-radius: 10px; font-weight: 600; }
.settings-btn:hover { background: var(--panel2); color: var(--text); }
.set-list { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.set-row { display: flex; align-items: center; gap: 12px; padding: 12px 6px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; width: 100%; }
.set-row:hover { background: var(--panel2); }
.set-row.danger .set-text > span:first-child { color: var(--danger); }
.set-ico { width: 32px; height: 32px; flex: 0 0 32px; border-radius: 10px; background: var(--panel2); display: flex; align-items: center; justify-content: center; font-size: 17px; }
.set-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.set-text > span:first-child { font-weight: 600; }
.set-arrow { color: var(--muted); font-size: 22px; }
.modal-back { position: absolute; top: 10px; left: 10px; font-size: 20px; }

/* ---------- МЕНЮ ЧАТА ---------- */
.ctx-menu {
  position: fixed; z-index: 165; min-width: 220px; padding: 6px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: 0 12px 34px rgba(0,0,0,.55); animation: popIn .12s ease-out;
}
.ctx-title { padding: 6px 10px 8px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.ctx-item, .pick-act { width: 100%; display: flex; align-items: center; gap: 10px; border: 0; background: none; color: var(--text); padding: 9px 10px; border-radius: 9px; text-align: left; font-size: 14px; }
.ctx-item:hover, .pick-act:hover { background: var(--panel2); }
.ctx-item.danger, .pick-act.danger { color: #ff8a95; }
.ctx-ico, .pa-ico { width: 20px; text-align: center; }
.item.pinned { background: rgba(255,204,51,.04); }
.pin-ico { font-size: 12px; opacity: .8; }
.blk-tag { font-size: 12px; }

/* меню сообщения: реакции сверху, действия снизу */
.react-picker { flex-direction: column; border-radius: 18px; gap: 4px; }
.pick-row { display: flex; gap: 2px; }
.pick-acts { display: flex; flex-direction: column; border-top: 1px solid var(--line); padding-top: 4px; }

/* ---------- БЛОКИРОВКА ---------- */
.blocked-bar { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 14px; border-top: 1px solid var(--line); background: var(--panel); color: var(--muted); text-align: center; flex-wrap: wrap; }

/* ---------- ЖАЛОБА ---------- */
.reasons { display: flex; flex-direction: column; gap: 2px; }
.reason { flex-direction: row !important; align-items: center; gap: 10px !important; padding: 8px 10px; border-radius: 10px; cursor: pointer; color: var(--text) !important; font-size: 15px !important; }
.reason:hover { background: var(--panel2); }
.reason input { width: auto; accent-color: var(--accent); }
.rep-photo { position: relative; align-self: flex-start; }
.rep-photo img { max-width: 160px; max-height: 120px; border-radius: 10px; display: block; }
.rep-photo .chip-x { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.6); border-radius: 50%; width: 22px; height: 22px; color: #fff; }

/* ---------- ВИДЕО В ЧАТЕ ---------- */
.vid-box {
  position: relative; width: 320px; max-width: 100%; aspect-ratio: 16 / 9; max-height: 420px;
  border-radius: 10px; overflow: hidden; background: #000; margin-bottom: 6px; cursor: pointer;
}
.vid-box video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.vid-play {
  position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%;
  background: rgba(0,0,0,.55); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; transition: transform .12s;
}
.vid-play::before { content: ""; margin-left: 5px; border-style: solid; border-width: 11px 0 11px 18px; border-color: transparent transparent transparent #fff; }
.vid-box:hover .vid-play { transform: scale(1.08); background: rgba(0,0,0,.7); }
.vid-dur { position: absolute; left: 8px; top: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 10px; font-variant-numeric: tabular-nums; }
.vid-dl { position: absolute; right: 8px; top: 8px; width: 30px; height: 30px; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; text-decoration: none; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.vid-dl:hover { background: rgba(0,0,0,.85); }
.vid-box.vid-err { aspect-ratio: auto; height: 90px; }
.vid-box.vid-err .vid-play { display: none; }
#viewerVid { background: #000; }
@media (max-width: 760px) { .vid-box { width: 260px; } }

/* ---------- ОБРЕЗКА АВАТАРКИ ---------- */
.crop-wrap { display: flex; justify-content: center; margin: 6px 0 10px; }
.crop-stage { position: relative; width: 280px; height: 280px; overflow: hidden; border-radius: 16px; background: #000; touch-action: none; cursor: grab; user-select: none; }
.crop-stage:active { cursor: grabbing; }
.crop-img { position: absolute; left: 0; top: 0; transform-origin: 0 0; max-width: none; pointer-events: none; }
.crop-ring { position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 400px rgba(0,0,0,.55); border: 2px solid rgba(255,255,255,.8); pointer-events: none; }
.crop-zoom-row { gap: 10px; color: var(--muted); font-size: 20px; }
.crop-zoom { flex: 1; padding: 0; accent-color: var(--accent); }

/* ---------- КАПТЧА ---------- */
.captcha {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel2); color: var(--text); text-align: left; font-size: 15px;
}
.captcha:hover { border-color: #3a4152; }
.cap-box { width: 24px; height: 24px; flex: 0 0 24px; border-radius: 6px; border: 2px solid #5a6275; background: var(--bg); position: relative; }
.cap-text { flex: 1; }
.cap-brand { font-size: 11px; color: var(--muted); }
.captcha.solving .cap-box { border-color: transparent; border-top-color: var(--accent); border-radius: 50%; animation: vspin .7s linear infinite; }
.captcha.done .cap-box { border-color: #2fbf63; background: #2fbf63; }
.captcha.done .cap-box::after { content: ""; position: absolute; left: 6px; top: 1px; width: 7px; height: 13px; border: solid #fff; border-width: 0 3px 3px 0; transform: rotate(45deg); }
.captcha.done .cap-text { color: #3ddc84; }

/* =================== СТИКЕРЫ И АНИМАЦИИ =================== */
@keyframes stkBeat { 0%, 100% { transform: scale(1); } 14% { transform: scale(1.13); } 28% { transform: scale(1); } 42% { transform: scale(1.09); } 56% { transform: scale(1); } }
@keyframes stkGlow { 0%, 100% { filter: drop-shadow(0 0 2px rgba(255,190,40,.35)); } 50% { filter: drop-shadow(0 0 10px rgba(255,190,40,.95)) brightness(1.15); } }
@keyframes stkFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6%); } }
@keyframes stkWiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-7deg); } 75% { transform: rotate(7deg); } }
@keyframes stkJelly { 0%, 100% { transform: scale(1, 1); } 30% { transform: scale(1.1, .9); } 50% { transform: scale(.94, 1.06); } 70% { transform: scale(1.03, .97); } }
@keyframes stkSwing { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(10deg); } }
@keyframes stkPop { 0% { transform: scale(.2) rotate(-14deg); opacity: 0; } 60% { transform: scale(1.15) rotate(4deg); opacity: 1; } 100% { transform: scale(1) rotate(0); } }

/* в переписке и в реакциях анимации играют всегда, в сетках — при наведении */
.stk[data-a="beat"], .rchip [data-a="beat"], .stk-big[data-a="beat"] { animation: stkBeat 1.6s ease-in-out infinite; }
.stk[data-a="glow"], .rchip [data-a="glow"], .stk-big[data-a="glow"] { animation: stkGlow 2.2s ease-in-out infinite; }
.stk[data-a="float"], .rchip [data-a="float"], .stk-big[data-a="float"] { animation: stkFloat 2.6s ease-in-out infinite; }
.stk[data-a="wiggle"], .rchip [data-a="wiggle"], .stk-big[data-a="wiggle"] { animation: stkWiggle 1.8s ease-in-out infinite; }
.stk[data-a="jelly"], .rchip [data-a="jelly"], .stk-big[data-a="jelly"] { animation: stkJelly 2s ease-in-out infinite; }
.stk[data-a="swing"], .rchip [data-a="swing"], .stk-big[data-a="swing"] { animation: stkSwing 2.4s ease-in-out infinite; transform-origin: 50% 10%; }
.stk-cell:hover img[data-a="beat"], .rcell:hover img { animation: stkBeat 1.2s ease-in-out infinite; }
.stk-cell:hover img[data-a="glow"] { animation: stkGlow 1.4s ease-in-out infinite; }
.stk-cell:hover img[data-a="float"], .stk-cell:hover img[data-a="swing"] { animation: stkFloat 1.4s ease-in-out infinite; }
.stk-cell:hover img[data-a="wiggle"], .stk-cell:hover img[data-a="jelly"], .stk-cell:hover img:not([data-a]) { animation: stkWiggle 1s ease-in-out infinite; }
.stk.pop { animation: stkPop .55s cubic-bezier(.2,1.4,.4,1) both !important; }
@media (prefers-reduced-motion: reduce) { .stk, .rchip img, .stk-cell img, .rcell img, .stk-big { animation: none !important; } }

/* стикер в чате: без пузыря */
.msg.sticker-msg { background: none !important; box-shadow: none !important; padding: 0; border: 0; }
.msg.sticker-msg .stk { display: block; width: 160px; height: 160px; object-fit: contain; cursor: pointer; filter: drop-shadow(0 4px 10px rgba(0,0,0,.35)); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.msg.sticker-msg.out .stk { margin-left: auto; }
.msg.sticker-msg .meta-row { justify-content: flex-end; }
.msg.sticker-msg .meta { background: rgba(0,0,0,.45); border-radius: 10px; padding: 1px 7px; color: #ddd; }
.stk-missing { padding: 10px 14px; border-radius: 12px; background: var(--panel2); color: var(--muted); }
@media (max-width: 760px) { .msg.sticker-msg .stk { width: 140px; height: 140px; } }

/* реакции-стикеры */
.ri-stk { width: 22px; height: 22px; object-fit: contain; display: block; }
.rchip .ri-stk { width: 22px; height: 22px; }
.pick .ri-stk { width: 30px; height: 30px; }
.pick.more { color: var(--muted); font-size: 20px; font-weight: 700; }
.react-picker.wide { width: min(360px, calc(100vw - 16px)); padding: 8px; }
.rgrid-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 2px 8px; font-weight: 700; color: var(--muted); font-size: 13px; }
.rtabs { display: flex; gap: 4px; overflow-x: auto; padding: 2px 2px 6px; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.rtabs::-webkit-scrollbar { display: none; }
.rtab { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 10px; border: 0; background: none; padding: 4px; display: flex; align-items: center; justify-content: center; opacity: .6; }
.rtab.on { background: var(--panel2); opacity: 1; box-shadow: inset 0 -2px 0 var(--accent); }
.rtab .ri-stk { width: 28px; height: 28px; }
.rgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 2px; max-height: min(300px, 46vh); overflow-y: auto; padding-top: 6px; overscroll-behavior: contain; }
.rcell { aspect-ratio: 1; border: 0; background: none; border-radius: 10px; padding: 3px; display: flex; align-items: center; justify-content: center; }
.rcell:hover { background: var(--panel2); }
.rcell .ri-stk { width: 100%; height: 100%; }
.rcell .ri { font-size: 24px; }

/* кнопка и панель стикеров */
.stk-btn { color: var(--muted); }
.stk-btn.on, .stk-btn:hover { color: var(--accent); }
.composer.recording .stk-btn { display: none; }
.stk-panel {
  border-top: 1px solid var(--line); background: var(--panel); height: min(340px, 45vh);
  display: flex; flex-direction: column; animation: slideUp .16s ease-out;
}
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.stk-tabs { display: flex; gap: 4px; padding: 6px 8px; overflow-x: auto; border-bottom: 1px solid var(--line); flex: 0 0 auto; scrollbar-width: thin; }
.stk-tab { flex: 0 0 auto; width: 42px; height: 42px; border-radius: 12px; border: 0; background: none; padding: 4px; font-size: 20px; display: flex; align-items: center; justify-content: center; opacity: .65; }
.stk-tab img { width: 100%; height: 100%; object-fit: contain; }
.stk-tab.on { opacity: 1; background: var(--panel2); box-shadow: inset 0 -2px 0 var(--accent); }
.stk-body { flex: 1; overflow-y: auto; padding: 6px 8px 10px; overscroll-behavior: contain; }
.stk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 4px; }
.stk-grid.in-modal { max-height: 46vh; overflow-y: auto; width: 100%; }
.stk-cell { aspect-ratio: 1; border: 0; background: none; border-radius: 12px; padding: 5px; display: flex; align-items: center; justify-content: center; transition: background .12s, transform .12s; }
.stk-cell:hover { background: var(--panel2); }
.stk-cell:active { transform: scale(.92); }
.stk-cell img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; -webkit-user-select: none; user-select: none; }
.stk-pack-title { display: flex; align-items: center; gap: 8px; font-weight: 700; padding: 4px 2px 8px; }
.stk-pack-title .link-btn { margin-left: auto; }
.stk-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 30px 16px; }
.stk-big { width: 180px; height: 180px; object-fit: contain; }
.tag18 { font-size: 11px; font-weight: 800; color: #fff; background: #c3122e; border-radius: 6px; padding: 1px 6px; margin-left: 6px; }
.stk-cat { display: flex; flex-direction: column; gap: 4px; width: 100%; }
.cat-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border: 0; border-radius: 12px; background: var(--panel2); text-align: left; width: 100%; }
.cat-row:hover { background: #262b38; }
.cat-row img { width: 46px; height: 46px; object-fit: contain; flex: 0 0 auto; }
.cat-row.bot { background: linear-gradient(90deg, rgba(255,204,51,.16), rgba(195,18,46,.12)); border: 1px solid rgba(255,204,51,.35); }
.cat-ico { width: 46px; height: 46px; display: flex; align-items: center; justify-content: center; font-size: 28px; flex: 0 0 auto; }
.cat-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.cat-note { padding: 8px 4px; text-align: center; }
.set-sub { align-self: flex-start; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-top: 6px; }
.link-btn { border: 0; background: none; color: var(--accent2); padding: 0; font-size: 13px; text-decoration: underline; }
.danger-text { color: #ff8a95 !important; }

/* кнопки бота */
.bot-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.bot-btn {
  flex: 1 1 auto; min-width: 90px; border: 1px solid rgba(255,204,51,.45); background: rgba(255,204,51,.08); color: var(--accent);
  border-radius: 10px; padding: 7px 12px; font-weight: 600; font-size: 14px; transition: background .12s, transform .1s;
}
.bot-btn:hover { background: rgba(255,204,51,.18); }
.bot-btn:active { transform: scale(.96); }
.bot-btn.done { border-color: #3fb37f; color: #6fe3a8; background: rgba(63,179,127,.12); }
.sticker-msg .bot-btns { max-width: 200px; }
.msg.out .bot-btns { justify-content: flex-end; }
.bot-tag { font-size: 10px; font-weight: 800; text-transform: uppercase; color: var(--bg); background: var(--accent); border-radius: 5px; padding: 0 5px; margin-left: 6px; vertical-align: 2px; }

/* =================== ПАПКИ ЧАТОВ =================== */
.folder-tabs { display: flex; gap: 6px; padding: 6px 10px 8px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.folder-tabs::-webkit-scrollbar { display: none; }
.ftab {
  flex: 0 0 auto; display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: none; color: var(--muted);
  border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; transition: all .12s;
}
.ftab:hover { color: var(--text); border-color: #3a4050; }
.ftab.on { color: var(--bg); background: var(--accent); border-color: var(--accent); }
.ftab.add { padding: 5px 10px; text-transform: none; font-size: 15px; }
.fbadge { background: var(--accent2); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 6px; min-width: 18px; text-align: center; }
.ftab.on .fbadge { background: var(--bg); color: var(--accent); }
.f-ico { width: 40px; height: 40px; border-radius: 12px; background: var(--panel2); display: flex; align-items: center; justify-content: center; font-size: 20px; flex: 0 0 auto; }
.pick-list { max-height: 44vh; overflow-y: auto; width: 100%; }
.item.pick { cursor: pointer; }
.item.pick input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); flex: 0 0 auto; }
.p-field { width: 100%; }

/* кнопка игр в подвале */
.side-foot { display: flex; gap: 6px; }
.side-foot .settings-btn { flex: 1; }
.games-btn { color: var(--accent) !important; }
.games-btn:hover svg { animation: stkWiggle .6s ease-in-out; }

/* =================== ИГРЫ =================== */
.games {
  position: fixed; inset: 0; z-index: 180; display: flex; flex-direction: column;
  background: radial-gradient(900px 500px at 50% -10%, #2a0a12 0%, #0b0d13 65%); color: var(--text);
  padding-top: env(safe-area-inset-top); user-select: none; -webkit-user-select: none;
}
body.games-open { overflow: hidden; }
.g-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,.06); flex: 0 0 auto; }
.g-title { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.g-title b { font-size: 17px; }
.g-sub { font-size: 12px; color: var(--muted); }
.g-ico { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); font-size: 18px; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.g-ico:hover { border-color: var(--accent); }
.g-ico.off { opacity: .35; text-decoration: line-through; }
.g-menu { flex: 1; overflow-y: auto; padding: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; align-content: start; max-width: 900px; width: 100%; margin: 0 auto; }
.g-card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 20px 10px 14px; border-radius: 18px;
  border: 1px solid color-mix(in srgb, var(--gc) 40%, transparent); background: linear-gradient(160deg, color-mix(in srgb, var(--gc) 18%, #161922), #11131a 70%);
  transition: transform .15s, box-shadow .15s; overflow: hidden;
}
.g-card:hover { transform: translateY(-3px) scale(1.02); box-shadow: 0 10px 30px color-mix(in srgb, var(--gc) 30%, transparent); }
.g-card:active { transform: scale(.97); }
.g-icon { font-size: 44px; line-height: 1.1; filter: drop-shadow(0 4px 12px color-mix(in srgb, var(--gc) 60%, transparent)); transition: transform .2s; }
.g-card:hover .g-icon { animation: stkJelly .7s ease-in-out; }
.g-name { font-weight: 800; font-size: 16px; }
.g-tags { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; }
.g-best { position: absolute; top: 8px; right: 10px; font-size: 11px; color: var(--accent); }
.g-intro { flex: 1; overflow-y: auto; padding: 18px 16px 24px; display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: 560px; width: 100%; margin: 0 auto; }
.g-big-icon { font-size: 76px; animation: stkFloat 2.6s ease-in-out infinite; filter: drop-shadow(0 8px 24px color-mix(in srgb, var(--gc) 70%, transparent)); }
.g-desc { text-align: center; color: #c9cdd8; margin: 0; }
.g-opts { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.g-opts:empty { display: none; }
.g-seg { display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 4px; gap: 4px; }
.g-seg button { flex: 1; border: 0; background: none; border-radius: 10px; padding: 10px 6px; font-weight: 700; color: var(--muted); }
.g-seg button.on { background: var(--accent); color: #1a1205; }
.g-seg.small button { padding: 7px 4px; font-size: 13px; }
.g-hint { font-size: 13px; color: var(--muted); text-align: center; }
.g-ctrls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
@media (max-width: 520px) { .g-ctrls { grid-template-columns: 1fr; } }
.g-ctrl { border: 1px solid var(--line); background: rgba(22,25,34,.8); border-radius: 14px; padding: 10px 12px; opacity: .6; }
.g-ctrl.mine { opacity: 1; border-color: rgba(255,204,51,.5); box-shadow: 0 0 0 1px rgba(255,204,51,.15) inset; }
.g-ctrl-t { font-weight: 800; font-size: 13px; margin-bottom: 4px; }
.g-ctrl ul { margin: 0; padding-left: 18px; font-size: 13px; color: #c9cdd8; }
.g-btn { border: 0; border-radius: 14px; padding: 13px 22px; font-weight: 800; font-size: 16px; min-width: 200px; transition: transform .1s, filter .1s; }
.g-btn.primary { background: linear-gradient(180deg, #ffd84d, #f0a800); color: #1a1205; box-shadow: 0 6px 20px rgba(255,190,40,.35); }
.g-btn.ghost { background: var(--panel); border: 1px solid var(--line); color: var(--text); }
.g-btn:hover { filter: brightness(1.1); }
.g-btn:active { transform: scale(.96); }
.g-score { text-align: center; font-weight: 800; color: var(--accent); padding: 6px; min-height: 30px; font-variant-numeric: tabular-nums; }
.g-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 6px; touch-action: none; position: relative; }
.g-canvas { display: block; border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.05); touch-action: none; }
.g-pad { flex: 0 0 auto; display: flex; justify-content: center; padding: 6px 10px max(10px, env(safe-area-inset-bottom)); }
.g-pad:empty { display: none; }
.g-vbtn {
  width: 62px; height: 62px; border-radius: 18px; border: 1px solid rgba(255,255,255,.12); background: rgba(30,34,46,.9);
  font-size: 22px; color: var(--text); touch-action: none; -webkit-tap-highlight-color: transparent; transition: transform .06s, background .06s;
}
.g-vbtn.on { background: var(--accent); color: #1a1205; transform: scale(.94); }
.g-vbtn.small { font-size: 14px; color: var(--muted); }
.g-vbtn.big { width: 46%; height: 70px; font-size: 28px; }
.g-dpad { display: grid; grid-template-columns: repeat(3, 62px); grid-template-rows: repeat(3, 62px); gap: 6px; }
.g-race-pad { display: flex; gap: 10px; width: 100%; justify-content: center; }
.g-race-pad.duo { justify-content: space-between; }
.g-race-pad.duo > div { display: flex; gap: 8px; }
.g-over { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(5,6,10,.7); backdrop-filter: blur(4px); animation: popIn .2s ease-out; z-index: 5; }
.g-over-card { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 26px 22px; border-radius: 22px; background: #161922; border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0,0,0,.6); min-width: 280px; max-width: 92vw; text-align: center; }
.g-over-t { font-size: 22px; font-weight: 900; }
.g-over-s { font-size: 54px; font-weight: 900; color: var(--accent); line-height: 1; text-shadow: 0 0 20px rgba(255,190,40,.6); }
.g-over-x { color: var(--muted); }
.g-rec { color: var(--accent); font-weight: 800; animation: stkBeat 1.2s ease-in-out infinite; }

/* крестики-нолики */
.ttt-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.ttt-info { font-weight: 800; font-size: 18px; min-height: 26px; }
.ttt { display: grid; grid-template-columns: repeat(3, min(26vw, 110px)); gap: 8px; }
.ttt-c { aspect-ratio: 1; border-radius: 16px; border: 1px solid var(--line); background: var(--panel); font: 900 min(14vw, 60px)/1 Georgia, serif; transition: transform .1s, background .1s; }
.ttt-c:hover { background: var(--panel2); }
.ttt-c.x { color: #ff4d5e; text-shadow: 0 0 16px rgba(255,77,94,.7); animation: stkPop .3s ease-out; }
.ttt-c.o { color: #ffcc33; text-shadow: 0 0 16px rgba(255,204,51,.7); animation: stkPop .3s ease-out; }
.ttt-c.win { background: rgba(255,204,51,.18); border-color: var(--accent); animation: stkBeat 1s ease-in-out infinite; }

/* 2048 */
.g2048-wrap { display: flex; justify-content: center; }
.g2048 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 8px; border-radius: 16px; background: #1a1d27; width: min(92vw, 60vh, 420px); aspect-ratio: 1; touch-action: none; }
.t2 { border-radius: 10px; background: #232836; display: flex; align-items: center; justify-content: center; font: 900 clamp(18px, 6vw, 34px)/1 sans-serif; color: #fff; }
.t2.new { animation: stkPop .22s ease-out; }
.t2.merged { animation: stkJelly .25s ease-out; }
.t2.v2 { background: #3a3f50; } .t2.v4 { background: #4a4f62; }
.t2.v8 { background: #8a2a3a; } .t2.v16 { background: #a52438; } .t2.v32 { background: #c3122e; } .t2.v64 { background: #e0192d; }
.t2.v128 { background: #c98a00; font-size: clamp(16px, 5vw, 30px); } .t2.v256 { background: #e0a000; font-size: clamp(16px, 5vw, 30px); } .t2.v512 { background: #ffb800; color: #1a1205; font-size: clamp(16px, 5vw, 30px); }
.t2.v1024, .t2.v2048, .t2.v4096 { background: #ffcc33; color: #1a1205; font-size: clamp(13px, 4vw, 24px); box-shadow: 0 0 20px rgba(255,204,51,.7); }

/* =================== v9: ПОЛОСЫ ПРОКРУТКИ, ТЕЛЕФОН =================== */
html { background: var(--bg); color-scheme: dark; }
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.13) transparent; }
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track, *::-webkit-scrollbar-corner { background: transparent; }
*::-webkit-scrollbar-thumb { background: rgba(255,255,255,.13); border-radius: 6px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(255,204,51,.45); }
*::-webkit-scrollbar-button { display: none; height: 0; width: 0; }
.messages, .list { scrollbar-gutter: auto; }
@media (hover: none) { * { scrollbar-width: none; } *::-webkit-scrollbar { display: none; } }

/* поле ввода как в Telegram: растёт до ~7 строк, полосы прокрутки не видно */
#textInput { overflow-y: hidden; scrollbar-width: none; line-height: 1.4; max-height: 170px; min-height: 44px; border-radius: 22px; padding: 11px 16px; }
#textInput::-webkit-scrollbar { display: none; }
#textInput.maxed { overflow-y: auto; }
.composer { align-items: flex-end; }
.composer .icon-btn { height: 44px; flex: 0 0 auto; }
.composer .btn.primary { height: 44px; min-width: 44px; border-radius: 50%; padding: 0; display: flex; align-items: center; justify-content: center; }
.composer .send { font-size: 18px; }
.composer.typing .send { display: flex; }

/* кнопка реакции «?» — только при наведении мышью */
@media (hover: none) { .react-btn { display: none !important; } }
.msg.sticker-msg .react-btn, .msg.call-msg .react-btn { display: none; }

/* реакции под сообщением о звонке — не налезают на соседнее сообщение */
.msg.call-msg { flex-wrap: wrap; }
.msg.call-msg .reacts { position: static; flex-basis: 100%; margin: 2px 0 0 46px; }

/* =================== ПРЕВЬЮ ВЛОЖЕНИЯ =================== */
.file-chip { padding: 8px 12px; gap: 12px; border-top: 1px solid var(--line); background: var(--panel); animation: slideUp .14s ease-out; }
.fc-thumb { width: 56px; height: 56px; border-radius: 10px; overflow: hidden; flex: 0 0 auto; background: var(--panel2); display: flex; align-items: center; justify-content: center; position: relative; }
.fc-thumb img, .fc-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.fc-doc { font-size: 26px; }
.fc-play { position: absolute; width: 22px; height: 22px; border-radius: 50%; background: rgba(0,0,0,.55); }
.fc-play::after { content: ''; position: absolute; left: 8px; top: 6px; border-left: 8px solid #fff; border-top: 5px solid transparent; border-bottom: 5px solid transparent; }
.fc-dur { position: absolute; left: 3px; bottom: 3px; font-size: 10px; background: rgba(0,0,0,.6); border-radius: 4px; padding: 0 3px; }
.fc-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-chip .fc-name { font-weight: 700; color: var(--accent); flex: none; }
.file-chip .fc-size { flex: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* =================== ОТВЕТЫ =================== */
.reply-bar { display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-top: 1px solid var(--line); background: var(--panel); animation: slideUp .14s ease-out; }
.rb-ico { color: var(--accent); font-size: 20px; width: 24px; text-align: center; }
.rb-thumb { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; }
.rb-thumb.stk { object-fit: contain; }
.rb-body { flex: 1; min-width: 0; border-left: 2px solid var(--accent); padding-left: 8px; cursor: pointer; }
.rb-name { color: var(--accent); font-weight: 700; font-size: 13px; }
.rb-text, .rq-text { font-size: 13px; color: #c9cdd8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-q { display: flex; gap: 8px; align-items: center; margin: 2px 0 6px; padding: 4px 8px; border-left: 3px solid var(--accent); border-radius: 6px; background: rgba(0,0,0,.18); cursor: pointer; max-width: 100%; min-width: 120px; }
.reply-q:hover { background: rgba(0,0,0,.28); }
.reply-q.gone { opacity: .6; cursor: default; font-style: italic; }
.rq-body { min-width: 0; }
.rq-name { font-weight: 700; font-size: 13px; }
.rq-thumb { width: 34px; height: 34px; border-radius: 5px; object-fit: cover; flex: 0 0 auto; }
.msg.sticker-msg .reply-q, .msg.round-msg .reply-q { background: var(--panel2); }
@keyframes msgFlash { 0%, 100% { box-shadow: none; } 30% { box-shadow: 0 0 0 3px rgba(255,204,51,.7); } }
.msg.flash { animation: msgFlash 1.4s ease-in-out 1; }
.msg.swiping { transition: none; }
.msg { transition: transform .2s ease; }
.msg.swipe-ok::after { content: '↩'; position: absolute; right: -34px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #1a1205; display: flex; align-items: center; justify-content: center; font-weight: 900; }

/* =================== КРУЖОЧКИ =================== */
.msg.round-msg { background: none !important; padding: 0; box-shadow: none; }
.round-box {
  position: relative;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
  background: #000;
  box-shadow: 0 6px 20px rgba(0,0,0,.45);
}
.msg.out .round-box { margin-left: auto; }
.round-v { width: 100%; height: 100%; object-fit: cover; display: block; }
.round-ring { position: absolute; inset: 0; pointer-events: none; }
.round-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.round-ring circle { fill: none; stroke: transparent; stroke-width: 1; stroke-dasharray: 301.6; stroke-dashoffset: 301.6; stroke-linecap: round; }
.round-box.loud .round-ring circle { stroke: #ffffff; }
.round-dur, .round-snd { position: absolute; bottom: 14px; font-size: 12px; background: rgba(0,0,0,.55); border-radius: 10px; padding: 1px 8px; color: #fff; }
.round-dur { left: 50%; transform: translateX(-50%); }
.round-snd { right: 30px; bottom: 30px; padding: 2px 5px; }
.round-box.loud .round-snd { display: none; }
.round-box.paused::after { content: ''; position: absolute; left: 50%; top: 50%; transform: translate(-40%, -50%); border-left: 26px solid rgba(255,255,255,.85); border-top: 16px solid transparent; border-bottom: 16px solid transparent; }
.msg.round-msg .meta-row .meta { background: rgba(0,0,0,.45); border-radius: 10px; padding: 1px 7px; }
@media (max-width: 760px) { .round-box:not(.is-expanded) { width: 176px; height: 176px; } }

/* запись кружочка: живое видео в круге над чатом */
.round-rec { position: fixed; inset: 0; z-index: 150; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; background: rgba(5,6,10,.72); backdrop-filter: blur(6px); pointer-events: none; animation: fadeIn .15s; }
.rr-circle { position: relative; width: min(72vw, 320px); aspect-ratio: 1; border-radius: 50%; overflow: hidden; background: #000; box-shadow: 0 10px 40px rgba(0,0,0,.6); animation: popIn .2s ease-out; }
.rr-circle video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.rr-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.rr-ring circle { fill: none; stroke-width: 2.4; stroke: rgba(255,255,255,.15); }
.rr-ring #rrProg { stroke: var(--danger); stroke-dasharray: 301.6; stroke-dashoffset: 301.6; stroke-linecap: round; transition: stroke-dashoffset .1s linear; }
.rr-info { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.rr-hint { color: var(--muted); font-size: 14px; font-weight: 500; }
.round-rec.rec-cancel .rr-hint { color: var(--danger); }
.round-rec.rec-cancel .rr-circle { opacity: .5; }

/* кнопка: микрофон или камера */
.composer .mic .i-cam { display: none; }
.composer .mic.cam .i-cam { display: block; }
.composer .mic.cam .i-mic { display: none; }
.composer .mic.flip { animation: micFlip .3s ease; }
@keyframes micFlip { 0% { transform: rotateY(0) scale(1); } 50% { transform: rotateY(90deg) scale(.8); } 100% { transform: rotateY(0) scale(1); } }
.round-box { position: relative; }
.round-box .round-v { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }

/* пока метаданные не пришли — лёгкий скелетон, а не чёрный круг */
.round-box:not(.round-ready):not(.round-error) .round-v { opacity: 0; }
.round-box:not(.round-ready):not(.round-error)::before {
  content: '';
  position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #2a2f3a, #15181f);
  animation: roundPulse 1.2s ease-in-out infinite;
}
@keyframes roundPulse { 0%,100% { opacity: .7 } 50% { opacity: 1 } }

/* ошибка загрузки — понятная заглушка вместо мёртвого круга */
.round-box.round-error .round-v { display: none; }
.round-box.round-error::before {
  content: '⚠';
  position: absolute; inset: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: #2a1a1a; color: #ff8a95; font-size: 28px;
}

/* =================== СПИСОК: АРХИВ, СВАЙПЫ, БЕЗ ЗВУКА =================== */
.item-wrap { position: relative; overflow: hidden; }
.item-wrap > .item { position: relative; background: var(--panel); z-index: 1; will-change: transform; }
.item-wrap > .item.active { background: #1c2232; }
.item-acts { position: absolute; top: 0; right: 0; bottom: 0; width: 148px; display: flex; }
.ia { flex: 1; border: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 700; color: #fff; }
.ia-ico { font-size: 20px; }
.ia.mute { background: #4f5b75; }
.ia.arch { background: #8a6d1f; }
.arch-row .arch-av { background: linear-gradient(135deg, #3a3f50, #22262f); font-size: 22px; display: flex; align-items: center; justify-content: center; }
.arch-head { display: flex; align-items: center; gap: 8px; padding: 6px 10px; font-weight: 800; border-bottom: 1px solid var(--line); }
.arch-head .icon-btn { font-size: 18px; }
.badge.muted-b { background: #5b6275; color: #e8eaf0; }
.mute-tag { font-size: 12px; opacity: .8; }
.pin-ico { margin-right: 4px; }

/* =================== ПРИГЛАШЕНИЕ В ИГРУ =================== */
.msg.game-msg { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; min-width: 240px; background: linear-gradient(135deg, #2a1420, #1c2030); border: 1px solid rgba(255,204,51,.3); }
.gm-ico { font-size: 34px; animation: stkFloat 2.4s ease-in-out infinite; }
.gm-body { flex: 1; min-width: 0; }
.gm-title { font-weight: 800; }
.gm-sub { font-size: 13px; color: var(--muted); }
.game-msg .meta-row { flex-basis: 100%; margin-top: -4px; }
.game-msg .bot-btns { flex-basis: 100%; margin-top: 0; }
.bot-btn.ghost { color: var(--muted); border-color: var(--line); background: none; }
.game-inv .gi-ico { font-size: 54px; animation: stkJelly 1.2s ease-in-out infinite; }
.incoming-what { color: var(--muted); }

/* =================== ОБНОВЛЕНИЕ =================== */
.upd-bar {
  position: fixed;
  left: 50%;
  top: 60px; /* Опускаем вниз, чтобы не было под чёлкой */
  transform: translateX(-50%);
  z-index: 190;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 8px 16px;
  border-radius: 14px;
  background: var(--panel2);
  border: 1px solid rgba(255,204,51,.5);
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  font-weight: 600;
  animation: popIn .2s;
  white-space: nowrap;
  max-width: calc(100vw - 20px);
}

/* =================== ТЕЛЕФОН =================== */
@media (max-width: 760px) {
  .round-box.is-expanded {
    transform: scale(1.4);
  }
  body { background: var(--bg); }
  .composer { padding: 8px 8px max(8px, env(safe-area-inset-bottom)); gap: 6px; }
  .chat-box, .chat { background: var(--bg); }
  .messages { padding: 12px 10px; }
  .stk-panel { height: min(300px, 42vh); }
  .stk-grid { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); }
  .msg.swipe-ok::after { right: -32px; }
}

/* =================== ДЕМОНСТРАЦИЯ ЭКРАНА =================== */
.cbtn.on { background: #3fb37f !important; color: #fff !important; }
.tile.screen video { object-fit: contain !important; background: #000; }
.scr-pick { position: absolute; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.6); animation: fadeIn .15s; padding: 16px; }
.scr-win { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 20px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); max-width: 460px; width: 100%; text-align: center; animation: popIn .15s; }
.scr-win.wide { max-width: 760px; max-height: 86vh; }
.scr-title { font-size: 18px; font-weight: 800; }
.scr-opts { display: flex; gap: 10px; width: 100%; }
.scr-opt { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 14px 6px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel2); }
.scr-opt b { font-size: 18px; }
.scr-opt span { font-size: 12px; color: var(--muted); }
.scr-opt.def { border-color: rgba(255,204,51,.6); }
.scr-opt:hover { border-color: var(--accent); transform: translateY(-2px); }
.scr-srcs { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; overflow-y: auto; width: 100%; }
.scr-src { display: flex; flex-direction: column; gap: 6px; padding: 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel2); font-size: 12px; }
.scr-src img { width: 100%; aspect-ratio: 16/9; object-fit: contain; background: #000; border-radius: 6px; }
.scr-src span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scr-src:hover { border-color: var(--accent); }

/* ===== игры: друг онлайн ===== */
.g-search { width: 100%; }
.g-friends { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.g-friend { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); text-align: left; }
.g-friend:hover { border-color: var(--accent); }
.gf-name { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.gf-st { font-size: 12px; color: var(--muted); }
.gf-st.on { color: #3fb37f; }
.gf-go { color: var(--accent); font-weight: 700; font-size: 13px; }
.g-wait { justify-content: center; text-align: center; }
.g-dots { display: flex; gap: 8px; }
.g-dots span { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: gDot 1s ease-in-out infinite; }
.g-dots span:nth-child(2) { animation-delay: .15s; } .g-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes gDot { 0%, 100% { transform: scale(.6); opacity: .4; } 50% { transform: scale(1); opacity: 1; } }
@media (max-width: 760px) {
  .g-head { padding: 8px 10px; }
  .g-ico { width: 36px; height: 36px; }
  .g-menu { grid-template-columns: repeat(2, 1fr); padding: 10px; gap: 10px; }
  .g-stage { padding: 2px; }
  .g-btn { min-width: 0; width: 100%; }
}
.composer:not(.typing) .send { display: none !important; }
.composer.typing .mic { display: none !important; }
.game-inv { position: relative; }
.game-inv .gi-ico { margin-bottom: -30px; z-index: 2; position: relative; filter: drop-shadow(0 4px 10px rgba(0,0,0,.6)); }
.tag18.big { font-size: 22px; padding: 4px 12px; border-radius: 10px; margin: 0; }

/* =================== iPhone: вырез сверху, полоса снизу =================== */
.topbar { padding-top: env(safe-area-inset-top); height: calc(56px + env(safe-area-inset-top)); flex-basis: calc(56px + env(safe-area-inset-top)); }
html { background: var(--panel); }
@media (max-width: 760px) {
  /* полоса «домой» на iPhone: поле ввода ближе к низу, как в Telegram */
  .composer { padding-bottom: max(8px, calc(env(safe-area-inset-bottom) - 16px)) !important; }
  .side-foot { padding-bottom: max(6px, calc(env(safe-area-inset-bottom) - 18px)); }
  /* когда открыта клавиатура, отступ под «домой» не нужен */
  .composer:focus-within { padding-bottom: 8px !important; }
  .topbar { height: calc(48px + env(safe-area-inset-top)); flex-basis: calc(48px + env(safe-area-inset-top)); }
  .logo { font-size: 20px; }
}
@media (display-mode: standalone) { html, body { height: 100%; } body { position: fixed; inset: 0; } }

/* =================== ВЛОЖЕНИЕ: только картинка, как в Telegram =================== */
.file-chip.media { padding: 8px 12px; }
.file-chip.media .fc-info, .file-chip.media > #fileChipX { display: none; }
.file-chip.media .fc-thumb { width: auto; height: 120px; max-width: min(240px, 70vw); border-radius: 14px; box-shadow: 0 4px 14px rgba(0,0,0,.35); }
.file-chip.media .fc-thumb img, .file-chip.media .fc-thumb video { width: auto; height: 120px; max-width: min(240px, 70vw); }
.fc-x { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 14px; display: flex; align-items: center; justify-content: center; padding: 0; }
.fc-x:hover { background: rgba(0,0,0,.8); }
.file-chip.media .fc-play { width: 36px; height: 36px; }
.file-chip.media .fc-play::after { left: 13px; top: 10px; border-left-width: 13px; border-top-width: 8px; border-bottom-width: 8px; }

/* =================== ПРОСМОТР ТРАНСЛЯЦИИ =================== */
.tile-tools { position: absolute; right: 10px; bottom: 10px; z-index: 6; display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 14px; background: rgba(0,0,0,.55); backdrop-filter: blur(4px); transition: opacity .3s; }
.tile.small .tile-tools { display: none; }
.tv-btn { border: 0; background: none; color: #fff; font-size: 18px; width: 32px; height: 32px; padding: 0; border-radius: 8px; }
.tv-btn:hover { background: rgba(255,255,255,.12); }
.tv-range { width: 110px; accent-color: var(--accent); padding: 0; border: 0; background: none; }
/* кнопки прячутся, если не трогать экран */
.call-view .call-top, .call-view .call-controls { transition: opacity .35s, transform .35s; }
.call-view.idle .call-top { opacity: 0; transform: translateY(-14px); pointer-events: none; }
.call-view.idle .call-controls { opacity: 0; transform: translateY(14px); pointer-events: none; }
.call-view.idle .tile-tools, .call-view.idle .thumbs, .call-view.idle .tile-name { opacity: 0; pointer-events: none; }
.call-view.idle { cursor: none; }
/* телефон боком или полный экран — трансляция на всё окно */
.call-view.land-stream .call-grid, .call-view.fs-stream .call-grid { position: fixed; inset: 0; z-index: 3; padding: 0; }
.call-view.land-stream .tile.big, .call-view.fs-stream .tile.big { inset: 0 !important; border-radius: 0; }
.call-view.land-stream .call-top, .call-view.land-stream .call-controls, .call-view.fs-stream .call-top, .call-view.fs-stream .call-controls { position: relative; z-index: 5; }
.call-view.land-stream .call-controls, .call-view.fs-stream .call-controls { position: fixed; left: 0; right: 0; bottom: 0; background: linear-gradient(transparent, rgba(0,0,0,.7)); padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.call-view.land-stream .call-top, .call-view.fs-stream .call-top { position: fixed; left: 0; right: 0; top: 0; background: linear-gradient(rgba(0,0,0,.7), transparent); }

/* =================== СТРАНИЦА «ZYSMES ДЛЯ ANDROID» =================== */
body.apk-page { overflow-y: auto; display: block; height: auto; min-height: 100%; position: static; }
.apk { max-width: 620px; margin: 0 auto; padding: 28px 18px 40px; display: flex; flex-direction: column; gap: 12px; }
.apk-ico { width: 96px; height: 96px; border-radius: 24px; align-self: center; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.apk h1 { text-align: center; margin: 6px 0 0; font-size: 26px; }
.apk h2 { margin: 18px 0 0; font-size: 18px; color: var(--accent); }
.apk > p { text-align: center; margin: 0; }
.apk-dl { align-self: center; padding: 14px 26px; font-size: 17px; text-decoration: none; border-radius: 14px; margin-top: 6px; }
.apk-none { text-align: center; color: var(--muted); padding: 12px; border: 1px dashed var(--line); border-radius: 12px; }
.apk-steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 10px; line-height: 1.5; }
.apk-steps li::marker { color: var(--accent); font-weight: 800; }
.apk-back { align-self: center; text-decoration: none; margin-top: 10px; }
.auth-apk { display: block; text-align: center; margin-top: 14px; color: var(--muted); font-size: 13px; text-decoration: none; }
.auth-apk:hover { color: var(--accent); }
.scr-audio { display: flex; align-items: center; gap: 10px; align-self: stretch; padding: 10px 12px; border-radius: 12px; background: var(--panel2); cursor: pointer; font-weight: 600; }
.scr-audio input { width: 20px; height: 20px; accent-color: var(--accent); flex: 0 0 auto; }
/* =================== МИНИ-ПЛЕЕР В СТИЛЕ TELEGRAM =================== */
.mini-player {
  position: fixed;
  top: 70px; /* Отступ сверху, чтобы не наезжать на шапку чата */
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 500px;
  background: rgba(29, 33, 44, 0.95); /* Темный фон с прозрачностью */
  backdrop-filter: blur(10px); /* Размытие заднего фона (как в iOS) */
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  z-index: 10030; /* выше развёрнутого кружочка, чтобы медиаплашкой можно было пользоваться */
  animation: slideDown 0.2s ease-out; /* Плавное появление */
}

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

/* ЖЕЛЕЗНОЕ ПРАВИЛО: если есть класс hidden — плеер невидим */
.mini-player.hidden {
  display: none !important;
}

.mp-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mp-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mp-time {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* В Telegram нет волны в мини-плеере, скрываем её */
.mp-wave {
  display: none; 
}

.mp-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.mp-btn {
  border: 0;
  background: none;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.1s;
}

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

/* Кнопка Play/Pause (маленькая) */
.mp-play {
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: #1a1a1a;
  position: relative;
}
.mp-play::before {
  content: "";
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 6px 0 6px 9px;
  border-color: transparent transparent transparent #1a1a1a;
  margin-left: 2px;
}
.mini-player.is-playing .mp-play::before {
  margin-left: 0;
  width: 3px;
  height: 10px;
  border: 0;
  background: #1a1a1a;
  box-shadow: 6px 0 0 #1a1a1a;
  transform: translateX(-3px);
}

/* Кнопка скорости */
.mp-speed {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--muted);
}
.mp-speed.active {
  background: var(--accent);
  color: #1a1a1a;
  border-color: var(--accent);
}

/* Кнопка закрытия */
.mp-close {
  width: 24px;
  height: 24px;
  font-size: 14px;
  color: var(--muted);
}
.mp-close:hover { color: var(--danger); }

/* Прогресс для кружочков (чтобы бегала желтая полоска) */
.round-box .progress-circle {
  fill: none;
  stroke: transparent;
  stroke-width: 4;
  stroke-dasharray: 301.6;
  stroke-dashoffset: 301.6;
  stroke-linecap: round;
  transition: stroke 0.2s;
}
.round-box.is-playing .progress-circle {
  stroke: var(--accent);
  transition: stroke-dashoffset 0.1s linear;
}
/* =================== ФИНАЛЬНАЯ ОПТИМИЗАЦИЯ ДЛЯ СМАРТФОНОВ =================== */
@media (max-width: 760px) {
  body { font-size: 14px; }
  .messages { padding: 8px 6px; gap: 4px; }
  
  .chat-head { padding: 6px 10px; gap: 8px; }
  .chat-head .name { font-size: 15px; }
  .chat-head .muted { font-size: 11px; }
  .chat-head .avatar { width: 34px; height: 34px; flex-basis: 34px; font-size: 14px; }
  .chat-head .head-btn svg { width: 20px; height: 20px; }
  .chat-head-user { gap: 8px; }

  .mini-player {
    top: 56px;
    width: calc(100% - 12px);
    padding: 6px 10px;
    gap: 8px;
    border-radius: 10px;
    background: rgba(22, 25, 34, 0.98);
  }
  .mp-title { font-size: 12px; }
  .mp-time { font-size: 10px; }
  .mp-play { width: 26px; height: 26px; }
  .mp-speed { font-size: 10px; padding: 2px 5px; }
  .mp-close { width: 18px; height: 18px; font-size: 12px; }

  .msg { max-width: 88%; padding: 6px 10px 4px; border-radius: 12px; }
  .msg .text { font-size: 14px; line-height: 1.3; }

  .round-box:not(.is-expanded) { width: 176px; height: 176px; }
  .round-dur { bottom: 8px; font-size: 10px; padding: 1px 5px; }
  .round-snd { right: 16px; bottom: 16px; font-size: 12px; }

  .voice { min-width: 160px; gap: 8px; padding: 2px 0; }
  .vplay { width: 34px; height: 34px; flex-basis: 34px; }
  .vplay::before { border-width: 6px 0 6px 10px; margin-left: 3px; }
  .voice.is-playing .vplay::before { width: 4px; height: 12px; box-shadow: 6px 0 0 #1a1a1a; transform: translateX(-3px); }
  .wave { height: 22px; gap: 1px; }
  .vtime { font-size: 10px; }

  .composer { padding: 6px 8px max(6px, env(safe-area-inset-bottom)); gap: 4px; }
  .composer .icon-btn { height: 38px; width: 38px; font-size: 20px; }
  #textInput { padding: 8px 12px; min-height: 38px; font-size: 15px; border-radius: 18px; }
  .composer .btn.primary { height: 38px; min-width: 38px; }
  .composer .send { font-size: 16px; }
  .composer .mic { padding: 0 12px; }

  .item { padding: 8px 10px; gap: 8px; }
  .item .avatar { width: 38px; height: 38px; flex-basis: 38px; font-size: 15px; }
  .item .name { font-size: 14px; }
  .item .item-last { font-size: 12px; }
  .badge { font-size: 10px; padding: 1px 5px; }
  .folder-tabs { padding: 4px 8px; gap: 4px; }
  .ftab { padding: 4px 10px; font-size: 12px; }

  .modal-win { padding: 20px 16px; border-radius: 16px 16px 0 0; }
  .p-name { font-size: 20px; }
  .btn { padding: 8px 14px; font-size: 13px; }
  
  body, html { overflow-x: hidden; }
}

/* Кружочек при просмотре открывается поверх чата, примерно на половину экрана. */
.round-box {
  position: relative;
  transform-origin: center center;
  transition: width .22s cubic-bezier(.2,.8,.2,1), height .22s cubic-bezier(.2,.8,.2,1), box-shadow .22s ease;
  will-change: width, height;
}
.round-box.is-expanded {
  position: fixed;
  left: 50%; top: 50%;
  width: min(52vw, 58vh, 560px);
  height: min(52vw, 58vh, 560px);
  transform: translate(-50%, -50%);
  z-index: 10020;
  box-shadow: 0 0 0 100vmax rgba(0,0,0,.76), 0 16px 48px rgba(0,0,0,.65);
}
.round-box.is-expanded .round-v { width: 100%; height: 100%; }
@media (max-width: 760px) {
  .round-box.is-expanded {
    width: min(82vw, 62vh, 460px);
    height: min(82vw, 62vh, 460px);
    max-width: calc(100vw - 28px);
    max-height: calc(100dvh - 120px);
  }
}

/* Дополнительная адаптация сенсорных экранов и безопасных зон. */
@media (max-width: 760px) {
  html, body { min-height: 100%; }
  body { min-height: 100dvh; }
  .messages { min-width: 0; padding-left: 8px; padding-right: 8px; }
  .msg { max-width: min(88%, 420px); overflow-wrap: anywhere; }
  .msg.round-msg { max-width: 100%; overflow: visible; }
  .voice { max-width: min(76vw, 340px); min-width: 0; }
  .wave { min-width: 0; flex: 1 1 auto; }
  .composer { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .mini-player { top: calc(56px + env(safe-area-inset-top)); }
  button, .round-box, .vplay, .mp-btn { -webkit-tap-highlight-color: transparent; }
}
@media (max-width: 380px) {
  .round-box:not(.is-expanded) { width: 156px; height: 156px; }
  .voice { max-width: 72vw; gap: 6px; }
  .composer { gap: 3px; }
  .composer .icon-btn { width: 34px; height: 36px; }
}
