/* ============================================================================
   ЧАТ-2 — «ЧАТ С АЙДОЛОМ» КАК ПОЛНОЭКРАННЫЙ МЕССЕНДЖЕР (тест 27.09.2026)
   Включается классом .c2 на #chatOv (флаг CHAT2_USERS / ?lab=chat2 в public/app.js).
   ВСЕ правила ниже — под #chatOv.c2, кроме строки «скрыть новые узлы в старом виде»:
   старый чат этот файл не меняет ни на пиксель.

   Компоновка (решение 27.09): во весь экран, без большой фотографии. Шапка стоит,
   история сжимается, при клавиатуре поднимается только низ. Высоту даёт visualViewport:
   chatVVSync() пишет --vv-h/--vv-gap и класс .kb, как у старого чата (auth-help.css).
   Цвет айдола из idols.json приходит переменной --c2-tint — «это её пространство»:
   кольцо аватара, свечение под шапкой, кнопка голосового.
   ============================================================================ */

/* Новые узлы в старом виде не существуют. */
.chat-back,.c2-stk,.c2-stk-tg{display:none}

/* ---- Каркас: весь экран, низ привязан к видимой области ------------------- */
.ov#chatOv.c2{padding:0 0 var(--vv-gap,0px);align-items:flex-end;justify-content:center;
  background:var(--bg-0);-webkit-backdrop-filter:none;backdrop-filter:none}
.ov#chatOv.c2 #chatBox{width:100%;max-width:none;height:var(--vv-h,100dvh);max-height:none;
  border:0;border-radius:0;box-shadow:none;
  background:
    radial-gradient(120% 38% at 50% 0%,color-mix(in srgb,var(--c2-tint,var(--iris)) 15%,transparent),transparent 70%),
    var(--bg-0)}
#chatOv.c2 .chat-box::before{display:none}
/* На планшете и десктопе — колонка телефона по центру, а не строка во всю ширину монитора. */
@media (min-width:640px){
  .ov#chatOv.c2 #chatBox{max-width:560px;border-left:1px solid var(--line);border-right:1px solid var(--line)}
}

/* ---- Шапка ------------------------------------------------------------------ */
#chatOv.c2 .chat-head{position:relative;z-index:3;flex:none;justify-content:flex-start;gap:4px;
  min-height:56px;padding:5px 12px 5px 4px;padding-top:max(5px,env(safe-area-inset-top,0px));
  background:color-mix(in srgb,var(--bg-1) 90%,transparent);
  -webkit-backdrop-filter:blur(14px);backdrop-filter:blur(14px);
  border-bottom:1px solid var(--line);color:var(--ink)}
#chatOv.c2 .chat-x{display:none}
#chatOv.c2 .chat-back{display:inline-flex;align-items:center;justify-content:center;flex:none;
  width:44px;height:44px;padding:0;border:0;border-radius:50%;background:none;color:var(--ink);cursor:pointer;
  transition:background var(--d-fast,140ms) var(--ease,ease)}
#chatOv.c2 .chat-back:hover{background:var(--iris-soft)}
#chatOv.c2 .chat-ttl{flex:1;min-width:0;flex-direction:row;align-items:center;gap:10px}
.c2-hav-w{position:relative;flex:none;width:40px;height:40px}
.c2-hav{display:block;width:40px;height:40px;border-radius:50%;object-fit:cover;object-position:50% 20%;
  box-shadow:0 0 0 2px var(--bg-1),0 0 0 3.5px var(--c2-tint,var(--iris))}
.c2-dot{position:absolute;right:-2px;bottom:-2px;width:12px;height:12px;border-radius:50%;
  background:var(--good);border:2.5px solid var(--bg-1)}
.c2-htx{display:flex;flex-direction:column;min-width:0;gap:2px}
#chatOv.c2 .chat-ttl-nm{color:var(--ink);font-size:16.5px;font-weight:750;letter-spacing:.01em;line-height:1.15}
#chatOv.c2 .chat-ttl-st{font-size:12.5px;font-weight:500;letter-spacing:0;color:var(--mut);line-height:1.25;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
#chatOv.c2 .chat-ttl-st.typing{color:var(--accent);font-weight:600}
/* Заглушка без портрета: буква на сиреневом, того же размера — вёрстка не прыгает. */
#chatOv.c2 .ph{display:inline-flex;align-items:center;justify-content:center;border-radius:50%;
  background:var(--iris-soft);color:var(--iris);font-weight:800}
#chatOv.c2 .c2-hav.ph{font-size:17px}

/* Полоса «пусть пишет в мессенджер» — в полноэкранном виде тоньше и без обводок-плиток:
   она живёт под шапкой, а не в центре внимания. */
/* 27.09 («любыми способами увеличить окно»): плитки 36 px вместо 44 и поля 3 px — ленте +14 px. */
#chatOv.c2 .chat-relay{flex:none;padding:3px 12px;gap:6px;background:color-mix(in srgb,var(--bg-1) 70%,transparent)}
#chatOv.c2 .chat-relay .cr-b{min-height:36px;padding:2px 10px;border-radius:12px;flex:1 1 90px}
#chatOv.c2 .chat-relay .cr-t small{display:none}
/* Клавиатура открыта — полоса уходит: каждая строка ленты на счету. */
#chatOv.c2.kb .chat-relay{display:none}

/* ---- Лента ------------------------------------------------------------------ */
#chatOv.c2 .chat-log{flex:1;min-height:0;padding:8px 10px 10px;gap:2px;overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch}
/* Короткая переписка прижата к низу, как в любом мессенджере: к полю ввода, а не к шапке. */
#chatOv.c2 .chat-log>:first-child{margin-top:auto}
#chatOv.c2 .chat-msg{align-items:flex-end;gap:6px;min-width:0}
#chatOv.c2 .chat-msg.me{padding-bottom:0;position:static}
#chatOv.c2 .chat-msg.c2-first{margin-top:8px}
#chatOv.c2 .c2-av{flex:none;align-self:flex-start;width:30px;height:30px;border-radius:50%;object-fit:cover;
  object-position:50% 20%;visibility:hidden}
#chatOv.c2 .c2-av.ph{font-size:13px}
#chatOv.c2 .chat-msg.idol.c2-first .c2-av{visibility:visible}

/* Пузыри: скругление 18, у соседних в серии внутренний угол 6 — серия читается одним голосом. */
#chatOv.c2 .chat-b{max-width:min(78%,360px);padding:7px 11px 6px 12px;border-radius:18px;
  font-size:16px;line-height:1.38;white-space:pre-wrap;word-break:break-word}
#chatOv.c2 .chat-msg.me .chat-b{background:var(--accent-fill);color:#fff;border:0}
#chatOv.c2 .chat-msg.idol .chat-b{background:var(--panel2);color:var(--ink);border:0}
#chatOv.c2 .chat-b{position:relative;box-shadow:0 1px 1.5px rgba(0,0,0,.16)}
/* ХВОСТИК у последнего пузыря серии — как в Telegram. Кусок цвета пузыря, из которого
   маской вырезана четверть круга: получается изогнутый «носик» у нижнего угла.
   Без картинок (CSP) и без подложки под цвет фона — работает на любом фоне и в обеих темах. */
#chatOv.c2 .chat-msg.c2-last>.chat-b::after{content:"";position:absolute;bottom:0;width:10px;height:15px;background:inherit;pointer-events:none}
#chatOv.c2 .chat-msg.me.c2-last>.chat-b::after{right:-6px;
  -webkit-mask:radial-gradient(circle at 100% 0,#0000 9.5px,#000 10px);mask:radial-gradient(circle at 100% 0,#0000 9.5px,#000 10px)}
#chatOv.c2 .chat-msg.idol.c2-last>.chat-b::after{left:-6px;
  -webkit-mask:radial-gradient(circle at 0 0,#0000 9.5px,#000 10px);mask:radial-gradient(circle at 0 0,#0000 9.5px,#000 10px)}
#chatOv.c2 .chat-msg.me.c2-last .chat-b{border-bottom-right-radius:0}
#chatOv.c2 .chat-msg.idol.c2-last .chat-b{border-bottom-left-radius:0}
/* Светлая тема: пузырь айдола белый на сером фоне — как у Telegram, без обводки. */
html:not([data-theme="dark"]) #chatOv.c2 .chat-msg.idol .chat-b{background:#fff}
#chatOv.c2 .chat-msg.me:not(.c2-first) .chat-b{border-top-right-radius:6px}
#chatOv.c2 .chat-msg.me:not(.c2-last) .chat-b{border-bottom-right-radius:6px}
#chatOv.c2 .chat-msg.idol:not(.c2-first) .chat-b{border-top-left-radius:6px}
#chatOv.c2 .chat-msg.idol.c2-first .chat-b{border-top-left-radius:4px}
#chatOv.c2 .chat-msg.idol:not(.c2-last) .chat-b{border-bottom-left-radius:6px}

/* Время внутри пузыря справа снизу, галочки у своих: ✓ отправлено, ✓✓ прочитано. */
.c2-tm{float:right;display:inline-flex;align-items:center;gap:3px;margin:8px 0 -4px 10px;
  font-size:11px;line-height:1;white-space:nowrap;font-variant-numeric:tabular-nums;opacity:.7;
  font-style:normal;font-weight:500}
#chatOv.c2 .chat-msg.me .c2-tm{opacity:.85}
#chatOv.c2 .c2-rd,#chatOv.c2 .chat-msg.me .chat-unread{position:static;left:auto;right:auto;bottom:auto;
  font-style:normal;font-size:11px;letter-spacing:-.18em;margin-right:.18em;color:inherit;opacity:1;
  background:none;padding:0;min-width:0;height:auto;border:0}

/* «Печатает…» — круглые точки, как в мессенджерах, и её аватар рядом. */
#chatOv.c2 .chat-typing{padding:12px 14px}
#chatOv.c2 .chat-typing i{border-radius:50%}

/* Разделитель дня — пилюля в потоке. Липкой не делаем: висящая поверх пузыря
   пилюля закрывала текст сообщения (проверено на снимке 27.09). */
.c2-day{display:flex;justify-content:center;margin:12px 0 2px;pointer-events:none}
.c2-day span{padding:4px 11px;border-radius:999px;font-size:12px;font-weight:600;color:var(--mut);
  background:color-mix(in srgb,var(--bg-1) 82%,transparent);border:1px solid var(--line);
  -webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px)}

/* Жалоба на ответ — остаётся (требование магазинов), но тише и с честной зоной нажатия. */
#chatOv.c2 .chat-flag{align-self:center;min-width:32px;min-height:32px;opacity:.22}

/* ---- Стикер: без пузыря, крупно ------------------------------------------- */
.c2-sticker{display:flex;flex-direction:column;align-items:flex-end;gap:2px}
#chatOv.c2 .chat-msg.idol .c2-sticker{align-items:flex-start}
/* Цветной шрифт эмодзи явно: текстовые шрифты (Noto Sans KR и др.) несут монохромные
   контуры части эмодзи, и 😭 в ленте выходил серым контуром (снимок 27.09). */
.c2-sticker-e,.c2-stk-b{font-family:"Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji",sans-serif}
.c2-sticker-e{font-size:60px;line-height:1.08;filter:drop-shadow(0 6px 12px rgba(0,0,0,.22))}
.c2-sticker .c2-tm{float:none;margin:0 2px;padding:3px 7px;border-radius:999px;opacity:1;
  color:var(--mut);background:color-mix(in srgb,var(--bg-1) 80%,transparent)}
/* Стикер Сухёна (수현) (27.09): картинка 256 px в файле, 150 в ленте — чётко на ретине. Тень по
   контуру (drop-shadow, а не box-shadow) — белая вырезка держит края на светлом фоне. */
.c2-sticker-p{display:block;width:150px;height:150px;object-fit:contain;
  -webkit-user-select:none;user-select:none;-webkit-touch-callout:none;
  filter:drop-shadow(0 4px 10px rgba(40,20,70,.18))}
/* В картинке ~15% прозрачного поля снизу — время подтягиваем к самому стикеру. */
.c2-sticker-p+.c2-tm{position:relative;margin-top:-20px}
.chat-stk-old{display:block;width:112px;height:112px;object-fit:contain}
.chat-msg .chat-b:has(>.chat-stk-old),.chat-msg.me .chat-b:has(>.chat-stk-old){background:none;border:0;box-shadow:none;padding:0}
#chatOv.c2 .chat-log>.chat-msg:last-child .c2-sticker-p,
#chatOv.c2 .chat-log>.chat-msg:last-child .c2-sticker-e{animation:c2pop .42s var(--ease,cubic-bezier(.16,1,.3,1)) both}
@keyframes c2pop{0%{transform:scale(.4);opacity:0}60%{transform:scale(1.12);opacity:1}100%{transform:scale(1)}}

/* ---- Голосовое: плеер-пузырь ---------------------------------------------- */
#chatOv.c2 .c2-vb{min-width:min(260px,74vw);max-width:min(84%,360px);padding:9px 12px 7px 9px}
.c2v{--p:0%;display:flex;align-items:center;gap:10px}
.c2v audio{display:none}
.c2v-play{flex:none;display:inline-flex;align-items:center;justify-content:center;width:44px;height:44px;
  padding:0;border:0;border-radius:50%;cursor:pointer;transition:transform 90ms var(--ease,ease);
  background:var(--c2-tint,var(--iris));color:#1A1024;box-shadow:0 2px 8px rgba(0,0,0,.18)}
/* Значок ▶ — треугольник clip-path (не трюк с рамками), пауза — две полосы фоном. */
.c2v-ic{display:block;width:14px;height:16px;margin-left:3px;background:currentColor;
  clip-path:polygon(0 0,100% 50%,0 100%)}
.c2v[data-st="play"] .c2v-ic{width:12px;height:15px;margin:0;clip-path:none;
  background:linear-gradient(90deg,currentColor 0 4px,transparent 4px 8px,currentColor 8px 12px)}
.c2v-body{flex:1;min-width:0;display:flex;flex-direction:column;gap:3px}
/* Волна — зона перемотки: тап или протяжка. pan-y — вертикальная прокрутка ленты
   с пальцем на волне не ломается (браузер забирает жест, перемотки не будет). */
.c2v-wave{position:relative;display:block;height:28px;cursor:pointer;touch-action:pan-y}
.c2v-wave::before{content:"";position:absolute;inset:-8px 0}
.c2v-bars{position:absolute;inset:0;display:flex;align-items:center;gap:2px}
.c2v-bars i{flex:1;min-width:2px;border-radius:2px;background:color-mix(in srgb,var(--ink) 30%,transparent)}
.c2v-fill{clip-path:inset(0 calc(100% - var(--p)) 0 0);will-change:clip-path}
.c2v-fill i{background:var(--accent)}
.c2v-meta{display:flex;align-items:center;gap:8px;min-height:18px}
.c2v-dur{flex:none;font-size:12px;color:var(--mut);font-variant-numeric:tabular-nums}
/* Скорость 1×/1.5×/2× — пилюля появляется, когда голосовое начали слушать (как Telegram).
   Видимая пилюля маленькая, зона нажатия — 44 px за счёт ::before. */
.c2v-sp{position:relative;display:none;align-items:center;height:18px;padding:0 7px;border:0;border-radius:9px;
  font:700 11px/1 var(--f-ui,inherit);font-variant-numeric:tabular-nums;cursor:pointer;
  background:color-mix(in srgb,currentColor 16%,transparent);color:inherit;
  transition:transform 90ms var(--ease,ease)}
.c2v-sp::before{content:"";position:absolute;inset:-13px -8px}
.c2v-sp:active{transform:scale(.88)}
.c2v.used .c2v-sp,.c2v[data-st="play"] .c2v-sp{display:inline-flex}
#chatOv.c2 .c2-vb .vl,#chatOv.c2 .c2-vb .chat-voice-t{margin-top:4px}
/* Пузырь голосового — колонка, float там не работает: время ставим вправо явно. */
#chatOv.c2 .c2-vb>.c2-tm{align-self:flex-end;float:none;margin:2px 0 0}

/* ---- Пустой чат: небольшой портрет над «вот-вот напишет» ------------------ */
.c2-wait-av .c2-wav{display:block;width:76px;height:76px;border-radius:50%;object-fit:cover;object-position:50% 20%;
  box-shadow:0 0 0 3px var(--bg-0),0 0 0 5px var(--c2-tint,var(--iris))}
.c2-wait-av .c2-wav.ph{font-size:30px}

/* ---- Низ: стикеры + поле ---------------------------------------------------- */
#chatOv.c2 .c2-stk{display:flex;flex:none;gap:2px;overflow-x:auto;overflow-y:hidden;overscroll-behavior:contain;
  padding:4px 6px 0;scroll-snap-type:x proximity;scrollbar-width:none;touch-action:pan-x;
  background:var(--bg-1);border-top:1px solid var(--line)}
#chatOv.c2 .c2-stk::-webkit-scrollbar{display:none}
/* Плитка стикера (правка 27.09, ужата вечером того же дня ради ленты): картинка 66 px в
   плитке 72, под ней подпись — крупно хангыль, ниже мелко смысл на языке интерфейса (до двух
   строк, дальше многоточие). Кнопка 78 px — ряд листается ровными шагами. */
.c2-stk-b{flex:none;display:inline-flex;flex-direction:column;align-items:center;gap:0;width:78px;
  padding:0 2px;border:0;border-radius:18px;background:none;color:var(--ink);
  font-size:28px;line-height:1;cursor:pointer;scroll-snap-align:start;
  transition:transform var(--d-fast,140ms) var(--ease,ease)}
.c2-stk-i{display:flex;align-items:center;justify-content:center;width:72px;height:72px;
  border:1px solid var(--line);border-radius:18px;background:var(--panel2);
  transition:border-color var(--d-fast,140ms)}
.c2-stk-b img{display:block;width:66px;height:66px;object-fit:contain;pointer-events:none}
.c2-stk-ko{display:block;max-width:100%;margin-top:2px;font-family:var(--f-ko,"Noto Sans KR"),system-ui,sans-serif;
  font-size:14px;font-weight:700;line-height:1.1;letter-spacing:-.01em;color:var(--ink);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.c2-stk-tr{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;max-width:100%;
  min-height:2.2em;margin-top:1px;font-family:var(--f-ui,inherit);font-size:10.5px;font-weight:500;line-height:1.1;
  color:var(--mut);text-align:center;overflow-wrap:anywhere}
.c2-stk-b:hover .c2-stk-i{border-color:var(--c2-tint,var(--iris))}
.c2-stk-b:focus-visible{outline:none}
.c2-stk-b:focus-visible .c2-stk-i{outline:2px solid var(--accent);outline-offset:2px}
.c2-stk-b:active{transform:scale(.86)}
/* Пока айдол отвечает, стикеры приглушены — отправка всё равно заблокирована (как у кнопки). */
#chatOv.c2 .chat-box:has(#chatSend:disabled) .c2-stk-b{opacity:.45;pointer-events:none}

/* Поле почти вплотную к подписям ряда: 4 px сверху (правка 27.09, было 8 + 4 у ряда). */
#chatOv.c2 .chat-input{flex:none;align-items:center;gap:8px;padding-top:4px;padding-left:10px;padding-right:10px;
  border-top:0;background:var(--bg-1)}
/* Поле — div contenteditable (chat2Field в app.js): над ним iOS не рисует полосу «∧ ∨ ✓».
   Растёт до пяти строк (20 px × 5 + поля), дальше прокрутка внутри. Кнопки по бокам стоят
   у нижнего края растущего поля (align-items:flex-end у ряда). */
#chatOv.c2 .chat-input{align-items:flex-end}
#chatOv.c2 #chatText{flex:1;min-width:0;box-sizing:border-box;min-height:44px;max-height:124px;overflow-y:auto;
  overscroll-behavior:contain;padding:11px 16px;border-radius:22px;background:var(--panel2);border:1px solid var(--line);
  color:var(--ink);font:inherit;font-size:16px;line-height:20px;text-align:left;
  white-space:pre-wrap;overflow-wrap:anywhere;word-break:normal;outline:none;cursor:text;
  -webkit-user-select:text;user-select:text;-webkit-touch-callout:default;
  box-shadow:inset 0 1px 3px rgba(23,32,56,.07)}
html[data-theme="dark"] #chatOv.c2 #chatText{box-shadow:inset 0 2px 4px rgba(0,0,0,.35)}
#chatOv.c2 #chatText:focus{border-color:var(--c2-tint,var(--accent2))}
#chatOv.c2 #chatText.is-empty::before{content:attr(data-ph);color:var(--dim);pointer-events:none}
#chatOv.c2 #chatSend{flex:none;width:44px;height:44px;min-width:44px;padding:0;border-radius:50%;font-size:20px;line-height:1}

/* Клавиатура открыта: ряд стикеров сворачивается в одну кнопку слева от поля,
   чтобы не съедать и без того короткую ленту. Тап по ней — ряд раскрывается над полем. */
#chatOv.c2.kb:not(.stk-open) .c2-stk{display:none}
#chatOv.c2.kb:not(.stk-open) .chat-input{border-top:1px solid var(--line);padding-top:6px}
/* Поле вплотную к клавиатуре (27.09): при открытой клавиатуре снизу только 6 px — полоску
   жеста закрывает сама клавиатура. Системную полосу iOS «∧ ∨ ✓» над клавишами сайт убрать не
   может, свою щель поверх неё не добавляем. Перебивает .ov#chatOv.kb из auth-help.css (12 px).
   Клавиатура закрыта — safe-area и запас остаются (auth-help.css), в браузере чуть меньше. */
.ov#chatOv.c2.kb #chatBox .chat-input{padding-bottom:6px}
@media(max-width:560px){
  .ov#chatOv.c2:not(.kb) #chatBox .chat-input{padding-bottom:max(14px,calc(8px + env(safe-area-inset-bottom,0px)))}
}
@media(max-width:560px) and (display-mode:standalone){
  .ov#chatOv.c2:not(.kb) #chatBox .chat-input{padding-bottom:max(30px,calc(8px + env(safe-area-inset-bottom,0px)))}
}
#chatOv.c2.kb .c2-stk-tg{display:inline-flex}
.c2-stk-tg{flex:none;align-items:center;justify-content:center;width:44px;height:44px;padding:0;
  border:0;border-radius:50%;background:none;color:var(--mut);font-size:24px;line-height:1;cursor:pointer}
.c2-stk-tg img{display:block;width:30px;height:30px;object-fit:contain;pointer-events:none;opacity:.85;filter:grayscale(.35)}
#chatOv.c2.stk-open .c2-stk-tg{color:var(--accent)}
#chatOv.c2.stk-open .c2-stk-tg img{opacity:1;filter:none}

@media (prefers-reduced-motion:reduce){
  #chatOv.c2 .chat-log>.chat-msg:last-child .c2-sticker-e,
  #chatOv.c2 .chat-log>.chat-msg:last-child .c2-sticker-p{animation:none}
  .c2-stk-b{transition:none}
}

/* ============================================================================
   ПЛАВНОСТЬ УРОВНЯ МЕССЕНДЖЕРА (27.09, эталон — Telegram iOS)
   Всё движение — только transform/opacity (композитор, без перерасчёта раскладки).
   ============================================================================ */
/* Экран чата въезжает справа и уезжает вправо, как экран iOS. Подложка прозрачная —
   под уезжающим чатом виден кабинет, а не чёрная вспышка. */
.ov#chatOv.c2{background:transparent}
@media (min-width:640px){.ov#chatOv.c2{background:var(--bg-0)}}
#chatOv.c2.show #chatBox{animation:c2push .28s cubic-bezier(.2,.8,.2,1) both}
#chatOv.c2.c2-out #chatBox{animation:c2pop-out .2s cubic-bezier(.4,0,1,1) both}
@keyframes c2push{from{transform:translate3d(100%,0,0)}to{transform:none}}
@keyframes c2pop-out{from{transform:none}to{transform:translate3d(100%,0,0)}}
#chatOv.c2 #chatBox{position:relative;will-change:transform}
/* ЧАТ — ОТДЕЛЬНЫЙ ЭКРАН (27.09). Въезд кончился (.c2-still ставит app.js через 300 мс) —
   подложка непрозрачная на всю высоту: и полоса под клавиатурой (--vv-gap), и safe-area
   больше не показывают гримёрку. Прокрутка любого места чата не уходит на страницу. */
.ov#chatOv.c2.c2-still{background:var(--bg-0)}
.ov#chatOv{overscroll-behavior:contain}
#chatOv.c2 .chat-head,#chatOv.c2 .chat-input,#chatOv.c2 .chat-relay{overscroll-behavior:contain}
/* Замок страницы под открытым чатом (любой вид чата): body закреплён на месте прокрутки,
   документу прокручивать нечего. Позицию пишет и возвращает chatPageLock() в app.js. */
html.chat-lock{overflow:hidden;overscroll-behavior:none}
html.chat-lock body{position:fixed;top:var(--chat-lock-y,0);left:0;right:0;width:100%;overflow:hidden;overscroll-behavior:none}

/* Новое сообщение — подъезжает на 10 px и проявляется за 180 мс. */
#chatOv.c2 .chat-msg.c2-in{animation:c2msg .18s cubic-bezier(.2,.8,.2,1) both}
#chatOv.c2 .chat-msg.me.c2-in{transform-origin:100% 100%}
#chatOv.c2 .chat-msg.idol.c2-in{transform-origin:0 100%}
@keyframes c2msg{from{opacity:0;transform:translate3d(0,10px,0) scale(.96)}to{opacity:1;transform:none}}

/* «Печатает…» — три точки волной, по очереди, как в iMessage/Telegram. */
#chatOv.c2 .chat-typing{gap:4px;padding:13px 14px}
#chatOv.c2 .chat-typing i{width:7px;height:7px;background:var(--mut);animation:c2dot 1.2s infinite cubic-bezier(.45,0,.55,1)}
#chatOv.c2 .chat-typing i:nth-child(2){animation-delay:.15s}
#chatOv.c2 .chat-typing i:nth-child(3){animation-delay:.3s}
@keyframes c2dot{0%,60%,100%{transform:translate3d(0,0,0);opacity:.35}30%{transform:translate3d(0,-4px,0);opacity:1}}
#chatOv.c2 .chat-ttl-st{transition:color var(--d-fast,140ms) var(--ease,ease)}

/* Мгновенный отклик на касание: всё нажимаемое чуть «вдавливается» сразу на pointerdown. */
#chatOv.c2 button{-webkit-tap-highlight-color:transparent;touch-action:manipulation}
#chatOv.c2 .chat-back:active,#chatOv.c2 .c2-stk-tg:active{transform:scale(.88);background:var(--iris-soft)}
#chatOv.c2 .chat-back,#chatOv.c2 .c2-stk-tg{transition:transform 90ms var(--ease,ease),background var(--d-fast,140ms)}
#chatOv.c2 #chatSend{transition:transform 90ms var(--ease,ease),opacity var(--d-fast,140ms)}
#chatOv.c2 #chatSend:active{transform:scale(.88)}
#chatOv.c2 .c2v-play:active{transform:scale(.9)}

/* Скелет первого открытия: пузыри-заглушки вместо слова «загрузка». */
#chatOv.c2 .c2-skel{display:flex;flex-direction:column;gap:8px;margin:auto 0 0;padding:8px 0;width:100%}
#chatOv.c2 .c2-skel i{display:block;height:38px;border-radius:18px;background:var(--panel2);opacity:.55;
  animation:c2skel 1.3s ease-in-out infinite}
#chatOv.c2 .c2-skel i.r{align-self:flex-end;background:color-mix(in srgb,var(--accent-fill) 55%,var(--panel2))}
#chatOv.c2 .c2-skel i:nth-child(2n){animation-delay:.15s}
@keyframes c2skel{0%,100%{opacity:.35}50%{opacity:.7}}

/* Кнопка «вниз» со счётчиком новых. */
.c2-down{display:none}
#chatOv.c2 .c2-down{position:absolute;right:12px;bottom:140px;z-index:4;display:inline-flex;align-items:center;justify-content:center;
  width:44px;height:44px;padding:0;border:1px solid var(--line);border-radius:50%;cursor:pointer;
  background:color-mix(in srgb,var(--bg-1) 92%,transparent);color:var(--ink);box-shadow:0 4px 14px rgba(0,0,0,.28);
  -webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);
  opacity:0;transform:translate3d(0,12px,0) scale(.8);pointer-events:none;
  transition:opacity .16s var(--ease,ease),transform .2s var(--ease,ease)}
#chatOv.c2 .c2-down.show{opacity:1;transform:none;pointer-events:auto}
#chatOv.c2.rec .c2-down{opacity:0;pointer-events:none}
#chatOv.c2 .c2-down:active{transform:scale(.9)}
#chatOv.c2 .c2-down b{position:absolute;top:-6px;left:50%;transform:translateX(-50%);min-width:20px;height:20px;padding:0 6px;
  border-radius:10px;background:var(--accent-fill);color:#fff;font-size:11.5px;font-weight:700;line-height:20px;text-align:center}
#chatOv.c2 .c2-down b:empty{display:none}
#chatOv.c2 .chat-input{position:relative}

@media (prefers-reduced-motion:reduce){
  #chatOv.c2.show #chatBox,#chatOv.c2.c2-out #chatBox,#chatOv.c2 .chat-msg.c2-in,#chatOv.c2 .c2-skel i{animation:none}
  #chatOv.c2 .chat-typing i{animation:none;opacity:.6}
  #chatOv.c2 .c2-down{transition:none}
}

/* ============================================================================
   ГОЛОСОВОЕ ФАНАТА (27.09): жесты Telegram — удержание, влево отмена, вверх замок
   Видно только при флаге micOn() (класс .mic на #chatOv, см. public/app.js).
   Состояния — классы на .chat-input (не на всём окне: перерасчёт стилей — только низа):
     .rec  — идёт запись (палец держит)    .rlock — запись на замке, без пальца
     .rprev — остановлено, предпрослушка    .has-txt — в поле текст: вместо 🎤 стрелка
   ============================================================================ */
.c2-mic,.c2-rec,.c2-mic-w,.c2-tip{display:none}
#chatOv.c2.mic .c2-mic-w{position:relative;display:inline-flex;flex:none;width:48px;height:48px}
#chatOv.c2.mic .c2-mic{position:relative;z-index:2;display:inline-flex;align-items:center;justify-content:center;
  width:48px;height:48px;min-width:48px;padding:0;border:0;border-radius:50%;cursor:pointer;
  background:color-mix(in srgb,var(--c2-tint,var(--iris)) 62%,#fff);color:#1A1024;box-shadow:0 2px 8px rgba(0,0,0,.18);
  touch-action:none;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;
  transition:transform .16s cubic-bezier(.2,.8,.2,1),background-color .12s}
#chatOv.c2.mic .c2-mic:active{transform:scale(.9)}
#chatOv.c2.mic .c2-mic:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
#chatOv.c2.mic .chat-box:has(#chatSend:disabled) .c2-mic{opacity:.45;pointer-events:none}
/* Поле пустое — 🎤, набран текст — стрелка (одна кнопка, как в Telegram). */
#chatOv.c2.mic .chat-input:not(.has-txt) #chatSend{display:none}
#chatOv.c2.mic .chat-input.has-txt .c2-mic-w{display:none}
#chatOv.c2.mic .chat-input.has-txt #chatSend{animation:c2swap .16s cubic-bezier(.2,.8,.2,1)}
#chatOv.c2.mic .chat-input:not(.has-txt) .c2-mic{animation:c2swap .16s cubic-bezier(.2,.8,.2,1)}
@keyframes c2swap{from{transform:scale(.6);opacity:0}to{transform:none;opacity:1}}

/* Ореол уровня голоса за кнопкой: масштаб — громкость, 60 кадров из requestAnimationFrame. */
.c2-mic-halo{position:absolute;inset:0;z-index:1;border-radius:50%;pointer-events:none;
  background:color-mix(in srgb,var(--bad,#E5484D) 30%,transparent);opacity:0;will-change:transform}
/* Идёт запись: поле уступает место полосе, кнопка растёт и краснеет. */
#chatOv.c2.mic .chat-input.rec #chatText,#chatOv.c2.mic .chat-input.rec .c2-stk-tg,
#chatOv.c2.mic .chat-input.rprev #chatText,#chatOv.c2.mic .chat-input.rprev .c2-stk-tg{display:none}
#chatOv.c2.mic .chat-input.rec #chatSend,#chatOv.c2.mic .chat-input.rprev #chatSend{display:none}
#chatOv.c2.mic .chat-input.rec .c2-mic-w,#chatOv.c2.mic .chat-input.rprev .c2-mic-w{display:inline-flex}
#chatOv.c2.mic .chat-input.rec .c2-mic{transform:scale(1.45);background:var(--bad,#E5484D);color:#fff;animation:none;
  box-shadow:0 4px 16px color-mix(in srgb,var(--bad,#E5484D) 45%,transparent)}
#chatOv.c2.mic .chat-input.rec .c2-mic-halo{opacity:1;transform:scale(1)}
#chatOv.c2.mic .chat-input.rec .c2-rec,#chatOv.c2.mic .chat-input.rprev .c2-rec{display:flex;flex:1;min-width:0;min-height:48px;align-items:center;gap:6px;
  padding:0 8px 0 12px;border-radius:24px;background:var(--panel2);animation:c2recin .14s ease-out}
@keyframes c2recin{from{opacity:0;transform:translate3d(16px,0,0)}to{opacity:1;transform:none}}
.c2-rec-live{display:flex;align-items:center;gap:8px;flex:1;min-width:0}
.c2-rec-dot{flex:none;width:9px;height:9px;border-radius:50%;background:var(--bad,#E5484D);animation:c2blink 1s steps(1,end) infinite}
@keyframes c2blink{50%{opacity:.25}}
.c2-rec-t{flex:none;min-width:54px;font-size:15px;font-weight:600;font-variant-numeric:tabular-nums;color:var(--ink)}
/* Живая волна — canvas: 40 столбиков за кадр дешевле, чем 40 узлов DOM. Цвет — currentColor. */
.c2-rec-wave{display:none;flex:1;min-width:0;height:26px;color:var(--c2-tint,var(--accent))}
/* Держишь — «‹ смахни — отмена» по центру (волну заменяет ореол у кнопки, как в Telegram);
   на замке палец свободен — вместо подсказки бежит волна. */
#chatOv.c2.mic .chat-input.rlock .c2-rec-wave{display:block}
.c2-rec-sw{flex:1;min-width:0;display:inline-flex;align-items:center;justify-content:center;gap:4px;padding-right:34px;
  font-size:14px;color:var(--mut);white-space:nowrap;overflow:hidden;pointer-events:none;will-change:transform,opacity}
.c2-rec-sw i{font-style:normal;font-size:18px;line-height:1;animation:c2nudge 1.4s ease-in-out infinite}
@keyframes c2nudge{0%,100%{transform:none}50%{transform:translate3d(-4px,0,0)}}
.c2-rec-prev{display:none}
/* Замок над кнопкой: тянешь вверх — едет вместе с пальцем. */
.c2-lock{position:absolute;left:50%;bottom:calc(100% + 26px);z-index:3;display:none;flex-direction:column;align-items:center;gap:2px;
  width:38px;margin-left:-19px;padding:9px 0 8px;border-radius:19px;
  background:color-mix(in srgb,var(--bg-1) 94%,transparent);border:1px solid var(--line);color:var(--mut);
  box-shadow:0 4px 14px rgba(0,0,0,.28);will-change:transform,opacity}
.c2-lock-up{width:8px;height:8px;border-left:2px solid currentColor;border-top:2px solid currentColor;transform:rotate(45deg);margin-top:4px;
  animation:c2up 1.2s ease-in-out infinite}
@keyframes c2up{0%,100%{transform:rotate(45deg) translate(0,0)}50%{transform:rotate(45deg) translate(-3px,-3px)}}
#chatOv.c2.mic .chat-input.rec:not(.rlock) .c2-lock{display:flex;animation:c2lockin .2s cubic-bezier(.2,.8,.2,1)}
@keyframes c2lockin{from{opacity:0;transform:translate3d(0,14px,0)}to{opacity:1;transform:none}}
/* Кнопки замка/предпрослушки. */
.c2-rec-del,.c2-rec-stop,.c2-rec-send{display:none}
#chatOv.c2.mic .c2-rec-del{flex:none;align-items:center;justify-content:center;width:40px;height:40px;margin-left:-6px;padding:0;border:0;border-radius:50%;
  background:none;color:var(--mut);cursor:pointer;transition:transform 90ms var(--ease,ease),color .12s}
#chatOv.c2.mic .c2-rec-del:active{transform:scale(.86);color:var(--bad,#E5484D)}
#chatOv.c2.mic .chat-input.rlock .c2-rec-del,#chatOv.c2.mic .chat-input.rprev .c2-rec-del{display:inline-flex}
#chatOv.c2.mic .chat-input.rlock .c2-rec-sw{display:none}
#chatOv.c2.mic .c2-rec-send{position:absolute;inset:0;z-index:2;align-items:center;justify-content:center;width:48px;height:48px;padding:0;border:0;border-radius:50%;
  background:var(--accent-fill);color:#fff;cursor:pointer;box-shadow:0 2px 10px rgba(0,0,0,.25);transition:transform 90ms var(--ease,ease)}
#chatOv.c2.mic .c2-rec-send:active{transform:scale(.88)}
#chatOv.c2.mic .chat-input.rlock .c2-mic,#chatOv.c2.mic .chat-input.rprev .c2-mic,
#chatOv.c2.mic .chat-input.rprev .c2-mic-halo{display:none}
#chatOv.c2.mic .chat-input.rlock .c2-rec-send,#chatOv.c2.mic .chat-input.rprev .c2-rec-send{display:inline-flex;animation:c2swap .16s cubic-bezier(.2,.8,.2,1)}
#chatOv.c2.mic .chat-input.rlock .c2-mic-halo{opacity:.8}
#chatOv.c2.mic .c2-rec-stop{position:absolute;left:50%;bottom:calc(100% + 14px);z-index:3;align-items:center;justify-content:center;
  width:44px;height:44px;margin-left:-22px;padding:0;border:1px solid var(--line);border-radius:50%;cursor:pointer;
  background:color-mix(in srgb,var(--bg-1) 94%,transparent);color:var(--bad,#E5484D);box-shadow:0 4px 14px rgba(0,0,0,.28);
  transition:transform 90ms var(--ease,ease)}
#chatOv.c2.mic .c2-rec-stop i{width:13px;height:13px;border-radius:3px;background:currentColor}
#chatOv.c2.mic .c2-rec-stop:active{transform:scale(.88)}
#chatOv.c2.mic .chat-input.rlock .c2-rec-stop{display:inline-flex;animation:c2lockin .2s cubic-bezier(.2,.8,.2,1)}
/* Предпрослушка: живая полоса уступает место плееру. */
#chatOv.c2.mic .chat-input.rprev .c2-rec-live{display:none}
#chatOv.c2.mic .chat-input.rprev .c2-rec-prev{display:flex;flex:1;min-width:0}
#chatOv.c2.mic .c2-rec-prev .c2v{flex:1;min-width:0;gap:8px}
#chatOv.c2.mic .c2-rec-prev .c2v-play{width:36px;height:36px}
#chatOv.c2.mic .c2-rec-prev .c2v-meta{display:none}
#chatOv.c2.mic .c2-rec-prev .c2v-wave{height:24px}
/* Подсказка на короткий тап: «удерживай» — всплывает над кнопкой и гаснет сама. */
#chatOv.c2.mic .c2-tip{position:absolute;right:10px;bottom:calc(100% + 8px);z-index:5;display:flex;flex-direction:column;gap:2px;
  max-width:min(300px,calc(100% - 20px));padding:9px 12px;border-radius:14px;
  background:color-mix(in srgb,var(--bg-4) 96%,transparent);color:var(--ink);box-shadow:0 6px 20px rgba(0,0,0,.35);
  font-size:13.5px;line-height:1.3;pointer-events:none;opacity:0;transform:translate3d(0,6px,0);
  transition:opacity .16s var(--ease,ease),transform .2s var(--ease,ease)}
#chatOv.c2.mic .c2-tip b{font-weight:650}
#chatOv.c2.mic .c2-tip span{font-size:12px;color:var(--mut)}
#chatOv.c2.mic .c2-tip.show{opacity:1;transform:none}
/* Свой пузырь-плеер: на заливке акцента кнопка и волна — белые. */
#chatOv.c2 .chat-msg.me .c2v-play{background:rgba(255,255,255,.92);color:var(--accent-fill,#7B3FE4)}
#chatOv.c2 .chat-msg.me .c2v-bars i{background:rgba(255,255,255,.45)}
#chatOv.c2 .chat-msg.me .c2v-fill i{background:#fff}
#chatOv.c2 .chat-msg.me .c2v-dur{color:rgba(255,255,255,.85)}
.c2-heard{margin-top:5px;font-size:12.5px;line-height:1.3;opacity:.9;white-space:normal}
.c2-heard.wait{font-style:italic;opacity:.7}
.c2-heard.c2-herr{display:flex;align-items:center;flex-wrap:wrap;gap:6px;opacity:1;font-weight:600;color:inherit}
/* Статус отправки: часики (идёт) → ✓✓ (дошло и прочитано) → «!» (сбой). */
#chatOv.c2 .c2-rd.c2-clock{position:relative;display:inline-block;width:11px;height:11px;margin:0 0 0 1px;
  border:1.4px solid currentColor;border-radius:50%;letter-spacing:0;opacity:.9}
#chatOv.c2 .c2-rd.c2-clock::before,#chatOv.c2 .c2-rd.c2-clock::after{content:"";position:absolute;left:50%;top:50%;
  width:1.4px;margin-left:-.7px;background:currentColor;border-radius:1px;transform-origin:50% 0}
#chatOv.c2 .c2-rd.c2-clock::before{height:3.4px;animation:c2clock 1.6s linear infinite}
#chatOv.c2 .c2-rd.c2-clock::after{height:2.4px;animation:c2clock 9.6s linear infinite}
@keyframes c2clock{from{transform:rotate(180deg)}to{transform:rotate(540deg)}}
#chatOv.c2 .c2-rd.c2-err{display:inline-flex;align-items:center;justify-content:center;width:14px;height:14px;border-radius:50%;
  background:#fff;color:var(--bad,#E5484D);font-weight:800;font-size:10px;letter-spacing:0}
.c2-retry{margin-left:4px;padding:3px 10px;min-height:28px;border:0;border-radius:14px;background:rgba(255,255,255,.95);
  color:var(--accent-fill,#7B3FE4);font:700 12.5px/1 var(--f-ui,inherit);cursor:pointer;position:relative}
.c2-retry::before{content:"";position:absolute;inset:-8px -4px}
.c2-retry:active{transform:scale(.92)}
@media (prefers-reduced-motion:reduce){
  #chatOv.c2.mic .c2-mic,.c2-rec-sw i,.c2-lock-up,.c2-rec-dot,#chatOv.c2 .c2-rd.c2-clock::before,#chatOv.c2 .c2-rd.c2-clock::after{animation:none;transition:none}
  #chatOv.c2.mic .c2-tip{transition:none}
}
/* КОМПАКТНО ПРИ КЛАВИАТУРЕ (27.09, Сармат: «увеличить окно истории»). Полосу iOS
   «∧ ∨ ✓» сайт убрать не может, поэтому место забираем у шапки: фото 28 px, только
   имя, без статуса и лишних полей; кнопка стикеров уже — полю ввода больше ширины. */
#chatOv.c2.kb .chat-head{min-height:40px;padding-top:max(2px,env(safe-area-inset-top,0px));padding-bottom:2px}
#chatOv.c2.kb .chat-back{width:36px;height:36px}
#chatOv.c2.kb .c2-hav-w,#chatOv.c2.kb .c2-hav{width:28px;height:28px}
#chatOv.c2.kb .c2-dot{width:9px;height:9px;border-width:2px}
#chatOv.c2.kb .chat-ttl{gap:8px}
#chatOv.c2.kb .chat-ttl-st{display:none}
#chatOv.c2.kb .chat-ttl-nm{font-size:15px}
#chatOv.c2.kb .c2-stk-tg{width:34px;height:34px}
#chatOv.c2.kb .c2-stk-tg img{width:26px;height:26px}
/* Метка «한» на микрофоне: голосовые только на корейском (правка 28.09). Прячется во время записи. */
.c2-mic-ko{display:none}
#chatOv.c2.mic .c2-mic-ko{display:flex;position:absolute;z-index:3;right:-2px;top:-2px;min-width:18px;height:18px;padding:0 3px;
  align-items:center;justify-content:center;border-radius:9px;background:var(--accent);color:#fff;
  font:700 10px/1 system-ui,sans-serif;pointer-events:none;box-shadow:0 0 0 2px var(--bg,#fff)}
#chatOv.c2.mic.rec .c2-mic-ko,#chatOv.c2.mic .c2-mic-w.rec .c2-mic-ko{display:none}
/* «Удалить» под своим сообщением (правка 28.09): тап по своему пузырю. */
#chatLog .chat-msg.me{flex-wrap:wrap}
#chatLog .c2-del{flex-basis:100%;margin:4px 0 0 auto;max-width:max-content;padding:6px 12px;border:0;border-radius:14px;
  background:#e5484d;color:#fff;font:600 13px/1 system-ui,sans-serif;cursor:pointer}
#chatLog .chat-msg.c2-deleting{opacity:.4;pointer-events:none}
/* ЧАТ КАК МЕССЕНДЖЕР (05.10): сообщение не ушло — под пузырём «Не отправлено · Повторить»,
   набранное остаётся в ленте; ответ айдола не пришёл — строка сбоя с той же кнопкой.
   Без .c2: работает и в старом виде чата. Кнопка на заливке акцента — видна в обеих темах. */
#chatLog .c2-unsent{flex-basis:100%;display:flex;align-items:center;justify-content:flex-end;gap:6px;margin:4px 0 0 auto;
  font:600 12.5px/1.2 var(--f-ui,system-ui,sans-serif);color:var(--bad,#E5484D)}
#chatLog .c2-unsent .c2-retry,#chatLog .chat-rerr .c2-retry{margin:0;background:var(--accent-fill,#7B3FE4);color:#fff}
#chatLog .chat-rerr{display:flex;align-items:center;justify-content:center;flex-wrap:wrap;gap:8px;margin:6px auto 4px;padding:8px 12px}
#chatOv.c2 .chat-msg.me.c2-fail .chat-b{opacity:.75}
