#chat-app[hidden],body.locked #chat-app{display:none!important}
#chat-app{position:absolute;inset:84px 20px 18px 20px;min-width:0;display:grid;grid-template-columns:210px minmax(0,1fr);grid-template-rows:52px minmax(0,1fr);gap:16px;max-width:1442px;margin:0 auto}
#chat-app .chat-switch-slot{grid-column:1;grid-row:1;position:relative}
#chat-app .chat-list-panel{grid-column:1;grid-row:2;min-width:0;min-height:0;overflow:auto;padding:18px 12px;background:#ffffffdf;border-radius:26px}
#chat-app .chat-list-header{display:flex;align-items:center;justify-content:space-between;padding:0 6px 12px 12px;gap:12px}
#chat-app .chat-list-header h1{font-size:19px;font-weight:600;line-height:1.2;margin:0;color:#242429}
#chat-app #chat-list{display:flex;flex-direction:column}
#chat-app .press-key{display:inline-flex;align-items:center;justify-content:center;gap:9px;min-height:42px;padding:0 16px;color:#242429;border:1px solid #e7e7ec;border-radius:999px;background:linear-gradient(#fff,#f5f5fa);box-shadow:0 1px 0 #f1f1f6,inset 0 1px 0 #fff;transition:transform .07s ease,box-shadow .07s ease,background .15s ease;cursor:pointer}
@media(hover:hover){#chat-app .press-key:hover{background:linear-gradient(#fff,#f0f0f5)}}
#chat-app .press-key:active,#chat-app .press-key.active,#chat-app .press-key[aria-expanded=true]{transform:translateY(1px);background:linear-gradient(#f0f0f5,#f5f5fa);box-shadow:0 0 0 #e4e4e9,inset 0 1px 3px #e1e1e6}
#chat-app .press-key:disabled{opacity:.45;cursor:default}
#chat-app .round-key{flex:none;width:42px;height:42px;padding:0}
#chat-app .round-key svg{width:19px;height:19px;color:#242429}
#chat-app .chat-list-key{width:100%;display:flex;text-align:left}
#chat-app .chat-list-key strong{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:14px}
#chat-app .chat-list-key span{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;color:#8d8d92}
#chat-app .chat-top-strip{grid-column:2;grid-row:1;display:flex;align-items:center;gap:10px;min-width:0;padding:0 10px;position:relative;background:#ffffffdf;border-radius:26px}
#chat-app #chat-back{display:none}
#chat-app .chat-title-button{position:absolute;left:50%;transform:translateX(-50%);max-width:calc(100% - 240px);min-height:40px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:18px;font-weight:600}
#chat-app .chat-title-button:active,#chat-app .chat-title-button[aria-expanded=true]{transform:translate(-50%,1px)}
#chat-app .chat-title-button:disabled{cursor:default}
#chat-app #chat-settings{margin-left:auto}
#chat-app #user-button{flex:none;margin-left:0}
#chat-app .chat-content{grid-column:2;grid-row:2;position:relative;inset:auto;display:block;width:auto;max-width:none;height:auto;margin:0;padding:0;align-self:stretch;justify-self:stretch;min-width:0;min-height:0;overflow:hidden;border:0;border-radius:26px;background:#f9f9fe}
#chat-app .chat-photo,#chat-app .chat-tints{position:absolute;inset:-45px;pointer-events:none}
#chat-app .chat-photo{background-position:center;background-size:cover}
/* Фон-фотография: как есть или размытая (по выбору), затемнение — слоем поверх. */
#chat-app[data-wall] .chat-photo::after{content:'';position:absolute;inset:0;background:rgb(0 0 0/var(--chat-dim,0))}
#chat-app[data-wall] .chat-tints{display:none}
#chat-app .chat-tints{background:radial-gradient(ellipse at 10% 12%,rgb(var(--chat-tone-1,255 255 255)/.36),transparent 50%),radial-gradient(ellipse at 85% 15%,rgb(var(--chat-tone-2,255 255 255)/.42),transparent 48%),radial-gradient(ellipse at 20% 90%,rgb(var(--chat-tone-3,255 255 255)/.4),transparent 52%),radial-gradient(ellipse at 90% 85%,rgb(var(--chat-tone-4,255 255 255)/.38),transparent 45%)}
#chat-app .chat-content-inner{position:relative;z-index:1;width:100%;height:100%;min-height:0;display:flex;flex-direction:column}
#chat-app .chat-messages{flex:1;min-height:0;overflow:auto;display:flex;flex-direction:column;scrollbar-color:#d2d2d7 transparent}
#chat-app .chat-empty{margin:auto;color:#8c8c91;text-align:center;font-size:14px}
#chat-app .chat-message{display:flex;flex-direction:column;align-items:flex-start;gap:4px}
#chat-app .chat-message.own{align-self:flex-end;align-items:flex-end}
#chat-app .chat-message strong{padding:0 9px;font-size:12px;font-weight:600;color:#69696e}
#chat-app .chat-bubble{display:flow-root;max-width:100%;border:1px solid #e8e8ed;background:#fffffff0;box-shadow:0 1px 0 #37373c12,inset 0 1px 0 #fff;color:#242429;text-align:left;white-space:pre-wrap;overflow-wrap:anywhere;cursor:pointer;transition:transform .08s ease,box-shadow .08s ease}
#chat-app .chat-bubble:active,#chat-app .chat-bubble[aria-expanded=true]{transform:translateY(1px);box-shadow:inset 0 2px 5px #37373c1c}
#chat-app .chat-message.own .chat-bubble{border-radius:17px 17px 5px 17px;background:#efeff4ed;border-color:#e4e4e9}
#chat-app .chat-message time{color:#8c8c91;font-size:11px}
#chat-app .chat-message-text{display:inline}
#chat-app .chat-forwarded{display:block;margin-bottom:6px;color:#7d7d82}
#chat-app .chat-quote{margin-bottom:6px;color:#69696e;text-overflow:ellipsis}
#chat-app .chat-meta{float:right;display:inline-flex;align-items:center;margin-left:12px;line-height:1;white-space:nowrap;vertical-align:baseline}
#chat-app .chat-meta time{padding:0}
#chat-app .chat-read-status{display:inline-flex;align-items:center;padding:0}
#chat-app .chat-read-status svg{flex:none;fill:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round}
#chat-app .chat-edited{padding:0 3px}
#chat-app .chat-pinned[hidden],#chat-app .chat-reply-bar[hidden]{display:none}
#chat-app .chat-pinned{flex:none;display:flex;justify-content:flex-start;min-height:44px;margin:12px 18px 0;max-width:calc(100% - 36px);gap:9px;border-radius:16px;text-align:left}
#chat-app .chat-pinned strong{flex:none;font-size:12px}
#chat-app .chat-pinned span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px}
#chat-app .chat-reply-bar{display:flex;align-items:center;gap:8px;margin:0 18px;padding:8px 10px 8px 16px;background:#ffffffd9;border:1px solid #e7e7ec;border-radius:18px}
#chat-app .chat-reply-bar span{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#69696e;font-size:12px}
#chat-app .chat-reply-bar .round-key{width:32px;height:32px;min-height:32px}
#chat-app .chat-composer{display:flex;gap:8px;padding:13px 18px}
#chat-app .chat-composer[hidden]{display:none}
#chat-app .pill-input{min-width:0;border:1px solid #e7e7ec;border-radius:999px;background:#fff;color:#242429;text-align:center;box-shadow:inset 0 1px 2px #f0f0f5;outline:none;font:inherit}#chat-app .chat-composer .chat-tool{width:40px;height:40px;min-height:40px;padding:0}
#chat-app .chat-composer .chat-tool svg{width:20px;height:20px}
#chat-app .chat-input-wrap{display:flex;flex:1;gap:4px;min-width:0;min-height:44px;padding:2px 3px 2px 12px;border:1px solid #e7e7ec;border-radius:999px;background:#fff;box-shadow:inset 0 1px 2px #f0f0f5}#chat-app #chat-message{flex:1;min-width:0;height:38px;padding:0;border:0;background:transparent;color:#242429;outline:0;font:inherit}
#chat-app #chat-message::placeholder{color:#909095}
#chat-app .chat-live-wave{flex:1;display:flex;align-items:center;gap:8px;min-width:0;height:38px}
#chat-app .chat-live-wave canvas{flex:1;min-width:0;height:32px}
#chat-app .chat-live-wave span{font-size:12px;color:#7a7a7f}

/* Голосовые как в Telegram: удержание микрофона — запись, вверх — замочек, влево — отмена. */
#chat-app #chat-action{touch-action:none;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
#chat-app .chat-composer{position:relative}
#chat-app .chat-record-lock{position:absolute;bottom:calc(100% + 10px);width:38px;height:78px;margin-left:-19px;display:flex;flex-direction:column;align-items:center;justify-content:space-between;
  padding:10px 0 8px;box-sizing:border-box;border:1px solid #e7e7ec;border-radius:999px;background:linear-gradient(#ffffff,#f5f5fa);box-shadow:inset 0 1px 0 #fff,0 6px 18px #3131361f;
  color:#247bff;z-index:6;transform:translateY(calc(var(--pull,0) * -22px));transition:opacity .18s ease,transform .12s linear;pointer-events:none}
#chat-app .chat-record-lock[hidden]{display:flex!important;opacity:0;transform:translateY(12px) scale(.85)}
#chat-app .chat-record-lock svg{width:19px;height:19px}
#chat-app .chat-record-lock svg:last-child{width:16px;height:16px;color:#8c8c91;animation:chat-lock-hint 1.2s ease-in-out infinite}
@keyframes chat-lock-hint{50%{transform:translateY(-4px)}}
#chat-app .chat-live-wave{transform:translateX(var(--slide,0px));transition:transform .12s linear}
#chat-app .chat-slide-hint{display:none;flex:none;font-size:13px;color:#8c8c91;white-space:nowrap}
#chat-app.voice-hold .chat-slide-hint{display:inline}
#chat-app.voice-hold .chat-live-wave canvas{max-width:90px}
#chat-app.voice-hold #chat-action{transform:scale(1.18);background:#247bff;color:#fff;border-color:#247bff;box-shadow:0 4px 14px #247bff55;transition:transform .15s ease}
:root[data-theme=dark] #chat-app .chat-record-lock{border-color:#3a3a3c;background:linear-gradient(#2c2c2e,#232325);box-shadow:none}
#chat-app .chat-emojis{position:absolute;right:18px;bottom:calc(100% + 8px);z-index:5;display:grid;grid-template-columns:repeat(8,minmax(0,1fr));gap:3px;box-sizing:border-box;width:min(330px,calc(100vw - 36px));max-height:230px;overflow-y:auto;overflow-x:hidden;padding:10px;border:1px solid #e7e7ec;border-radius:18px;background:#fff;box-shadow:0 12px 30px #37373c26}
#chat-app .chat-emoji-choice{width:100%;min-width:0;height:36px;padding:0;border:0;border-radius:50%;background:transparent;font-size:22px;cursor:pointer}
#chat-app .chat-emoji-choice:hover,#chat-app .chat-emoji-choice:focus-visible{background:#f0f0f5}
#chat-app .chat-file-link{display:flex;align-items:center;gap:8px;max-width:min(100%,280px);color:#242429;text-decoration:none}
#chat-app .chat-file-link svg{width:23px;height:23px;flex:none}
#chat-app .chat-file-link img{display:block;width:min(240px,100%);height:165px;border-radius:12px;object-fit:contain}
#chat-app .chat-file-link:has(img){flex-direction:column;align-items:flex-start}
#chat-app .chat-file-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#chat-app .chat-photo-button{padding:0;border:0;background:transparent;font:inherit;text-align:left;cursor:pointer}
#chat-app .chat-photo-preview{box-sizing:border-box;width:calc(100vw / var(--zoom,1));height:calc(100dvh / var(--zoom,1));max-width:none;max-height:none;margin:0;padding:0;border:0;border-radius:0;color:#fff}
#chat-app .chat-photo-preview-inner{position:relative;display:flex;align-items:center;justify-content:center;box-sizing:border-box;width:100%;height:100%;padding:64px 24px 90px}
#chat-app .chat-photo-preview img{display:block;max-width:100%;max-height:100%;object-fit:contain}
#chat-app .chat-photo-preview-actions{position:absolute;inset:0;pointer-events:none}
#chat-app .chat-photo-preview-actions .round-key{position:absolute;top:calc(16px + env(safe-area-inset-top));left:16px;width:42px;height:42px;min-height:42px;pointer-events:auto}
#chat-app .chat-voice{gap:9px;max-width:min(100%,300px)}
#chat-app .chat-voice-play{width:34px;height:34px;min-height:34px;padding:0}
#chat-app .chat-voice-play svg{width:17px;height:17px}
#chat-app .chat-voice-bars{display:flex;flex:1;align-items:center;gap:2px;height:30px;min-width:0}
#chat-app .chat-voice-bars i{flex:1;min-width:2px;max-width:4px;border-radius:3px;background:#b5b5ba}
/* Сыгранная часть голосового: тёмная копия полосок под шторкой. Шторка и её содержимое сдвигаются навстречу друг
   другу (transform) — полоски стоят на месте, а видимая часть растёт слева направо. */
#chat-app .chat-voice-bars{position:relative;touch-action:none;cursor:pointer}
#chat-app .chat-voice-played,#chat-app .chat-voice-played>span{position:absolute;inset:0;pointer-events:none}
#chat-app .chat-voice-played{overflow:hidden;transform:translateX(-100%)}
#chat-app .chat-voice-played>span{display:flex;align-items:center;gap:2px;transform:translateX(100%)}
#chat-app .chat-voice-played i{background:#6e6e73}
#chat-app .chat-voice-duration{font-size:11px;color:#7d7d82}
#chat-app .chat-voice-audio{display:none}
/* Отправляющееся голосовое — тот же вид, что дошедшее (без общих правил плитки загрузки), кольцо загрузки с крестиком —
   поверх кнопки «играть»; кнопка не нажимается, пока запись не на сервере. */
#chat-app .chat-bubble .chat-upload.chat-voice-upload{display:block;max-width:none;min-height:0;padding:0}
#chat-app .chat-voice-upload .chat-voice-play{pointer-events:none}
#chat-app .chat-voice-upload .chat-voice-play svg{width:17px;height:17px}
#chat-app .chat-bubble .chat-voice-upload .chat-ring{left:0;top:50%;width:34px;height:34px;margin:-17px 0 0;background:#247bff;-webkit-backdrop-filter:none;backdrop-filter:none}
#chat-app .chat-voice-upload .chat-ring b{display:none}
#chat-app .chat-voice-upload .chat-ring .x{opacity:1}
#chat-app [hidden]{display:none!important}
#chat-app .chat-dialog{width:min(390px,calc(100vw / var(--zoom,1) - 36px));max-height:calc(85dvh / var(--zoom,1));overflow:auto;padding:20px;color:#242429;transform-origin:top right}
@keyframes chat-sheet-in{from{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}
#chat-app .chat-sheet{display:flex;flex-direction:column;gap:16px}
#chat-app .chat-sheet h2{font-size:18px;font-weight:600;line-height:1.25;margin:0;text-align:center}
#chat-app .chat-sheet-top{display:grid;align-items:center}
#chat-app .chat-sheet-top h2{grid-column:2}
#chat-app .chat-sheet form{display:flex;align-items:center;gap:10px}
#chat-app .chat-sheet form .pill-input{flex:1;width:100%;padding:12px 18px}
#chat-app .chat-sheet form .chat-edit-input{min-height:120px;border-radius:20px;resize:vertical;text-align:left}
#chat-app .chat-sheet-actions{display:flex;justify-content:center;gap:14px}
#chat-app .chat-sheet-actions .press-key{min-width:92px}
#chat-app .chat-delete-choice{display:flex;align-items:center;justify-content:center;gap:10px;cursor:pointer}
#chat-app .chat-delete-choice input{appearance:none;width:24px;height:24px;margin:0;border:1px solid #dbdbe0;border-radius:50%;background:linear-gradient(#fff,#f5f5fa);box-shadow:0 1px 0 #f1f1f6,inset 0 1px 0 #fff;cursor:pointer}
#chat-app .chat-delete-choice input:checked{background:#e7eefb;border-color:#aebfda}
#chat-app .chat-delete-choice input:checked:after{content:'✓';display:block;text-align:center;line-height:22px;font-size:16px;color:#242429}
#chat-app .chat-settings-actions{display:flex;flex-direction:column;gap:8px}
#chat-app .chat-members{display:flex;flex-direction:column;gap:8px;max-height:260px;overflow:auto}
#chat-app .chat-member{display:flex;align-items:center;gap:11px;min-height:44px}
#chat-app .chat-member-photo{width:42px;height:42px;padding:0;border:0;border-radius:50%;background:none;cursor:pointer}
#chat-app .chat-member-photo .avatar,#chat-app .chat-member-photo img{width:42px;height:42px;border-radius:50%;object-fit:cover;font-size:18px}
#chat-app .chat-member span:last-child{font-size:14px}
#chat-app .chat-person-options{display:flex;flex-direction:column;gap:8px;max-height:300px;overflow:auto}
#chat-app .chat-person-key{width:100%;justify-content:flex-start}
#chat-app .chat-person-key .avatar{width:32px;height:32px;font-size:14px}
#chat-app .chat-person-key span:last-child{flex:1;text-align:left}
@media(min-width:651px){#chat-app{inset:20px 20px 18px 20px}}
@media(max-width:650px){
  #chat-app .chat-switch-slot{display:none}
  #chat-app .chat-list-panel{flex:1;min-height:0}
  #chat-app .chat-top-strip{flex:none;min-height:52px;order:1;border-radius:22px}
  #chat-app .chat-content{flex:1;min-height:0;order:2}
  #chat-app[data-mobile-view=list] .chat-top-strip,#chat-app[data-mobile-view=list] .chat-content{display:none}
  #chat-app[data-mobile-view=detail] .chat-list-panel{display:none}
  #chat-app #chat-back{display:inline-flex}
  #chat-app .chat-title-button{max-width:calc(100% - 150px);font-size:16px}
}

/* Как «Файлы» и «Настройки»: панель по содержимому, без заголовка; плюс — в полоске. */
#chat-app #chat-create-strip{display:none}
@media(min-width:651px){
#chat-app{max-width:none;justify-content:center;align-content:start}
#chat-app .chat-list-panel{align-self:start;max-height:100%;padding:12px}
#chat-app .chat-list-header{display:none}
#chat-app #chat-list:empty{display:none}
#chat-app .chat-list-panel:has(#chat-list:empty){display:none}
}
@media(min-width:651px){#chat-app{grid-template-columns:210px minmax(0,720px);grid-template-rows:52px min(592px,calc(100dvh / var(--zoom, 1) - 104px))}#chat-app .chat-content{min-height:0}}
/* Заголовок — просто текст; чаты в списке — такие же клавиши, как вкладки боковой панели. */
#chat-app .chat-title{position:absolute;left:50%;transform:translateX(-50%);max-width:calc(100% - 240px);margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:19px;font-weight:600;pointer-events:none}
#chat-app .chat-list-key{min-height:48px;flex-direction:row;align-items:center;justify-content:flex-start;gap:10px;padding:15px 17px;border-radius:999px}
#chat-app .chat-list-key svg{width:19px;height:19px;flex:none;color:#242429}
#chat-app .chat-list-key strong{font-weight:500}
#chat-app #chat-list{gap:9px}
/* Настройки чата: узкие клавиши по центру; «Фон» — маленькое окно; участники — отдельная страница. */
#chat-app .chat-settings-actions{align-items:center}
#chat-app .chat-settings-actions .press-key{width:220px}
.chat-background-keys{display:flex;flex-direction:column;gap:8px;width:200px}
.chat-background-keys .press-key{width:100%;min-height:40px}
#chat-app .chat-members-add{grid-column:3}
#chat-app .chat-member{justify-content:flex-start}
#chat-app .chat-member>span{flex:1}
#chat-app .chat-member-remove{width:42px;height:42px;min-height:42px;flex:none}
/* На компьютере настройки чата — в меню по правой кнопке на чате; шестерёнка остаётся на телефоне. */
@media(min-width:651px){#chat-app #chat-settings{display:none}#chat-app #user-button{margin-left:auto}}
/* Поле ввода без полупрозрачной подложки; многострочное, растёт по высоте. */
#chat-app .chat-composer{background:none;border-top:0;align-items:flex-end}
#chat-app .chat-composer .round-key{flex:none}
/* Многострочное поле в новой панели ввода. */
#chat-app textarea#chat-message{display:block;resize:none;height:38px;min-height:38px;max-height:160px;padding:9px 0;line-height:1.4;overflow-y:auto;scrollbar-width:none}
/* Поле растёт по тексту само — средствами браузера (без пересчёта высоты кодом на каждую букву). */
@supports (field-sizing:content){#chat-app textarea#chat-message{field-sizing:content;height:auto!important}}
#chat-app .chat-input-wrap{align-items:flex-end}
/* Телефон — как «Файлы» и «Настройки»: карточка без верхней полоски; плюс внизу списка. */
@media(max-width:650px){
  #chat-app{inset:calc(90px + env(safe-area-inset-top)) 8px max(8px,calc(env(safe-area-inset-bottom) - 26px))}
  #chat-app .chat-top-strip{display:none!important}
  #chat-app .chat-list-panel{display:flex;flex-direction:column;padding:0;overflow:hidden;border-radius:22px}
  #chat-app #chat-list{flex:1;min-height:0}
  #chat-app .chat-list-header{order:2;flex:none;justify-content:center}
  #chat-app .chat-list-header h1{display:none}
  #chat-app .chat-list-header .round-key{width:40px;height:40px;min-height:40px}
  #chat-app .chat-composer{padding:10px 10px 12px}
  #chat-app textarea#chat-message{font-size:16px}
  #chat-app .chat-emojis{right:10px}
  #chat-app .chat-input-wrap #chat-emoji{width:34px;height:34px;min-height:34px;margin:2px 0}
  #chat-app .chat-input-wrap #chat-emoji svg{width:19px;height:19px}
}
/* Телефон: без кнопки смайлов (они есть в клавиатуре); скрепка и микрофон — по центру поля;
   фон чата — на весь экран, а не только в карточке. */
@media(max-width:650px){
  #chat-app .chat-input-wrap #chat-emoji{display:none}
  #chat-app .chat-input-wrap{padding:0 14px}
  /* Узкое окно на компьютере: клавиатуры со смайлами нет — кнопка остаётся. */
  @media(hover:hover) and (pointer:fine){
    #chat-app .chat-input-wrap #chat-emoji{display:flex}
    #chat-app .chat-input-wrap{padding:0 3px 0 14px}
  }
  #chat-app .chat-composer{align-items:center}
  #chat-app .chat-content{overflow:visible;background:transparent;border-radius:0;box-shadow:none;border:0}
  #chat-app .chat-content .chat-photo,#chat-app .chat-content .chat-tints{z-index:-1}
}
@media(max-width:650px){#chat-app .chat-composer.multiline{align-items:flex-end}}
/* Телефон: «назад» и шестерёнка — в верхней строке по бокам от кнопки с названием чата. */
.app-header>#chat-back,.app-header>#chat-settings,.app-header>.chat-peer-avatar{display:none}
@media(max-width:650px){
  body:has(#chat-app[data-mobile-view=detail]:not([hidden])) .app-header>#chat-back,
  body:has(#chat-app[data-mobile-view=detail]:not([hidden])) .app-header>#chat-settings{display:inline-flex;flex:none;width:44px;height:44px;min-height:44px;padding:0;border-radius:50%}
  .app-header>#chat-back{order:-1}
  .app-header>#chat-settings{margin-left:auto}
  body:has(#chat-app[data-mobile-view=detail]:not([hidden])) .app-header>.chat-peer-avatar{display:inline-flex;margin-left:auto}
  .app-header>#chat-back svg,.app-header>#chat-settings svg{width:19px;height:19px;color:#242429}
}
@media(max-width:650px){.app-header>#chat-settings[aria-expanded=true]{transform:translateY(1px);background:linear-gradient(#f0f0f5,#f5f5fa);box-shadow:0 0 0 #e4e4e9,inset 0 1px 3px #e1e1e6}}
/* Телефон: поле — капсула той же высоты и скругления, что и круглые кнопки; при нескольких строках
   растёт прямоугольником с теми же углами, без синей обводки. */
@media(max-width:650px){
  #chat-app .chat-input-wrap{border-radius:20px;min-height:40px;box-sizing:border-box}
  #chat-app .chat-input-wrap:focus-within{border-color:#e7e7ec;box-shadow:inset 0 1px 2px #f0f0f5}
  #chat-app textarea#chat-message{min-height:38px;padding:8px 0;line-height:22px}
}
/* Телефон, чат с фоном: сверху фон плавно переходит в цвет полосы с часами — шва и дымки не видно. */
@media(max-width:650px){
  #chat-app .chat-content::after{content:'';left:0;right:0;top:0;height:calc(124px + env(safe-area-inset-top));pointer-events:none;background:linear-gradient(var(--chat-tint,var(--status-color,#e9e9ee)),color-mix(in srgb,var(--chat-tint,var(--status-color,#e9e9ee)) 55%,transparent) 45%,transparent)}
}
/* Компьютер: скрепка и микрофон — по центру поля; при нескольких строках — прижаты к низу. */
@media(min-width:651px){#chat-app .chat-composer{align-items:center}#chat-app .chat-composer.multiline{align-items:flex-end}}
/* Телефон, открыта клавиатура: фон чата — карточка со скруглёнными углами и отступом над клавиатурой,
   как карточка в файлах; сверху — цвет полосы с часами. */
@media(max-width:650px){
  body.kb-open #chat-app .chat-content{overflow:hidden;isolation:isolate;border-radius:22px}
  body.kb-open #chat-app .chat-content .chat-photo,body.kb-open #chat-app .chat-content .chat-tints,body.kb-open #chat-app .chat-content::before{position:absolute}
  body.kb-open #chat-app .chat-content::after{display:none}
}

/* Сообщение, которое ещё отправляется: часики; не дошло — восклицательный знак, повтор сам. */
#chat-app .chat-send-state svg{width:14px;height:14px}
#chat-app .chat-send-state.failed{color:#d2453b}
#chat-app .chat-pending .chat-bubble{opacity:.85}
/* Фото, файл или голосовое, которое ещё загружается: превью и полоска загрузки. */
#chat-app .chat-upload{display:flex;flex-direction:column;align-items:flex-start;gap:6px;max-width:min(100%,280px)}
#chat-app .chat-upload img{display:block;width:min(240px,100%);height:165px;border-radius:12px;object-fit:cover}
#chat-app .chat-upload svg{width:23px;height:23px}
/* Фото — как в Телеграме: пузырь по размеру фото, тонкая обводка, углы с «хвостиком»,
   время и галочки — в светлой полупрозрачной капсуле поверх фото. */
#chat-app .chat-bubble.chat-photo-bubble{position:relative;padding:2px;border:1px solid #e1e1e6;line-height:0}
#chat-app .chat-photo-bubble .chat-file-link,#chat-app .chat-photo-bubble .chat-upload{display:block;max-width:none;gap:0}
#chat-app .chat-photo-bubble img{display:block;width:auto;height:auto;max-width:min(260px,62vw);max-height:340px;min-width:120px;min-height:90px;object-fit:cover;border-radius:15px 15px 15px 3px}
#chat-app .chat-message.own .chat-photo-bubble img{border-radius:15px 15px 3px 15px}
/* Размер кадра известен (chatFrame): тот же результат, что ограничения выше дают загруженной картинке, но сразу. */
#chat-app .chat-bubble.chat-photo-bubble :is(img,canvas).chat-sized{--fw:max(120px,min(var(--w)*1px,min(260px,62vw),340px*var(--w)/var(--h)));width:var(--fw);height:clamp(90px,var(--fw)*var(--h)/var(--w),340px)}
/* Плашка времени на фото — без размытия фона под собой (как и ▶ на видео): размытие у каждого фото телефон пересчитывал
   в каждом кадре прокрутки переписки. Вместо него цвет плашки чуть плотнее. */
#chat-app .chat-photo-bubble .chat-meta{position:absolute;right:9px;bottom:9px;float:none;margin:0;padding:4px 8px;border-radius:999px;background:#ffffffd9;color:#69696e;box-shadow:0 1px 3px #37373c1f;line-height:1}
#chat-app .chat-photo-bubble .chat-meta time,#chat-app .chat-photo-bubble .chat-read-status,#chat-app .chat-photo-bubble .chat-edited{color:#69696e}
#chat-app .chat-photo-bubble .chat-forwarded,#chat-app .chat-photo-bubble .chat-quote{line-height:1.45;padding:6px 10px 4px;margin:0}
/* Сообщения как в Телеграме (телефон и компьютер): имя — внутри пузыря сверху, своим цветом;
   аватарка — слева у «хвостика» каждого чужого сообщения; время и тонкие галочки — в правом нижнем углу. */
#chat-app .chat-message:not(.own){flex-direction:row;align-items:flex-end}
#chat-app .chat-face{flex:none;width:32px;height:32px}
#chat-app .chat-face .avatar{width:32px;height:32px;font-size:14px}
#chat-app .chat-author{display:block;margin:0 0 3px;font-size:13px;font-weight:600;line-height:1.3;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
#chat-app .chat-author[data-color=sage]{color:#4f7a61}
#chat-app .chat-author[data-color=blue]{color:#3f78b3}
#chat-app .chat-author[data-color=rose]{color:#a55a7b}
#chat-app .chat-author[data-color=sand]{color:#9a7843}
#chat-app .chat-author[data-color=violet]{color:#7160a6}
#chat-app .chat-author[data-color=slate]{color:#5b6d80}
#chat-app .chat-photo-bubble .chat-author{padding:6px 10px 2px;line-height:1.3}
#chat-app .chat-bubble{position:relative;border-radius:17px}
#chat-app .chat-message.tail:not(.own) .chat-bubble{border-bottom-left-radius:5px}
#chat-app .chat-message.own.tail .chat-bubble{border-bottom-right-radius:5px}
#chat-app .chat-message:not(.tail) .chat-photo-bubble img{border-radius:15px}
#chat-app .chat-bubble:not(.chat-photo-bubble)>.chat-meta{position:absolute;float:none;margin:0}
#chat-app .chat-meta-space{display:inline-flex;gap:5px;margin-left:10px;visibility:hidden;font-size:11px;line-height:1;vertical-align:baseline}
#chat-app .chat-meta-space .chat-read-status{height:12px}
#chat-app .chat-read-status{height:12px}
#chat-app .chat-read-status svg{width:14px;height:11px;stroke-width:1.5}
#chat-app .chat-read-status.read svg{width:20px}
#chat-app .chat-meta{gap:4px;font-size:11px;color:#8c8c91}
#chat-app .chat-read-status{color:#8c8c91}
/* Пузыри плотнее к содержимому и ближе к краям экрана (телефон и компьютер). */
#chat-app .chat-messages{padding:14px 16px;gap:8px}
#chat-app .chat-bubble{padding:7px 11px;line-height:1.38}
#chat-app .chat-bubble:not(.chat-photo-bubble)>.chat-meta{right:11px;bottom:7px}
#chat-app .chat-author{margin-bottom:1px}
#chat-app .chat-message:not(.own){gap:6px}
/* Голосовое: кнопка слева, под волной — длительность, время — справа на той же строке. */
#chat-app .chat-voice{display:grid;grid-template-columns:34px minmax(150px,1fr);grid-template-rows:auto auto;column-gap:9px;row-gap:1px;align-items:center;min-width:0;padding-right:2px}
#chat-app .chat-voice .chat-voice-play{grid-row:1 / span 2}
#chat-app .chat-voice .chat-voice-bars{height:22px}
#chat-app .chat-voice .chat-voice-duration{grid-column:2;line-height:14px}
/* Часики и восклицательный знак отправки — в тон и размер галочек. */
#chat-app .chat-read-status.chat-send-state svg{width:12px;height:12px;stroke-width:1.5}
#chat-app .chat-read-status.chat-send-state.failed{color:#d2453b}
@media(max-width:650px){
}
/* Телефон: пузыри, аватарки и кнопки ближе к краям экрана. */
@media(max-width:650px){
  #chat-app .chat-messages{padding:10px 6px}
  #chat-app .chat-message:not(.own){gap:5px}
}
/* Свайп для ответа: пузырь едет влево, справа проявляется значок ответа. */
#chat-app .chat-message{position:relative;touch-action:pan-y}
#chat-app .chat-swipe-reply{position:absolute;right:-44px;top:50%;display:flex;align-items:center;justify-content:center;width:32px;height:32px;margin-top:-16px;border-radius:50%;background:#ffffffcc;opacity:0;pointer-events:none}
#chat-app .chat-swipe-reply svg{width:17px;height:17px;color:#242429}
#chat-app .chat-swipe-reply.ready{transform:scale(1.12);background:#fff}
#chat-app .chat-messages{overflow-x:hidden}
/* Тёмная тема, ручные поправки чата (автоматическая копия светлой здесь выходит неудачно). */
:root[data-theme=dark] #chat-app .chat-message.own .chat-bubble{background:#343436f2;border-color:#454548}
:root[data-theme=dark] #chat-app .chat-message.own .chat-meta,:root[data-theme=dark] #chat-app .chat-message.own .chat-read-status{color:#a1a1a8}
:root[data-theme=dark] #chat-app .chat-voice-bars i{background:#6e6e73}
:root[data-theme=dark] #chat-app .chat-voice-played i{background:#d1d1d6}
:root[data-theme=dark] #chat-app .chat-message .chat-bubble.chat-photo-bubble{border-color:#ffffff1f}
:root[data-theme=dark] #chat-app .chat-message .chat-photo-bubble .chat-meta{background:#121213cc;color:#e5e5ea}
:root[data-theme=dark] #chat-app .chat-photo-bubble .chat-meta time,:root[data-theme=dark] #chat-app .chat-photo-bubble .chat-read-status{color:#e5e5ea}
/* Тёмная тема: фон чата приглушён — картинка и цветные разводы темнее, сообщения читаются лучше. */
:root[data-theme=dark] #chat-app .chat-content .chat-photo{filter:brightness(.72)}
:root[data-theme=dark] #chat-app .chat-content .chat-tints{opacity:.45}
:root[data-theme=dark] #chat-app .chat-content::before{background:#0b0b0c}
/* OLED: под фоном чата — чёрный; пузыри остаются тёмно-серыми, чтобы читались. */
:root[data-theme=dark][data-oled] #chat-app .chat-content::before{background:#000}
:root[data-theme=dark][data-oled] #chat-app .chat-message .chat-bubble{background:#0e0e10f2;border-color:#ffffff24}
:root[data-theme=dark][data-oled] #chat-app .chat-message.own .chat-bubble{background:#1d1d20f2;border-color:#ffffff2e}
:root[data-theme=dark][data-oled] #chat-app .chat-message .chat-photo-bubble .chat-meta{background:#000000cc;color:#e5e5ea}
:root[data-theme=dark][data-oled] #chat-app .chat-input-wrap{background:#000;border-color:#ffffff2e;box-shadow:none}
/* Компьютер: поле ввода как на телефоне — капсула высотой и скруглением как круглые кнопки,
   при нескольких строках растёт прямоугольником с теми же углами; без подсветки при фокусе. */
@media(min-width:651px){
  #chat-app .chat-input-wrap{box-sizing:border-box;min-height:40px;border-radius:20px;padding:0 3px 0 14px}
  #chat-app .chat-input-wrap:focus-within{border-color:#e7e7ec;box-shadow:inset 0 1px 2px #f0f0f5}
  #chat-app textarea#chat-message{min-height:38px;height:38px;padding:8px 0;line-height:22px}
}
/* Компьютер: смайлы — просто значок в поле (как в Телеграме), без кнопки-капсулы. */
@media(min-width:651px){
  #chat-app .chat-input-wrap #chat-emoji{border:0;background:none;box-shadow:none;width:32px;height:32px;min-height:32px;margin:3px 0}
  #chat-app .chat-input-wrap #chat-emoji svg{width:21px;height:21px;color:#949499;transition:color .15s ease}
  #chat-app .chat-input-wrap #chat-emoji:hover svg,#chat-app .chat-input-wrap #chat-emoji[aria-expanded=true] svg{color:#242429}
  #chat-app .chat-input-wrap #chat-emoji:active,#chat-app .chat-input-wrap #chat-emoji[aria-expanded=true]{transform:none;background:none;box-shadow:none}
}
/* OLED: фон чата приглушён сильнее — экран остаётся по-настоящему чёрным. */
:root[data-theme=dark][data-oled] #chat-app .chat-content .chat-photo{filter:brightness(.6)}
:root[data-theme=dark][data-oled] #chat-app .chat-content .chat-tints{opacity:.28}
#chat-app .chat-gone{color:#8c8c91;font-style:italic}
/* Телефон, как в Telegram: поле ввода со скрепкой и микрофоном — 26 точек от боков
   и 28 от низа экрана (над полоской «Домой»), между ними 7. */
@media(max-width:650px){
  #chat-app .chat-composer{padding-left:22px;padding-right:22px;gap:7px}
}
/* Телефон: сообщения прокручиваются под верхними кнопками и под полем ввода, без обреза-«разделителя».
   Высоту низа (поле ввода + строка ответа) скрипт кладёт в --chat-dock. */
@media(max-width:650px){
  /* От последнего сообщения до поля ввода — всегда как от поля до полоски iOS над открытой клавиатурой (8⅓ точки;
     сверено по пикселям снимка симулятора, тень пузыря — ещё точка). */
  #chat-app{top:0;--chat-gap:.33px}
  #chat-app .chat-content-inner{padding-top:var(--top-h)}
  #chat-app .chat-pinned,#chat-app .chat-reply-bar{position:relative;z-index:2}
  #chat-app .chat-messages{margin-top:calc(-1 * var(--top-h));padding-top:calc(var(--top-h) + 10px);margin-bottom:calc(-1 * var(--chat-dock,62px));padding-bottom:calc(var(--chat-dock,62px) + var(--chat-gap))}
  #chat-app .chat-pinned:not([hidden])~.chat-messages{margin-top:calc(-1 * var(--top-h) - 56px);padding-top:calc(var(--top-h) + 66px)}
  #chat-app .chat-composer{z-index:2}
  #chat-app .chat-composer::before{content:'';position:absolute;left:-8px;right:-8px;top:10px;bottom:-40px;z-index:-1;pointer-events:none}
}
/* Компьютер: сообщения сверху мягко растворяются у края, снизу уходят под поле ввода. */
@media(min-width:651px){
  #chat-app .chat-composer,#chat-app .chat-reply-bar{position:relative;z-index:2}
  #chat-app .chat-messages{margin-bottom:calc(-1 * var(--chat-dock,70px));padding-bottom:calc(var(--chat-dock,70px) + 14px)}
}
/* Телефон, список чатов: так же уходит под верхний заголовок и под «+» внизу, без линии над «+». */
@media(max-width:650px){
  #chat-app #chat-list{padding-top:calc(var(--top-h) + 16px);padding-bottom:80px}
  #chat-app .chat-list-header{border-top:0}
  #chat-app .chat-list-header::before{content:'';position:absolute;left:-8px;right:-8px;top:10px;bottom:-40px;z-index:-1;pointer-events:none;background:linear-gradient(color-mix(in srgb,var(--status-color-bottom,var(--status-color,#fff)) 0%,transparent) calc((100% - 40px) * 0),color-mix(in srgb,var(--status-color-bottom,var(--status-color,#fff)) 10%,transparent) calc((100% - 40px) * 0.1),color-mix(in srgb,var(--status-color-bottom,var(--status-color,#fff)) 28%,transparent) calc((100% - 40px) * 0.25),color-mix(in srgb,var(--status-color-bottom,var(--status-color,#fff)) 50%,transparent) calc((100% - 40px) * 0.4),color-mix(in srgb,var(--status-color-bottom,var(--status-color,#fff)) 72%,transparent) calc((100% - 40px) * 0.55),color-mix(in srgb,var(--status-color-bottom,var(--status-color,#fff)) 88%,transparent) calc((100% - 40px) * 0.7),color-mix(in srgb,var(--status-color-bottom,var(--status-color,#fff)) 97%,transparent) calc((100% - 40px) * 0.85),var(--status-color-bottom,var(--status-color,#fff)) calc((100% - 40px) * 1),var(--status-color-bottom,var(--status-color,#fff)) 100%)}
}

/* «В сети»: зелёная точка в углу аватарки; крупная аватарка собеседника по нажатию. */
#chat-app .chat-face{position:relative;padding:0;border:0;background:none;cursor:pointer;border-radius:50%}
#chat-app .chat-face.online::after,#chat-app .chat-member-photo.online::after,.person-photo.online::after{content:'';position:absolute;right:-1px;bottom:-1px;width:9px;height:9px;border-radius:50%;background:#34c759;border:2px solid #fff}
#chat-app .chat-member-photo{position:relative}
.person-card{display:flex;flex-direction:column;align-items:center;gap:2px;padding:14px 26px 12px;text-align:center}
.person-card .person-photo{position:relative;display:inline-block;margin-bottom:8px}
.person-card .person-photo .avatar{width:96px;height:96px;font-size:40px}
.person-card .person-photo.online::after{right:4px;bottom:4px;width:16px;height:16px;border-width:3px}
.person-card strong{font-size:16px;font-weight:600;color:#1c1c1e}
.person-card .person-seen{font-size:13px;color:#8c8c91;white-space:nowrap}
:root[data-theme=dark] #chat-app .chat-face.online::after,:root[data-theme=dark] #chat-app .chat-member-photo.online::after,:root[data-theme=dark] .person-photo.online::after{border-color:#1c1c1e}
:root[data-theme=dark][data-oled] #chat-app .chat-face.online::after,:root[data-theme=dark][data-oled] #chat-app .chat-member-photo.online::after{border-color:#000}
:root[data-theme=dark] .person-card strong{color:#f2f2f7}
/* Меню чата (карточка собеседника и меню группы): кнопки — по центру. */
#context-menu .person-card~button,#context-menu.chat-menu button,.menu-centered button{justify-content:center}
/* Список: подписи «Группы» и «Личные», у людей — аватарка с точкой «в сети». */
#chat-app .chat-list-section{margin:10px 6px 2px;font-size:12px;font-weight:600;letter-spacing:.2px;color:#8c8c91;text-transform:uppercase}
#chat-app .chat-list-section:first-child{margin-top:0}
#chat-app .chat-list-icon{display:inline-flex;flex:none}
#chat-app .chat-list-icon svg{width:19px;height:19px;color:#242429}
#chat-app .chat-list-face{position:relative;flex:none;width:26px;height:26px;margin:-4px 0}
#chat-app .chat-list-face .avatar{width:26px;height:26px;max-width:none;font-size:12px;font-weight:600;color:#fff;overflow:hidden}
#chat-app .chat-list-face.online::after{content:'';position:absolute;right:-2px;bottom:-2px;width:8px;height:8px;border-radius:50%;background:#34c759;border:2px solid #fff}
:root[data-theme=dark] #chat-app .chat-list-face.online::after{border-color:#1c1c1e}
/* Телефон, список чатов: внизу капсула «Личные | Группы» (как в Файлах), видна одна секция; «+» (новая группа) —
   над капсулой, только на «Группах». */
#chat-app .chat-tabs{display:none}
#chat-app .chat-section-empty{display:none}
#chat-app .chat-section{display:flex;flex-direction:column;gap:inherit}
@media(min-width:651px){#chat-app .chat-section:not(:has(.chat-list-key)){display:none}}
@media(max-width:650px){
  #chat-app .chat-list-section{display:none}
  #chat-app .chat-section:not(:has(.chat-list-key)) .chat-section-empty{display:block;margin:40px 20px;text-align:center;font-size:15px;color:#8c8c91}
  #chat-app .chat-tabs{display:flex;position:fixed;left:0;right:0;bottom:0;z-index:5;width:calc(100% - 24px);max-width:420px;margin:0 auto var(--tabs-gap);padding:5px;gap:0;border:1px solid #e7e7ec;border-radius:34px;background:linear-gradient(#ffffff,#f7f7fc);box-shadow:0 8px 24px #37373c14,inset 0 1px 0 #ffffff;touch-action:none;user-select:none;-webkit-user-select:none}
  #chat-app .chat-tabs .chat-tab,#chat-app .chat-tabs .chat-tab:hover,#chat-app .chat-tabs .chat-tab:active,#chat-app .chat-tabs .chat-tab.active{position:relative;z-index:1;flex:1 1 0;min-width:0;flex-direction:column;justify-content:center;gap:3px;min-height:56px;padding:6px 2px;font-size:11px;font-weight:500;border:0;border-radius:999px;background:none;box-shadow:none;transform:none;color:#242429;transition:color .2s ease}
  #chat-app .chat-tabs .chat-tab svg{width:19px;height:19px;color:inherit}
  #chat-app .chat-tabs .chat-tab.active,#chat-app .chat-tabs .chat-tab.lens-over{color:#247bff}
  #chat-app .chat-tabs.dragging .chat-tab.active:not(.lens-over){color:#242429}
  #chat-app .chat-tabs .tab-lens{display:block;position:absolute;left:0;top:5px;bottom:5px;border-radius:999px;background:#ebebf0;pointer-events:none;transition:transform .36s cubic-bezier(.3,.78,.4,1),width .2s ease}
  #chat-app .chat-tabs .tab-lens.moving{transition:none}
  #chat-app #chat-list{margin-bottom:0}
  #chat-app .chat-list-header{position:fixed;left:0;right:0;bottom:calc(var(--tabs-h) + var(--tabs-gap));z-index:5;padding:10px 0 12px}
  #chat-app .chat-list-header::before{display:none}
  #chat-app:is([data-list-tab=direct],[data-list-tab=recent]) .chat-list-header{display:none}
}
@media(max-width:650px){
  #chat-app .chat-pager-foot::before{content:'';left:0;right:0;bottom:0;z-index:4;pointer-events:none;height:calc(var(--tabs-h) + var(--tabs-gap));background:linear-gradient(color-mix(in srgb,var(--status-color-bottom,var(--status-color,#fff)) 0%,transparent) 0%,color-mix(in srgb,var(--status-color-bottom,var(--status-color,#fff)) 10%,transparent) 10%,color-mix(in srgb,var(--status-color-bottom,var(--status-color,#fff)) 28%,transparent) 25%,color-mix(in srgb,var(--status-color-bottom,var(--status-color,#fff)) 50%,transparent) 40%,color-mix(in srgb,var(--status-color-bottom,var(--status-color,#fff)) 72%,transparent) 55%,color-mix(in srgb,var(--status-color-bottom,var(--status-color,#fff)) 88%,transparent) 70%,color-mix(in srgb,var(--status-color-bottom,var(--status-color,#fff)) 97%,transparent) 85%,var(--status-color-bottom,var(--status-color,#fff)) 100%)}
  #chat-app[data-list-tab=groups] .chat-pager-foot::before{height:calc(52px + var(--tabs-h) + var(--tabs-gap))}
}
/* «Печатает…» — пузырь с тремя прыгающими точками над полем ввода; в списке — подпись под названием. */
#chat-app .chat-typing-dots{display:inline-flex;gap:3px;flex:none}
#chat-app .chat-typing-dots i{width:6px;height:6px;border-radius:50%;background:#b0b0b5;animation:chat-typing-dot 1.2s infinite ease-in-out}
#chat-app .chat-typing-dots i:nth-child(2){animation-delay:.15s}
#chat-app .chat-typing-dots i:nth-child(3){animation-delay:.3s}
@keyframes chat-typing-dot{0%,60%,100%{transform:translateY(0);opacity:.5}30%{transform:translateY(-3px);opacity:1}}
@keyframes chat-typing-in{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}
/* Непрочитанные — как в Telegram: синий кружок с числом справа у чата, красный значок на вкладке. */
#chat-app .chat-list-key .chat-unread{flex:none;margin-left:auto;min-width:22px;height:22px;padding:0 7px;border-radius:11px;background:#247bff;color:#fff;font-size:12px;font-weight:600;line-height:22px;text-align:center;overflow:visible}
.unread-badge{display:inline-block;min-width:18px;height:18px;padding:0 5px;border-radius:9px;background:#ff3b30;color:#fff;font-size:11px;font-weight:600;line-height:18px;text-align:center;box-sizing:border-box}
#chat-app .chat-list-section .unread-badge{margin-left:6px;vertical-align:1px;text-transform:none}
#chat-app .chat-tabs .chat-tab .unread-badge{position:absolute;top:4px;left:calc(50% + 6px)}

/* «Печатает…» — пузырь от имени того, кто пишет. */
#chat-app .chat-typing-bubble{cursor:default;animation:chat-typing-in .18s ease-out}
#chat-app .chat-typing-bubble .chat-typing-dots{display:flex;align-items:center;height:20px;padding:0 2px}
/* Шапка чата как в Телеграме: капсула с названием и строкой состояния под ним (высотой с «назад»),
   аватарка собеседника — круглой кнопкой справа. */
.chat-peer-avatar{position:relative;flex:none;width:44px;height:44px;min-height:44px;padding:2px;border-radius:50%}
.chat-peer-avatar[hidden]{display:none!important}
.chat-peer-avatar .avatar{width:38px;height:38px;font-size:16px}
.chat-peer-avatar.online::after{content:'';position:absolute;right:0;bottom:0;width:9px;height:9px;border-radius:50%;background:#34c759;border:2px solid #fff}
.chat-peer-avatar:active,.chat-peer-avatar[aria-expanded=true]{transform:translateY(1px)}
#chat-app .chat-peer-head{position:absolute;left:50%;transform:translateX(-50%);display:flex;align-items:center;max-width:calc(100% - 300px)}
#chat-app .chat-peer-head[hidden]{display:none}
#chat-app .chat-peer-head>.chat-peer-avatar{position:absolute;left:calc(100% + 8px)}
#chat-app .chat-title.peer{display:none}
#chat-app .chat-peer-key{min-width:0;max-width:100%;height:44px;min-height:44px;padding:0 22px;border-radius:999px;font-size:16px;font-weight:600;color:#1c1c1e}
#chat-app .chat-peer-key[hidden]{display:none}
#chat-app .chat-peer-key:active,#chat-app .chat-peer-key[aria-expanded=true]{transform:translateY(1px)}
#chat-app .chat-peer-key span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
/* Строка состояния: «в сети», «печатает…», «3 участника». */
#chat-app .chat-peer-key span[data-status],#chat-app .chat-title[data-status]{display:block;text-align:center;line-height:19px}
#chat-app .chat-peer-key span[data-status]::after,#chat-app .chat-title[data-status]::after,#app-switch.chat-title-switch>span[data-status]::after{content:attr(data-status);display:block;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;line-height:15px;font-weight:400;color:#8a8a8f}
:is(#chat-app .chat-peer-key,#chat-app .chat-title,#app-switch).status-online [data-status]::after,#chat-app .chat-title.status-online[data-status]::after{color:#247bff}
#app-switch.chat-title-switch{height:44px;min-height:44px;padding:0 22px;gap:0;font-size:16px}
#app-switch.chat-title-switch>svg{display:none}
#app-switch.chat-title-switch>span{display:block;text-align:center;line-height:19px;max-width:220px}
#app-switch.chat-title-switch>span:not([data-status]){line-height:normal}
#context-menu .person-card+button{margin-top:4px}
:root[data-theme=dark] .chat-peer-avatar.online::after{border-color:#1c1c1e}
:root[data-theme=dark] #chat-app .chat-peer-key{color:#f2f2f7}
/* Реакции: панель частых над меню сообщения, полный список и значки под сообщением. */
#context-menu .reaction-bar{position:absolute;left:0;bottom:calc(100% + 10px);display:flex;align-items:center;gap:2px;padding:5px;border-radius:999px;background:#fff;box-shadow:0 12px 34px #00000024,0 2px 8px #00000012;white-space:nowrap}
#context-menu .reaction-bar button,#context-menu .reaction-grid button{flex:none;width:42px;height:42px;min-height:0;padding:0!important;margin:0;border:0;border-radius:50%;background:transparent;box-shadow:none;justify-content:center;font-size:27px;line-height:1;transition:transform .12s ease}
#context-menu .reaction-bar button:hover,#context-menu .reaction-grid button:hover{background:#f0f0f5}
#context-menu .reaction-bar button:active,#context-menu .reaction-grid button:active{transform:scale(.88);background:#ededf2}
#context-menu .reaction-bar .chosen,#context-menu .reaction-grid .chosen{background:#e3edff}
#context-menu .reaction-bar .reaction-more{width:36px;height:36px;margin-left:2px;background:#f0f0f5}
#context-menu .reaction-bar .reaction-more svg{width:18px;height:18px;color:#3a3a3f}
#context-menu.reaction-picker{padding:8px}
#context-menu .menu-fit{display:flex;flex-direction:column;overflow-y:auto;overscroll-behavior:contain}
#context-menu .menu-fit>*{flex:none}
#context-menu .menu-fit[style*="--menu-row"]>button,#context-menu .menu-fit[style*="--menu-row"]>button:hover{min-height:0;height:var(--menu-row)}
#context-menu .menu-fit[style*="--menu-row"] hr{margin:3px 12px}
#context-menu .reaction-grid{display:grid;grid-template-columns:repeat(7,42px);gap:4px;max-height:min(300px,60vh);overflow-y:auto;overscroll-behavior:contain}
#chat-app .chat-reactions{display:flex;flex-wrap:wrap;gap:5px;margin:6px 0 1px;white-space:normal}
#chat-app .chat-photo-bubble .chat-reactions,#chat-app .chat-voice~.chat-reactions{margin:6px 8px 4px}
#chat-app .chat-reaction{display:inline-flex;align-items:center;gap:4px;min-height:26px;padding:0 9px;border:1px solid #e3e3e8;border-radius:999px;background:#f2f2f7;font-size:14px;line-height:1;cursor:pointer}
#chat-app .chat-reaction:active{transform:scale(.94)}
#chat-app .chat-reaction.mine{background:#e3edff;border-color:#bcd3ff}
#chat-app .chat-reaction-emoji{font-size:16px}
#chat-app .chat-reaction-count{font-size:12px;font-weight:600;color:#3a3a3f}
#chat-app .chat-reaction.mine .chat-reaction-count{color:#1f63d6}
:root[data-theme=dark] #context-menu .reaction-bar{background:#2c2c2e}
:root[data-theme=dark] #context-menu .reaction-bar button:hover,:root[data-theme=dark] #context-menu .reaction-grid button:hover,:root[data-theme=dark] #context-menu .reaction-bar .reaction-more{background:#3a3a3c}
:root[data-theme=dark] #context-menu .reaction-bar .reaction-more svg{color:#e5e5ea}
:root[data-theme=dark] #context-menu .reaction-bar .chosen,:root[data-theme=dark] #context-menu .reaction-grid .chosen{background:#1f3a66}
:root[data-theme=dark] #chat-app .chat-reaction{background:#3a3a3c;border-color:#48484a}
:root[data-theme=dark] #chat-app .chat-reaction.mine{background:#1f3a66;border-color:#2f5596}
:root[data-theme=dark] #chat-app .chat-reaction-count{color:#e5e5ea}
:root[data-theme=dark] #chat-app .chat-reaction.mine .chat-reaction-count{color:#9ec2ff}
#chat-app .chat-reactions>.chat-meta-space{align-self:flex-end;margin-left:auto}
/* Список чатов как в Телеграме: имя и время, под ними последнее сообщение, галочки и непрочитанные. */
#chat-app .chat-list-key.with-preview{border-radius:999px}
#chat-app .chat-list-key .chat-list-body{flex:1;min-width:0;max-width:none;display:flex;flex-direction:column;gap:3px;overflow:visible;white-space:normal;font-size:inherit;color:inherit}
#chat-app .chat-list-key .chat-list-top,#chat-app .chat-list-key .chat-list-bottom{display:flex;align-items:center;gap:8px;max-width:none;overflow:visible;white-space:normal;font-size:inherit;color:inherit}
#chat-app .chat-list-key .chat-list-name{flex:1;min-width:0}
#chat-app .chat-list-key .chat-list-meta{flex:none;display:inline-flex;align-items:center;gap:3px;overflow:visible;font-size:12px;color:#8d8d92}
#chat-app .chat-list-key .chat-list-ticks{display:inline-flex;overflow:visible;color:#247bff}
#chat-app .chat-list-ticks svg{width:15px;height:14px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
#chat-app .chat-list-ticks.read svg{width:22px}
#chat-app .chat-list-key .chat-list-preview{flex:1;min-width:0;font-size:13px;line-height:1.3;color:#8d8d92;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#chat-app .chat-list-key .chat-list-preview.typing{color:#34a853;font-style:italic}
#chat-app .chat-list-key .chat-list-bottom .chat-unread{margin-left:0}
@media(max-width:650px){
  #chat-app .chat-list-key.with-preview{align-items:center;padding:10px 22px 10px 10px}
  #chat-app .chat-list-key.with-preview .chat-list-face,#chat-app .chat-list-key.with-preview .chat-list-face .avatar{width:48px;height:48px;margin:0;font-size:19px}
  #chat-app .chat-list-key.with-preview .chat-list-icon{width:48px;height:48px;border-radius:50%;background:#ececf1;justify-content:center;align-items:center}
  #chat-app .chat-list-key.with-preview .chat-list-icon svg{width:24px;height:24px}
  #chat-app .chat-list-key.with-preview .chat-list-face.online::after{right:0;bottom:0;width:11px;height:11px}
  #chat-app .chat-list-key .chat-list-name{font-size:16px}
  #chat-app .chat-list-key .chat-list-preview{font-size:14px;white-space:normal;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}
}
:root[data-theme=dark] #chat-app .chat-list-key.with-preview .chat-list-icon{background:#3a3a3c}
:root[data-theme=dark] #chat-app .chat-list-key .chat-list-ticks{color:#5e9bff}

/* Цитата ответа: полоска и имя цветом автора, фон — оттенок того же цвета. Нажатие — к исходному сообщению. */
#chat-app{--who:#247bff}
#chat-app .chat-quote,#chat-app [data-color]{--who:#247bff}
#chat-app [data-color=sage]{--who:#4f7a61}#chat-app [data-color=blue]{--who:#3f78b3}#chat-app [data-color=rose]{--who:#a55a7b}
#chat-app [data-color=sand]{--who:#9a7843}#chat-app [data-color=violet]{--who:#7160a6}#chat-app [data-color=slate]{--who:#5b6d80}
#chat-app .chat-quote{display:flex;flex-direction:column;gap:1px;max-width:100%;min-width:0;margin:2px 0 6px;padding:5px 10px 6px 11px;border-left:3px solid var(--who);border-radius:5px 9px 9px 5px;background:color-mix(in srgb,var(--who) 11%,transparent);white-space:normal;font-size:13px;line-height:1.3;overflow:hidden}
#chat-app .chat-quote.link{cursor:pointer}
#chat-app .chat-quote.link:active{background:color-mix(in srgb,var(--who) 20%,transparent)}
#chat-app .chat-quote .chat-quote-name{font-weight:600;color:var(--who);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#chat-app .chat-quote .chat-quote-text{color:#242429;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#chat-app .chat-quote.gone .chat-quote-text{color:#8c8c91;font-style:italic}
#chat-app .chat-photo-bubble .chat-quote{margin:6px 6px 4px;padding:5px 10px 6px 11px;line-height:1.3}
:root[data-theme=dark] #chat-app .chat-quote .chat-quote-text{color:#e5e5ea}
:root[data-theme=dark] #chat-app .chat-quote{background:color-mix(in srgb,var(--who) 24%,transparent)}
:root[data-theme=dark] #chat-app .chat-quote .chat-quote-name{color:color-mix(in srgb,var(--who) 55%,#fff)}
#chat-app .chat-reply-bar .chat-quote{flex:1;margin:0;--who:#247bff}
#chat-app .chat-reply-bar .chat-quote span{flex:none;font-size:13px}
#chat-app .chat-reply-bar .chat-quote .chat-quote-name{color:var(--who)}
#chat-app .chat-reply-bar .chat-quote .chat-quote-text{color:#242429}
:root[data-theme=dark] #chat-app .chat-reply-bar .chat-quote .chat-quote-text{color:#e5e5ea}
/* Переход к сообщению: оно коротко подсвечивается. */
#chat-app .chat-message .chat-bubble{transition:transform .08s ease,box-shadow .08s ease,background-color .7s ease,border-color .7s ease}
#chat-app .chat-message.chat-flash .chat-bubble{background-color:#d6e5ff;border-color:#b3cdfb;transition:transform .08s ease,box-shadow .08s ease}
:root[data-theme=dark] #chat-app .chat-message.chat-flash .chat-bubble{background-color:#23406e;border-color:#2f5596}
/* Вложения после нажатия не остаются выделенными. */
#chat-app .chat-messages :is(a,button,[role=button]):focus:not(:focus-visible){outline:none}
#chat-app .chat-photo-button img{-webkit-touch-callout:none;-webkit-user-select:none;user-select:none}
#chat-app .chat-list-key .chat-list-ticks svg{color:inherit}
@media(max-width:650px){#chat-app .chat-list-key.with-preview{min-height:70px}}
@media(min-width:651px){#chat-app .chat-list-key.with-preview{padding:10px 12px;gap:9px}#chat-app .chat-list-key .chat-list-meta{font-size:11px}#chat-app .chat-list-key .chat-list-ticks svg{width:13px}#chat-app .chat-list-key .chat-list-ticks.read svg{width:19px}}
/* Реакции: аватарки тех, кто поставил, и список в меню сообщения. */
#chat-app .chat-reaction-faces{display:inline-flex;margin-left:1px}
#chat-app .chat-reaction-face{display:inline-flex;width:20px;height:20px;border-radius:50%;box-shadow:0 0 0 2px #f2f2f7;overflow:hidden}
#chat-app .chat-reaction-face+.chat-reaction-face{margin-left:-6px}
#chat-app .chat-reaction-face .avatar{width:20px;height:20px;font-size:10px;font-weight:600;color:#fff}
#chat-app .chat-reaction.mine .chat-reaction-face{box-shadow:0 0 0 2px #e3edff}
#chat-app .chat-reaction:has(.chat-reaction-faces){padding:0 4px 0 8px}
:root[data-theme=dark] #chat-app .chat-reaction-face{box-shadow:0 0 0 2px #3a3a3c}
:root[data-theme=dark] #chat-app .chat-reaction.mine .chat-reaction-face{box-shadow:0 0 0 2px #1f3a66}
#context-menu .reaction-people{display:flex;flex-direction:column;gap:2px;max-height:170px;overflow-y:auto;padding:2px 4px}
#context-menu .reaction-person{display:flex;align-items:center;gap:10px;min-height:36px;padding:0 8px;font-size:14px}
#context-menu .reaction-person-face{display:inline-flex;flex:none;width:28px;height:28px;border-radius:50%;overflow:hidden}
#context-menu .reaction-person-face .avatar{width:28px;height:28px;font-size:12px;font-weight:600;color:#fff}
#context-menu .reaction-person-name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#context-menu .reaction-person-emoji{flex:none;font-size:18px}
/* Выбор сообщений: отмеченные — с синей обводкой и галочкой сбоку; внизу — панель действий. */
#chat-app .chat-select-bar{display:none}
#chat-app.selecting .chat-composer,#chat-app.selecting .chat-reply-bar{display:none!important}
#chat-app.selecting .chat-select-bar{display:flex;align-items:center;gap:8px;position:relative;z-index:2;margin:0 18px 14px;padding:6px;border:1px solid #e7e7ec;border-radius:999px;background:#ffffffe6;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px)}
#chat-app .chat-select-count{flex:1;text-align:center;font-size:15px;font-weight:600}
#chat-app .chat-select-bar .round-key{width:42px;height:42px;min-height:42px;flex:none}
#chat-app .chat-select-bar .danger-key svg{color:#ff3b30}
#chat-app.selecting .chat-message[data-id]{cursor:pointer}
#chat-app .chat-message.picked .chat-bubble{box-shadow:0 0 0 2px #247bff}
#chat-app.selecting .chat-message[data-id]::after{content:'';position:absolute;top:50%;width:20px;height:20px;margin-top:-11px;border:1.5px solid #c7c7cc;border-radius:50%;background:#ffffffcc}
#chat-app.selecting .chat-message.picked::after{border-color:#247bff;background:#247bff}
#chat-app.selecting .chat-message.picked::before{content:'';position:absolute;z-index:1;top:50%;width:5px;height:10px;margin-top:-8px;border:solid #fff;border-width:0 2px 2px 0;transform:rotate(45deg)}
:root[data-theme=dark] #chat-app.selecting .chat-select-bar{background:#2c2c2ee6;border-color:#3a3a3c}
:root[data-theme=dark] #chat-app.selecting .chat-message[data-id]::after{background:#1c1c1ecc;border-color:#636366}
@media(max-width:650px){#chat-app.selecting .chat-select-bar{margin:0 10px calc(10px + env(safe-area-inset-bottom))}}
/* Как в Телеграме: при выборе переписка сдвигается вправо, кружки — в колонку у левого края. */
#chat-app.selecting .chat-messages{padding-left:44px!important}
#chat-app.selecting .chat-message[data-id]::after,#chat-app.selecting .chat-message.own[data-id]::after{right:auto;left:var(--pick-x,-32px)}
#chat-app.selecting .chat-message.picked::before,#chat-app.selecting .chat-message.own.picked::before{right:auto;left:calc(var(--pick-x,-32px) + 8px)}
#chat-app .chat-message .chat-forwarded-from{padding:0;font-size:inherit;font-weight:600;color:var(--who)}
#chat-app .chat-forwarded{font-size:12px}
/* Гифка на холсте — как фото в переписке и на весь экран. */
#chat-app .chat-photo-bubble canvas.chat-gif{display:block;width:auto;height:auto;max-width:min(260px,62vw);max-height:340px;min-width:120px;min-height:90px;object-fit:cover;border-radius:15px 15px 15px 3px}
#chat-app .chat-message.own .chat-photo-bubble canvas.chat-gif{border-radius:15px 15px 3px 15px}
#chat-app .chat-message:not(.tail) .chat-photo-bubble canvas.chat-gif{border-radius:15px}
#chat-app .chat-photo-preview canvas.chat-gif{display:block;max-width:100%;max-height:100%;width:auto;height:auto;object-fit:contain}
/* Гифка-ролик: размер пузыря задаёт маленькая копия (как у фото), ролик лежит поверх неё и закрывает её целиком. */
#chat-app .chat-photo-bubble .chat-loop{position:relative;display:block;overflow:hidden;border-radius:15px 15px 15px 3px}
#chat-app .chat-message.own .chat-photo-bubble .chat-loop{border-radius:15px 15px 3px 15px}
#chat-app .chat-message:not(.tail) .chat-photo-bubble .chat-loop{border-radius:15px}
#chat-app .chat-photo-bubble.with-caption .chat-loop{border-bottom-left-radius:4px;border-bottom-right-radius:4px}
#chat-app .chat-loop>video{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;pointer-events:none}
#chat-app .chat-loop.bare>video{position:static;display:block;width:auto;height:auto;max-width:min(260px,62vw);max-height:340px;min-width:120px;min-height:90px}
#chat-app .chat-album .chat-loop{border-radius:0}
/* Одни эмодзи — крупно, без пузыря; время — в капсуле под ними. */
#chat-app .chat-bubble.chat-emoji-bubble{display:flex;flex-direction:column;align-items:flex-end;padding:0;border:0;background:none!important;box-shadow:none!important;line-height:1.1}
#chat-app .chat-emoji-bubble .chat-message-text{font-size:44px;letter-spacing:2px}
#chat-app .chat-emoji-bubble.emoji-1 .chat-message-text{font-size:76px;letter-spacing:0}
#chat-app .chat-emoji-bubble.emoji-2 .chat-message-text{font-size:56px}
#chat-app .chat-bubble.chat-emoji-bubble>.chat-meta{position:static;float:none;margin:2px 0 0;padding:3px 8px;border-radius:999px;background:#ffffffb8;color:#69696e}
#chat-app .chat-emoji-row .chat-reactions{align-self:flex-start}
:root[data-theme=dark] #chat-app .chat-bubble.chat-emoji-bubble>.chat-meta{background:#121213b3;color:#e5e5ea}
/* Подпись под фото или файлом; у фото с подписью время — в строке подписи. */
#chat-app .chat-caption{display:block;white-space:pre-wrap}
#chat-app .chat-photo-bubble .chat-caption{padding:6px 9px 0;line-height:1.38}
#chat-app .chat-photo-bubble.with-caption .chat-reactions{line-height:1.38;margin:6px 8px 0}
#chat-app .chat-photo-bubble.with-caption :is(img,canvas.chat-gif){border-bottom-left-radius:4px!important;border-bottom-right-radius:4px!important}
#chat-app .chat-photo-bubble.with-caption{padding-bottom:7px}
#chat-app .chat-photo-bubble.with-caption>.chat-meta{position:absolute;right:10px;bottom:7px;padding:0;background:none;box-shadow:none;-webkit-backdrop-filter:none;backdrop-filter:none;color:#8c8c91}
#chat-app .chat-photo-bubble.with-caption>.chat-meta :is(time,.chat-read-status,.chat-edited){color:#8c8c91}
/* Цитата вложения: миниатюра слева, имя и подпись (или «Фото», «Видео»…) справа. */
#chat-app .chat-quote.with-thumb{flex-direction:row;align-items:center;gap:8px}
#chat-app .chat-quote-body{display:flex;flex-direction:column;gap:1px;min-width:0}
#chat-app .chat-quote-thumb{flex:none;width:34px;height:34px;border-radius:6px;object-fit:cover}
#chat-app .chat-quote-thumb.round{border-radius:50%}
#chat-app .chat-quote-thumb.sticker{object-fit:contain;border-radius:0}

/* Предпросмотр фона: фото на весь экран, пример переписки, «Размытие», яркость и «Применить». */
#chat-app .chat-wall-preview{box-sizing:border-box;width:calc(100vw / var(--zoom,1));height:calc(100dvh / var(--zoom,1));max-width:none;max-height:none;margin:0;padding:0;border:0;border-radius:0;background:#111116;overflow:hidden}
#chat-app .chat-wall-preview::backdrop{background:#000}
#chat-app .chat-wall-photo,#chat-app .chat-wall-shade{position:absolute;inset:-45px}
#chat-app .chat-wall-photo{background-position:center;background-size:cover}
#chat-app .chat-wall-shade{background:#000;pointer-events:none}
#chat-app .chat-wall-close{position:absolute;top:calc(16px + env(safe-area-inset-top));left:16px;z-index:2;width:42px;height:42px;min-height:42px}
#chat-app .chat-wall-panel{position:absolute;left:0;right:0;bottom:0;z-index:2;display:flex;flex-direction:column;gap:14px;max-width:520px;margin:0 auto;padding:0 16px calc(18px + env(safe-area-inset-bottom))}
#chat-app .chat-wall-sample{display:flex;flex-direction:column;gap:6px;margin-bottom:8px}
#chat-app .chat-wall-sample .chat-message{max-width:80%}
#chat-app .chat-wall-controls{display:flex;flex-direction:column;align-items:center}
#chat-app .chat-wall-light{display:flex;align-items:center;gap:10px;width:100%;padding:8px 14px;border-radius:999px;background:#ffffffd9;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px)}
#chat-app .chat-wall-light svg{flex:none;width:16px;height:16px;color:#6e6e73}
#chat-app .chat-wall-light svg:last-child{width:22px;height:22px}
#chat-app .chat-wall-light input{flex:1;min-width:0;height:28px;margin:0;-webkit-appearance:none;appearance:none}
#chat-app .chat-wall-light input::-webkit-slider-runnable-track{height:6px;border-radius:3px;background:linear-gradient(90deg,#247bff var(--fill,100%),#d1d1d6 var(--fill,100%))}
#chat-app .chat-wall-light input::-webkit-slider-thumb{-webkit-appearance:none;width:24px;height:24px;margin-top:-9px;border-radius:50%;background:#fff;box-shadow:0 1px 4px #0004}
#chat-app .chat-wall-light input::-moz-range-track{height:6px;border-radius:3px;background:#d1d1d6}
#chat-app .chat-wall-light input::-moz-range-progress{height:6px;border-radius:3px;background:#247bff}
#chat-app .chat-wall-actions{display:flex;flex-direction:column;gap:8px}
#chat-app .chat-wall-actions .press-key{width:100%;min-height:48px;border-radius:999px;font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis}
:root[data-theme=dark] #chat-app .chat-wall-light{background:#2c2c2ed9}

#chat-app .chat-wall-blur-row svg{stroke-width:1.8}
#chat-app .chat-wall-controls{gap:10px}
#chat-app .chat-wall-light input,#chat-app .chat-wall-light input:hover,#chat-app .chat-wall-light input:focus{border:0;box-shadow:none;padding:0;border-radius:0;background:transparent;outline:none}
#chat-app .chat-wall-blur-row svg:first-child{width:16px;height:16px}
#chat-app .chat-wall-blur-row svg:last-child{width:22px;height:22px}
/* Видео в переписке: обложка, ▶ по центру, длина (и «сжимается…») в углу. */
#chat-app .chat-video-button,#chat-app .chat-upload{position:relative}
#chat-app .chat-video-blank{display:block;width:240px;height:160px;border-radius:15px;background:#2c2c2e}
#chat-app .chat-video-play{position:absolute;left:50%;top:50%;width:48px;height:48px;margin:-24px 0 0 -24px;display:flex;align-items:center;justify-content:center;border-radius:50%;background:#00000099;color:#fff;pointer-events:none}
#chat-app .chat-video-play svg{width:22px;height:22px;margin-left:3px;fill:#fff;stroke:#fff}
#chat-app .chat-video-length{position:absolute;left:9px;top:9px;padding:3px 8px;border-radius:999px;background:#0000008c;color:#fff;font-size:11px;line-height:1.2;pointer-events:none}
#chat-app .chat-photo-preview video{display:block;max-width:100%;max-height:100%;background:#000}
/* Голосовые: длина и кнопка скорости в одной строке. */
#chat-app .chat-voice-info{grid-column:2;display:flex;align-items:center;gap:6px;line-height:14px}
#chat-app .chat-voice-speed{min-height:0;padding:1px 6px;border:0;border-radius:999px;background:#00000014;color:#3a3a3f;font-size:11px;font-weight:600;line-height:14px;cursor:pointer}
#chat-app .chat-voice-speed:active{transform:scale(.94)}
:root[data-theme=dark] #chat-app .chat-voice-speed{background:#3a3a3c;color:#e5e5ea}
/* «Без сжатия»: вместо значка файла — маленькая копия (у видео — с ▶); в просмотре справа сверху — «скачать». */
#chat-app .chat-file-thumb-play{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:#0000003d}
#chat-app .chat-file-thumb-play svg{width:16px;height:16px;fill:#fff;stroke:#fff}
#chat-app .chat-photo-preview-actions .chat-download-key{left:auto;right:16px}
/* Окно «Фон»: готовые фоны сеткой 4 × 2, под ней — кнопки. */
dialog.user-sheet.chat-wall-sheet{width:min(360px,calc(calc(100vw / var(--zoom, 1)) - 24px))}
.chat-wall-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;margin-bottom:14px}
.chat-wall-tile{position:relative;aspect-ratio:3/4;padding:0;border:0;border-radius:14px;overflow:hidden;background:#e5e5ea;box-shadow:0 1px 3px #0000001f;cursor:pointer}
.chat-wall-tile img{display:block;width:100%;height:100%;object-fit:cover}
.chat-wall-tile:active{transform:scale(.96)}
.chat-wall-tile.chosen{box-shadow:0 0 0 3px #247bff}
.chat-wall-sheet .chat-background-keys{width:100%}
.chat-background-keys .danger-key{color:#e0403c}
#chat-app .chat-wall-soft{position:absolute;left:-45px;top:-45px;width:calc(100% + 90px);height:calc(100% + 90px);object-fit:cover}
#chat-app .chat-wall-soft[hidden]{display:none}

/* Окно отправки вложения — по центру, как в Телеграме. */
#chat-app .chat-send-sheet{box-sizing:border-box;width:min(420px,calc(calc(100vw / var(--zoom, 1)) - 24px));max-width:none;max-height:calc(calc(100dvh / var(--zoom, 1)) - 24px);margin:auto;padding:12px;border:0;border-radius:28px;background:#fff;color:#1c1c1e;box-shadow:0 24px 70px #0000003a,0 2px 10px #00000014;overflow:visible}
#chat-app .chat-send-sheet[open]{display:flex;flex-direction:column;gap:12px;animation:sheet-rise .38s cubic-bezier(.16,1,.3,1)}
#chat-app .chat-send-sheet::backdrop{background:#0000004d}
@keyframes chat-send-in{from{opacity:0;transform:scale(.94)}to{opacity:1;transform:none}}
#chat-app .chat-send-head{display:grid;grid-template-columns:44px 1fr 44px;align-items:center}
#chat-app .chat-send-head .round-key{width:44px;height:44px;min-height:44px}
#chat-app .chat-send-title{margin:0;text-align:center;font-size:17px;font-weight:600}
#chat-app .chat-send-menu{position:absolute;top:62px;right:12px;z-index:3;display:flex;flex-direction:column;min-width:210px;padding:6px;border-radius:18px;background:#fff;box-shadow:0 16px 44px #00000026,0 2px 8px #00000012;animation:chat-send-in .2s cubic-bezier(.3,1.2,.5,1);transform-origin:right top}
#chat-app .chat-send-menu[hidden]{display:none}
/* Меню удержания стрелки — над ней, у нижнего края окна. */
#chat-app .chat-send-later{top:auto;bottom:70px;min-width:190px;transform-origin:100% 100%}
#chat-app .chat-send-later svg{width:20px;height:20px;flex:none;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
#chat-app .chat-send-option{display:flex;align-items:center;gap:10px;min-height:44px;padding:0 14px 0 10px;border:0;border-radius:12px;background:none;font-size:16px;text-align:left;cursor:pointer;color:inherit}
#chat-app .chat-send-option:active{background:#ededf2}
#chat-app .chat-send-tick{position:relative;width:18px;height:18px;flex:none}
#chat-app .chat-send-option[aria-checked=true] .chat-send-tick::after{content:'';position:absolute;left:5px;top:1px;width:6px;height:12px;border:solid #1c1c1e;border-width:0 2px 2px 0;transform:rotate(45deg)}
#chat-app .chat-send-body{min-height:0}
#chat-app .chat-send-media{position:relative;border-radius:18px;overflow:hidden;background:#f2f2f7}
#chat-app .chat-send-media img{display:block;width:100%;height:auto;max-height:min(60dvh,520px);object-fit:contain}
#chat-app .chat-send-media.empty{height:200px;background:#2c2c2e}
/* Кадр видео, пришедший при открытом окне, заполняет уже стоящее место (attachments.js, place). */
#chat-app .chat-send-media.empty img{position:absolute;inset:0;width:100%;height:100%;max-height:none;object-fit:cover}
#chat-app .chat-send-body .chat-file-card{width:auto;padding:2px}
#chat-app .chat-send-form{position:relative;display:flex;align-items:flex-end;gap:8px}
#chat-app .chat-send-input{flex:1;min-width:0;display:flex;align-items:flex-end;min-height:44px;padding:0 4px 0 16px;border:1px solid #e5e5ea;border-radius:22px;background:#f7f7fa}
#chat-app .chat-send-input textarea{flex:1;min-width:0;height:42px;padding:11px 0;border:0;background:transparent;outline:none;resize:none;font:inherit;font-size:16px;line-height:20px;color:inherit}
#chat-app .chat-send-input .chat-send-smile{width:36px;height:36px;min-height:36px;margin:3px 0;border:0;background:none;box-shadow:none}
#chat-app .chat-send-input .chat-send-smile svg{width:22px;height:22px;color:#6e6e73}
#chat-app .chat-send-form .chat-send-go{width:44px;height:44px;min-height:44px;flex:none}
#chat-app .chat-send-emojis{position:absolute;right:52px;bottom:calc(100% + 8px);z-index:3;display:grid;grid-template-columns:repeat(8,minmax(0,1fr));gap:3px;width:320px;max-height:180px;overflow-y:auto;padding:10px;border-radius:18px;background:#fff;box-shadow:0 16px 44px #00000026}
#chat-app .chat-send-emojis[hidden]{display:none}
/* Телефон: пока пишешь подпись — окно прямо над клавиатурой, превью ужимается. */
body.kb-open #chat-app .chat-send-sheet{top:auto;bottom:calc(var(--vv-bottom,0px) + 8px);margin:0 auto;max-height:calc(calc(100dvh / var(--zoom, 1)) - var(--vv-top,0px) - var(--vv-bottom,0px) - 16px)}
body.kb-open #chat-app .chat-send-media img{max-height:calc(calc(100dvh / var(--zoom, 1)) - var(--vv-top,0px) - var(--vv-bottom,0px) - 190px)}
/* Файл в переписке (и в окне отправки): миниатюра или значок, имя, размер; пузырь не шире ~260 точек. */
#chat-app .chat-file-card{display:grid;grid-template-columns:52px minmax(0,1fr);grid-template-rows:auto auto;column-gap:11px;row-gap:3px;align-items:center;width:min(280px,66vw);max-width:100%;color:inherit;text-decoration:none;cursor:pointer}
#chat-app .chat-file-card .chat-file-thumb{position:relative;grid-row:1 / span 2;display:flex;align-items:center;justify-content:center;width:52px;height:52px;border-radius:12px;overflow:hidden;background:#247bff1f}
#chat-app .chat-file-card .chat-file-thumb svg{width:24px;height:24px;color:#247bff}
#chat-app .chat-file-card .chat-file-thumb img{display:block;width:52px;height:52px;min-width:0;min-height:0;max-width:none;max-height:none;border-radius:0;object-fit:cover}
#chat-app .chat-file-card .chat-file-name{align-self:end;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:14px;font-weight:500}
#chat-app .chat-file-card .chat-file-size{align-self:start;font-size:12px;color:#8c8c91}
#chat-app .chat-send-head .round-key svg{width:20px;height:20px;color:#1c1c1e}
#chat-app .chat-send-head [aria-haspopup=menu] svg{stroke-width:3.2}
/* Окна чата — того же вида, что и остальные. */
#chat-app .chat-dialog{border:0;border-radius:28px;background:#fff;box-shadow:0 24px 70px #0000003a,0 2px 10px #00000014;animation:sheet-rise .38s cubic-bezier(.16,1,.3,1)}
#chat-app .chat-dialog::backdrop{background:#0000004d}
#chat-app .chat-sheet-top{grid-template-columns:44px 1fr 44px;gap:8px}
#chat-app .chat-sheet-top::after{content:''}
#chat-app .chat-sheet-top .round-key{width:44px;height:44px;min-height:44px}
#chat-app .chat-sheet-top h2{margin:0;font-size:17px;font-weight:600;text-align:center}

/* Карточка пожелания в чате с Fio: метка «#N · состояние» и пометка агента. */
#chat-app .chat-task-chip{align-items:center;gap:6px;margin:0 0 5px;padding:2px 9px;border-radius:999px;background:#8e8e9322;font-size:12px;line-height:18px;color:#6e6e73}
#chat-app .chat-message .chat-task-chip strong{padding:0;font-size:12px;font-weight:700;color:inherit}
#chat-app .chat-task-chip.queued{background:#ff9f0a24;color:#b36200}
#chat-app .chat-task-chip.work{background:#247bff1f;color:#1f63d6}
#chat-app .chat-photo-bubble .chat-task-chip{margin:6px 8px 4px}
#chat-app .chat-task-note{display:block;margin-top:6px;padding:6px 10px;border-radius:10px;background:#34c7591a;line-height:1.35;color:#1c1c1e;white-space:pre-wrap}
#chat-app .chat-photo-bubble .chat-task-note{margin:6px 8px 0}
#chat-app .chat-task-note.ask{background:#247bff14}
:root[data-theme=dark] #chat-app .chat-task-note.ask{background:#247bff26;color:#f2f2f7}
#chat-app .chat-task-chip{display:flex;width:max-content}
#chat-app .chat-task-chip.done{background:#34c7592b;color:#248a3d}
#chat-app .chat-task-chip.closed{background:#8e8e9322;color:#6e6e73}
#chat-app .chat-task-note{font-size:14px}

/* Фон чата — готовая картинка на весь слой; новая проявляется поверх прежней. */
#chat-app .chat-photo>.chat-wall-img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;display:block;user-select:none;-webkit-user-select:none}
#chat-app .chat-photo>.chat-wall-img.fading{opacity:0;transition:opacity .22s ease}
#chat-app .chat-photo>.chat-wall-img.fading.shown{opacity:1}
#chat-app[data-wall] .chat-photo::after{z-index:1}
/* Компьютер: «+» у заголовка «Группы»; в полоске — «чат на всё окно». Телефон — как раньше. */
#chat-app #chat-wide,#chat-app .chat-section-add{display:none}
@media(min-width:651px){
  #chat-app #chat-wide{display:inline-flex}
  #chat-app .chat-section[data-kind=groups] .chat-list-section{display:flex;align-items:center;gap:6px}
  #chat-app .chat-section-add{display:inline-flex;width:28px;height:28px;min-height:28px;margin-left:auto}
  #chat-app .chat-section-add svg{width:15px;height:15px}
  /* На всё окно: без списка чатов, во всю ширину и высоту (уголок размера не нужен). */
  body.chat-wide #chat-app{grid-template-columns:minmax(0,1fr)!important;grid-template-rows:52px calc(100dvh / var(--zoom, 1) - 104px)!important;justify-content:stretch}
  body.chat-wide #chat-app .resize-grip{display:none}
  body.chat-wide #chat-app .chat-switch-slot,body.chat-wide #chat-app .chat-list-panel{display:none}
  body.chat-wide #chat-app .chat-top-strip,body.chat-wide #chat-app .chat-content{grid-column:1}
}
/* Компьютер, как на телефоне: переписка начинается под верхней областью, а кнопки и название чата лежат
   поверх неё (без отдельной полоски); сверху фон плавно темнеет/светлеет под кнопками. */
@media(min-width:651px){
  #chat-app .chat-content{grid-row:1 / span 2}
  #chat-app .chat-top-strip{grid-row:1;z-index:3;align-self:start;height:52px;padding:0 12px;background:transparent!important;box-shadow:none!important;border:0;pointer-events:none}
  #chat-app .chat-top-strip>*{pointer-events:auto}
  #chat-app .chat-top-strip .chat-title{pointer-events:none;display:flex;flex-direction:column;justify-content:center;height:44px;padding:0 22px;border:1px solid #e7e7ec;border-radius:999px;background:linear-gradient(#ffffff,#f5f5fa);box-shadow:0 1px 0 #f1f1f6,inset 0 1px 0 #fff;font-size:16px;line-height:19px}
  #chat-app .chat-top-strip .chat-title:empty{display:none}
  #chat-app .chat-top-strip .chat-title.peer{display:none}
  /* Сверху — под кнопками без маски (там своя дымка: она кончается на пиксель выше низа заголовка, 48 − 1),
     снизу сообщения мягко растворяются под полем ввода. */
  #chat-app .chat-messages{padding-top:78px;-webkit-mask-image:linear-gradient(#000 calc(100% - var(--chat-dock,70px) - 4px),transparent calc(100% - var(--chat-dock,70px) * .4));mask-image:linear-gradient(#000 calc(100% - var(--chat-dock,70px) - 4px),transparent calc(100% - var(--chat-dock,70px) * .4))}
  /* Полоса с кнопками опущена на 9px (list-top.css) — дымка начинается от самого верха области чата. */
  #chat-app .chat-top-strip::before{content:'';position:absolute;left:0;right:0;top:-9px;height:56px;z-index:-1;pointer-events:none;border-radius:26px 26px 0 0;
    background:linear-gradient(rgb(var(--chat-edge-top,251 251 253)/.92),rgb(var(--chat-edge-top,251 251 253)/.6) 40%,rgb(var(--chat-edge-top,251 251 253)/.2) 72%,transparent)}
  :root[data-theme=dark] #chat-app:not([data-wall]) .chat-top-strip::before{background:linear-gradient(#1c1c1ef0,#1c1c1e99 40%,#1c1c1e33 72%,transparent)}
  :root[data-theme=dark] #chat-app .chat-top-strip .chat-title{border-color:#3a3a3c;background:linear-gradient(#2c2c2e,#242426);box-shadow:none;color:#f2f2f7}
  #chat-app .chat-pinned{margin-top:70px}
}
/* Файл без подписи: время и галочки — справа на уровне строки с размером. */
#chat-app .chat-bubble.chat-file-bubble>.chat-meta{bottom:15px}
#chat-app .chat-file-bubble .chat-file-card{padding-right:0}
/* Фото с подписью: подпись занимает ширину пузыря, фото — по центру, по бокам его размытая копия. */
#chat-app .chat-photo-bubble.with-caption>.chat-photo-button{position:relative;display:flex;flex-direction:row;align-items:center;justify-content:center;width:100%;overflow:hidden;border-radius:15px 15px 4px 4px;isolation:isolate}
#chat-app .chat-photo-bubble.with-caption>.chat-photo-button>:is(img,canvas):not(.chat-photo-soft){position:relative;z-index:1}
#chat-app .chat-photo-bubble .chat-photo-soft{position:absolute;inset:0;z-index:0;width:100%!important;height:100%!important;max-width:none!important;max-height:none!important;min-width:0!important;min-height:0!important;object-fit:cover;filter:blur(18px) saturate(1.15);transform:scale(1.3);border-radius:0!important;pointer-events:none}
#chat-app .chat-photo-bubble.with-caption>.chat-photo-button>:is(img,canvas):not(.chat-photo-soft){border-radius:0!important}
/* Несколько вложений: сетка миниатюр (или список файлов) в окне отправки. */
#chat-app .chat-send-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(96px,1fr));gap:4px;max-height:min(52dvh,420px);overflow:auto;border-radius:18px}
#chat-app .chat-send-cell{position:relative;aspect-ratio:1;background:#f2f2f7;overflow:hidden}
#chat-app .chat-send-cell img{width:100%;height:100%;object-fit:cover;display:block}
#chat-app .chat-send-cell .chat-video-play{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%)}
/* Убрать вложение из отправки: маленькая круглая клавиша в углу плитки, у файла — в конце строки. */
#chat-app .chat-send-remove{width:28px;height:28px;min-height:28px;padding:0;flex:none}
#chat-app .chat-send-remove svg{width:14px;height:14px}
#chat-app .chat-send-cell .chat-send-remove{position:absolute;top:6px;right:6px}
#chat-app .chat-send-list .chat-send-remove{margin-left:auto}
#chat-app .chat-send-list{display:flex;flex-direction:column;gap:10px;max-height:min(46dvh,360px);overflow:auto}
:root[data-theme=dark] #chat-app .chat-send-cell{background:#2c2c2e}
/* Телефон, низ чата — «как сверху»: у самого края сплошной цвет, к середине — 55%, дальше прозрачно. */
@media(max-width:650px){
  #chat-app .chat-composer::before{background:linear-gradient(transparent 0,color-mix(in srgb,var(--chat-tint-bottom,var(--status-color-bottom,var(--status-color,#fff))) 55%,transparent) 55%,var(--chat-tint-bottom,var(--status-color-bottom,var(--status-color,#fff))) 100%)}
}
#chat-app .chat-swipe-reply{transition:background .15s ease}
/* Удержание на сообщении: пузырь слегка вдавливается; системное меню iOS (выделение текста) не мешает. */
#chat-app .chat-message .chat-bubble.pressing{scale:.96;transition:scale .3s ease,transform .08s ease,box-shadow .08s ease}
@media(pointer:coarse){#chat-app .chat-message .chat-bubble{-webkit-touch-callout:none;-webkit-user-select:none;user-select:none}}
/* Компьютер: все верхние кнопки и капсулы — одного размера (44), как в чате на телефоне;
   «Пожелания | Архив» — под ними, а не под заголовком. */
@media(min-width:651px){
  #chat-app .chat-top-strip>:is(.round-key,#user-button,.chat-peer-head .chat-peer-avatar){width:44px;height:44px;min-height:44px;flex:none}
  #chat-app .chat-top-strip #user-button svg{width:20px;height:20px}
  #chat-app .chat-peer-head>.chat-peer-avatar{width:44px;height:44px;min-height:44px}
}
/* Ширина пузырей — уже, как в Телеграме (телефон ~ три четверти экрана, компьютер — до 480 точек). */
#chat-app .chat-message{max-width:min(65%,480px)}
@media(max-width:650px){#chat-app .chat-message{max-width:78%}}
#chat-app .chat-photo-bubble.with-caption{max-width:min(300px,72vw)}
@media(min-width:651px){#chat-app .chat-switch-slot{display:flex}}

/* Телефон: список и переписка — две страницы одной горизонтальной прокрутки с «примагничиванием»; листает
   сам телефон. Всё, что раньше было закреплено за экраном (фон, подложка, дымки, нижние вкладки), теперь часть
   своей страницы и едет вместе с ней. У переписки своя шапка (назад, название, аватарка) — тоже на странице. */
@media(max-width:650px){
  #chat-app{left:0!important;right:0!important;bottom:0!important;display:flex!important;flex-direction:row!important;gap:0!important;
    overflow-y:hidden;scroll-snap-type:x mandatory;scrollbar-width:none;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}
  #chat-app::-webkit-scrollbar{display:none}
  /* Клавиатура: переписка остаётся во весь экран и своего размера не меняет — при открытии и закрытии устройству нечего
  перерисовывать заново (раньше она сжималась и вырастала, и в тяжёлых чатах с фото и видео отставала от клавиатуры).
  Над клавиатурой встаёт только низ (поле ввода, строка ответа) — отступом страницы; переписка под ним продолжается. */
  body.kb-open #chat-app .chat-content-inner{padding-bottom:var(--chat-lift)}
  body.kb-open #chat-app .chat-messages{margin-bottom:calc(-1 * var(--chat-dock,62px) - var(--chat-lift));padding-bottom:calc(var(--chat-dock,62px) + var(--chat-lift) + var(--chat-gap))}
  #chat-app>.chat-list-panel,#chat-app>.chat-content{flex:0 0 100%;width:100%;min-width:100%;box-sizing:border-box;scroll-snap-align:start;scroll-snap-stop:always}
  #chat-app>.chat-list-panel{display:flex!important;position:relative}
  #chat-app>.chat-content{display:block!important;position:relative;overflow:hidden}
  /* Фон и подкраска — часть страницы чата (absolute), а не экрана (fixed): при свайпе «назад» пальцем они
     уезжают вместе с перепиской, а не остаются висеть над списком. По бокам не выходят за страницу. */
  #chat-app .chat-content .chat-photo{position:absolute;z-index:-1}
  #chat-app .chat-content .chat-tints,#chat-app .chat-content::before{position:absolute;inset:0}
  #chat-app .chat-content::after{position:absolute;z-index:3}
  #chat-app .chat-content-inner{position:relative;z-index:0}
  #chat-app .chat-list-panel .chat-tabs,#chat-app .chat-pager-foot::before{position:absolute}
  /* Шапка переписки. */
  #chat-app .chat-content>.chat-top-strip{display:flex!important;position:absolute;left:0;right:0;top:calc(env(safe-area-inset-top) + 26px);height:44px;min-height:44px;
    margin:0;padding:0 16px;z-index:4;align-items:center;gap:0;background:none!important;box-shadow:none!important;border:0;border-radius:0;pointer-events:none}
  #chat-app .chat-content>.chat-top-strip>*{pointer-events:auto}
  #chat-app .chat-content>.chat-top-strip :is(#chat-create-strip,#chat-wide,#user-button,#chat-settings){display:none!important}
  #chat-app .chat-content>.chat-top-strip #chat-back{display:inline-flex;width:44px;height:44px;min-height:44px;padding:0;border-radius:50%;flex:none}
  #chat-app .chat-content>.chat-top-strip #chat-back svg{width:19px;height:19px}
  #chat-app .chat-content>.chat-top-strip .chat-peer-avatar{margin-left:auto}
  #chat-app .chat-content>.chat-top-strip .chat-peer-head{position:absolute;left:50%;top:0;transform:translateX(-50%);max-width:calc(100% - 132px)}
  #chat-app .chat-content>.chat-top-strip .chat-peer-key{height:44px;min-height:44px;padding:0 22px;font-size:16px}
  #chat-app .chat-content>.chat-top-strip .chat-title:not(.peer){position:absolute;left:50%;top:0;transform:translateX(-50%);max-width:calc(100% - 132px);
    display:flex;flex-direction:column;justify-content:center;height:44px;padding:0 22px;border:1px solid #e7e7ec;border-radius:999px;background:linear-gradient(#ffffff,#f5f5fa);
    box-shadow:0 1px 0 #f1f1f6,inset 0 1px 0 #fff;font-size:16px;line-height:19px;pointer-events:auto;box-sizing:border-box}
  #chat-app .chat-content>.chat-top-strip .chat-title:empty{display:none}
  :root[data-theme=dark] #chat-app .chat-content>.chat-top-strip .chat-title:not(.peer){border-color:#3a3a3c;background:linear-gradient(#2c2c2e,#242426);box-shadow:none;color:#f2f2f7}
}
/* Открыта переписка (и пока её листают назад) — её страница выше общей шапки со своей дымкой; шапка списка
   проявляется сквозь прозрачную страницу списка. В списке общая шапка снова сверху и нажимается. */
@media(max-width:650px){
  /* Общая шапка в чате — без своей подложки (у каждой страницы своя дымка), кнопки списка — на странице списка. */
  body.chat-pager .app-header::before{display:none}
  #chat-app .chat-pager-head{top:0;z-index:6;height:calc(90px + env(safe-area-inset-top));box-sizing:border-box;
    padding:calc(26px + env(safe-area-inset-top)) 16px 0;display:flex;align-items:flex-start;gap:11px;pointer-events:none}
  #chat-app .chat-pager-head>*{pointer-events:auto}
  #chat-app .chat-pager-head :is(.nav-key,.settings-key){display:inline-flex;align-items:center;justify-content:center;width:44px;height:44px;min-height:44px;padding:0;flex:none}
  #chat-app .chat-pager-head :is(.nav-key,.settings-key) svg{width:20px;height:20px;color:#242429;stroke-width:2.2}
  #chat-app .chat-pager-head .header-spacer{flex:1}
  #chat-app .chat-pager-head #app-switch{position:absolute;left:50%;transform:translateX(-50%);top:calc(26px + env(safe-area-inset-top))}
  #chat-app .chat-pager-head #app-switch:active,#chat-app .chat-pager-head #app-switch[aria-expanded=true]{transform:translateX(-50%) translateY(1px)}
  :root[data-theme=dark] #chat-app .chat-pager-head :is(.nav-key,.settings-key) svg{color:#f2f2f7}
}
/* Телефон: у каждого списка («Недавние», «Личные», «Группы») своя вертикальная прокрутка над нижними вкладками
   (раскладка списков — swipe.css). */
@media(max-width:650px){
  #chat-app #chat-list{padding:0!important}
  #chat-app #chat-list>.chat-section{box-sizing:border-box;overflow-y:auto;overflow-x:hidden;padding-bottom:calc(var(--tabs-h,64px) + var(--tabs-gap,12px) + 16px)}
  #chat-app #chat-list>.chat-section:not([data-kind=recent]):not([data-kind=direct]):not([data-kind=groups]){display:none!important}
}
/* Обёртка сообщения для свайпа-ответа: само сообщение и значок ответа у правого края (виден только при свайпе). */
#chat-app .chat-swipe{position:relative;display:flex;flex-direction:column;width:100%;flex:none}
#chat-app .chat-swipe-slot{display:none}
@media(max-width:650px){
  /* Жесты отдаём телефону: запреты по направлениям (touch-action) мешали бы листанию. */
  #chat-app .chat-messages,#chat-app .chat-list-panel,#chat-app .chat-message{touch-action:auto}
  #chat-app .chat-swipe-slot{display:flex;position:absolute;right:2px;top:0;bottom:0;align-items:center;pointer-events:none}
  #chat-app .chat-swipe-slot .chat-swipe-reply{position:static;margin:0;opacity:0;transition:background .15s ease}
  #chat-app .chat-message{will-change:auto}
  /* Края листания не пружинят (иначе свайп влево по переписке тянул бы всё окно). */
  #chat-app{overscroll-behavior-x:none}
}
/* Страница списка — всегда своего цвета приложения (белый / тёмный / чёрный), а не цвета фона открытого чата:
   иначе при листании назад на список «перетекают» крашеные дымки чата. */
:root{--list-base:#ffffff}
:root[data-theme=dark]{--list-base:#1c1c1e}
:root[data-theme=dark][data-oled]{--list-base:#000000}
@media(max-width:650px){
  #chat-app .chat-pager-head{background:linear-gradient(var(--list-base),color-mix(in srgb,var(--list-base) 85%,transparent) 55%,transparent)}
  #chat-app .chat-pager-foot::before,#chat-app .chat-pager-head{--status-color-bottom:var(--list-base);--status-color:var(--list-base)}
  #chat-app .chat-pager-head #app-switch{pointer-events:none}
  #chat-app .chat-pager-head #app-switch svg{display:none}
}
@media(max-width:650px){#chat-app>.chat-list-panel{background:var(--list-base)}}

/* Вложение с подписью: время и галочки — просто в строке подписи, без плашки (и в тёмной теме). */
#chat-app .chat-message .chat-photo-bubble.with-caption>.chat-meta,
:root[data-theme=dark] #chat-app .chat-message .chat-photo-bubble.with-caption>.chat-meta,
:root[data-theme=dark][data-oled] #chat-app .chat-message .chat-photo-bubble.with-caption>.chat-meta{background:none;box-shadow:none;-webkit-backdrop-filter:none;backdrop-filter:none;padding:0}
:root[data-theme=dark] #chat-app .chat-message .chat-photo-bubble.with-caption>.chat-meta :is(time,.chat-read-status,.chat-edited){color:#a1a1a8}
/* Альбом: сетка плиток, как в Телеграме (раскладка зависит от количества). */
#chat-app .chat-album{display:grid;grid-template-columns:repeat(6,1fr);gap:2px;width:min(320px,72vw);border-radius:15px;overflow:hidden}
/* Высота плитки — переменная --tile: по ней же стоят плитки ещё не отправленного альбома (.chat-upload ниже), иначе
   сетка в момент доставки меняла высоту. */
#chat-app .chat-album>*{grid-column:span 3;position:relative;min-width:0;height:var(--tile,150px);margin:0;border-radius:0}
#chat-app .chat-album>:is(.chat-photo-button,.chat-video-button){display:block;padding:0;border:0;background:#0000000d}
#chat-app .chat-album :is(img,canvas){display:block;width:100%!important;height:100%!important;max-width:none!important;max-height:none!important;min-width:0!important;min-height:0!important;object-fit:cover;border-radius:0!important}
#chat-app .chat-album[data-count="3"]>:first-child{grid-column:span 6;--tile:190px}
#chat-app .chat-album[data-count="3"]>:not(:first-child){--tile:120px}
#chat-app .chat-album[data-count="4"]>*{--tile:130px}
#chat-app .chat-album[data-count="5"]>:nth-child(n+3),#chat-app .chat-album[data-count="6"]>*,
#chat-app .chat-album:is([data-count="7"],[data-count="8"],[data-count="9"],[data-count="10"])>:nth-child(n+3){grid-column:span 2;--tile:100px}
/* Альбом файлов — просто список карточек. */
#chat-app .chat-album.files{display:flex;flex-direction:column;gap:10px;width:auto;border-radius:0;overflow:visible}
#chat-app .chat-album.files>*{height:auto}
#chat-app .chat-album-bubble.chat-photo-bubble .chat-album{border-radius:15px 15px 15px 3px}
#chat-app .chat-message.own .chat-album-bubble.chat-photo-bubble .chat-album{border-radius:15px 15px 3px 15px}
#chat-app .chat-album-bubble.with-caption .chat-album{border-bottom-left-radius:4px;border-bottom-right-radius:4px}
/* «+» у заголовка «Группы» — только на компьютере (на телефоне заголовков разделов нет). */
@media(max-width:650px){#chat-app .chat-section-add{display:none!important}}
/* Телефон: «+ создать группу» — часть страницы «Группы», прилипает к её низу над вкладками. */
@media(max-width:650px){
  #chat-app .chat-section .chat-list-header{display:flex!important;position:sticky;left:auto;right:auto;justify-content:center;padding:10px 0 12px;z-index:2;pointer-events:none}
  #chat-app .chat-section .chat-list-header>*{pointer-events:auto}
}
@media(max-width:650px){
  #chat-app #chat-list>.chat-section{display:flex!important;flex-direction:column}
  #chat-app #chat-list>.chat-section>.chat-list-key+.chat-list-key{margin-top:8px}
  #chat-app .chat-section .chat-list-header{order:99;margin-top:auto}
}
/* …и стоит ровно там же, где раньше: нижним краем — на верхнем краю нижних вкладок. */
@media(max-width:650px){#chat-app .chat-section .chat-list-header{margin-bottom:calc(-1 * (var(--tabs-h,64px) + var(--tabs-gap,12px) + 16px + 62px));bottom:-78px}
  /* Прокрутка до конца: последняя группа остаётся над кнопкой, как раньше. */
  #chat-app #chat-list>.chat-section[data-kind=groups]{padding-bottom:calc(var(--tabs-h,64px) + var(--tabs-gap,12px) + 16px + 62px)}}
@media(max-width:650px){#chat-app .chat-section .chat-list-header{padding-top:26px}}
/* Пожелания: «на проверке», «на паузе», «отклонено»; раздел «Проверка» у администратора. */
#chat-app .chat-task-chip.review{background:#8e8e9322;color:#6e6e73}
#chat-app .chat-task-chip.paused{background:#8e8e9330;color:#5c5c61}
#chat-app .chat-task-chip.rejected{background:#ff3b301f;color:#c4302b}
#chat-app .chat-message .chat-task-chip.rejected~.chat-task-note{color:#c4302b}
:root[data-theme=dark] #chat-app .chat-task-chip.rejected{color:#ff6961}
/* Номер пожелания в чате с ИИ-агентом — кнопка-ссылка: окно с самим пожеланием. */
#chat-app .chat-wish-link{display:inline;padding:0 2px;margin:0 -1px;border-radius:5px;color:#1f63d6;font-weight:600;cursor:pointer;-webkit-tap-highlight-color:transparent;text-decoration:underline;text-decoration-color:#1f63d655;text-underline-offset:2px}
#chat-app .chat-wish-link:active{background:#247bff24}
:root[data-theme=dark] #chat-app .chat-wish-link{color:#6aa5ff;text-decoration-color:#6aa5ff66}


/* Телефон: список и переписка — две страницы ОДНОЙ встроенной прокрутки (листает сам телефон). «Недавние», «Личные»
   и «Группы» — отдельные экраны: их списки лежат друг над другом на странице списка и сменяются на месте, ряд
   страниц при этом не меняется. Шапка, нижние вкладки и дымка стоят на странице списка и уезжают вместе с ней. */
@media(max-width:650px){
  #chat-app{overflow-x:auto!important;scroll-timeline:--chat-pager x}
  #chat-app>.chat-list-panel{padding-left:0!important;padding-right:0!important;overflow:clip!important;border-radius:0!important}
  /* Страница списка — во весь экран, без скруглений: в углах просвечивала подложка окна (при листании — в цвете чата). */
  #chat-app #chat-list{display:grid!important;grid-template:minmax(0,1fr)/minmax(0,1fr);overflow:hidden!important;width:100%}
  /* Скрытые списки остаются на месте со своей прокруткой:
     вернулись на вкладку — список там же, где его оставили. Смену ведёт chatTabSlide (код чата): старый список уезжает, новый въезжает. */
  #chat-app #chat-list>.chat-section{grid-area:1/1;min-width:0;padding-left:14px!important;padding-right:14px!important;
    visibility:hidden}
  #chat-app[data-list-tab=recent] #chat-list>.chat-section[data-kind=recent],#chat-app[data-list-tab=direct] #chat-list>.chat-section[data-kind=direct],
  #chat-app[data-list-tab=groups] #chat-list>.chat-section[data-kind=groups]{visibility:visible}
  #chat-app.list-only>.chat-content{display:none!important}
  /* Шапка — первой в колонке панели и не занимает высоту; вкладки и дымка отсчитываются от якоря нулевой высоты
     у нижнего края панели. */
  #chat-app .chat-pager-head{position:sticky;left:0;flex:none;align-self:flex-start;width:var(--page-w,100vw);margin-bottom:calc(-90px - env(safe-area-inset-top))}
  #chat-app .chat-pager-foot{display:block;position:sticky;left:0;z-index:5;flex:none;align-self:flex-start;width:var(--page-w,100vw);height:0}
}

/* Перетаскивание файлов в чат (компьютер): мягкая подсказка поверх переписки, появляется и гаснет CSS-переходом. */
#chat-app .chat-drop{position:absolute;inset:12px;z-index:20;display:flex;align-items:center;justify-content:center;border:2px dashed #247bff88;border-radius:22px;
  background:#f8f8fdd9;opacity:0;visibility:hidden;pointer-events:none;transition:opacity .15s ease,visibility 0s .15s}
/* Размытие фона — только пока подсказка показана: иначе невидимый слой с размытием лежал поверх всей переписки и
   пересчитывался при каждой её прокрутке. */
#chat-app .chat-drop.on{opacity:1;visibility:visible;backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px);transition:opacity .15s ease}
#chat-app .chat-drop span{padding:10px 18px;border-radius:999px;background:#fff;box-shadow:0 6px 18px #3131361f;font-size:15px;font-weight:600;color:#247bff}
:root[data-theme=dark] #chat-app .chat-drop{background:#1c1c1ed9}
:root[data-theme=dark] #chat-app .chat-drop span{background:#2c2c2e}
/* Ссылка в сообщении. */
#chat-app .chat-link{color:#1f63d6;text-decoration:underline;text-decoration-color:#1f63d655;text-underline-offset:2px;overflow-wrap:anywhere;-webkit-tap-highlight-color:transparent}
#chat-app .chat-link:active{background:#247bff24;border-radius:4px}
:root[data-theme=dark] #chat-app .chat-link{color:#6aa5ff;text-decoration-color:#6aa5ff66}
/* Карточка предпросмотра ссылки (как в Телеграме): полоска слева, сайт, заголовок, описание, картинка. */
#chat-app .chat-link-card{display:flex;flex-direction:column;gap:2px;margin:6px 0 2px;padding:6px 10px 8px;border-left:3px solid #247bff;border-radius:8px;
  background:#247bff12;color:inherit;text-decoration:none;max-width:340px;-webkit-tap-highlight-color:transparent;overflow:hidden}
#chat-app .chat-link-card:active{background:#247bff22}
#chat-app .chat-link-site{font-size:13px;font-weight:600;color:#1f63d6;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
#chat-app .chat-message .chat-link-title{padding:0;margin:0;color:inherit;font-size:14px;font-weight:600;line-height:1.3;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
#chat-app .chat-link-desc{font-size:13px;line-height:1.35;color:#5c5c61;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}
#chat-app .chat-link-card img{display:block;width:100%;max-height:200px;object-fit:cover;margin-top:6px;border-radius:6px;background:#8e8e9318}
:root[data-theme=dark] #chat-app .chat-link-card{background:#6aa5ff18;border-left-color:#6aa5ff}
:root[data-theme=dark] #chat-app .chat-link-site{color:#6aa5ff}
:root[data-theme=dark] #chat-app .chat-link-desc{color:#a1a1a8}

/* Просмотр фото/видео: закрыть свайпом вниз или вверх (прокрутка из трёх страниц, средняя — снимок). */
#chat-app .chat-photo-preview{background:transparent;timeline-scope:--viewer}
#chat-app .chat-photo-preview::backdrop{background:transparent}
#chat-app .chat-viewer-dim{inset:0;animation:chat-viewer-dim linear both;animation-timeline:--viewer}
@keyframes chat-viewer-dim{0%{opacity:0}50%{opacity:1}100%{opacity:0}}
#chat-app .chat-viewer-scroll{position:absolute;inset:0;overflow-x:hidden;overflow-y:auto;scroll-snap-type:y mandatory;scrollbar-width:none;overscroll-behavior:contain;scroll-timeline:--viewer y}
#chat-app .chat-viewer-scroll::-webkit-scrollbar{display:none}
#chat-app .chat-viewer-scroll>*{height:100%;scroll-snap-align:start;scroll-snap-stop:always}
#chat-app .chat-viewer-scroll>.chat-photo-preview-inner{height:100%;scroll-snap-align:none}
#chat-app .chat-viewer-scroll>.chat-viewer-mark{display:block;height:1px;margin-bottom:-1px;pointer-events:none}
/* Компьютер: колесо мыши не должно закрывать снимок — там закрывают кнопкой или Esc. */
@media(hover:hover) and (pointer:fine){#chat-app .chat-viewer-scroll{overflow-y:hidden}}
/* Кольцо загрузки с процентами — в центре миниатюры (у файла — слева от имени); нажал — загрузка отменяется.
   Заполнение — CSS-переход по длине дуги (рисует браузер). На компьютере при наведении проценты сменяются крестиком. */
#chat-app .chat-upload{position:relative}
#chat-app .chat-upload-dark{display:block;width:min(240px,100%);height:165px;border-radius:12px;background:#1c1c1e}
#chat-app .chat-album .chat-upload,#chat-app .chat-album .chat-upload-dark{width:100%;height:var(--tile,150px);border-radius:0}
#chat-app .chat-album .chat-upload img{height:100%}
#chat-app .chat-ring{--p:0;position:absolute;left:50%;top:50%;width:52px;height:52px;margin:-26px 0 0 -26px;padding:0;border:0;border-radius:50%;
  background:#00000059;backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px);color:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;-webkit-tap-highlight-color:transparent}
#chat-app .chat-ring svg{position:absolute;inset:0;width:100%;height:100%;fill:none;transform:rotate(-90deg)}
#chat-app .chat-ring .track{stroke:#ffffff40;stroke-width:2.5}
#chat-app .chat-ring .fill{stroke:#fff;stroke-width:2.5;stroke-linecap:round;stroke-dasharray:calc(var(--p) * 100) 100;transition:stroke-dasharray var(--t,.25s) cubic-bezier(.2,.6,.25,1)}
/* Отправлено: кольцо доезжает до конца и гаснет (outbox.js убирает его следом). */
#chat-app .chat-ring.done{opacity:0;pointer-events:none;transition:opacity .2s ease .14s}
#chat-app .chat-ring .x{stroke:#fff;stroke-width:2.2;stroke-linecap:round;opacity:0;transform:rotate(90deg);transform-origin:18px 18px;transition:opacity .12s ease}
#chat-app .chat-ring b{position:relative;font-size:12px;font-weight:700;letter-spacing:-.2px;transition:opacity .12s ease}
#chat-app .chat-ring:active .x{opacity:1}
#chat-app .chat-ring:active b{opacity:0}
@media(hover:hover) and (pointer:fine){#chat-app .chat-ring:hover .x{opacity:1}#chat-app .chat-ring:hover b{opacity:0}}
/* Файл (без миниатюры): кольцо слева от имени, в цвет приложения. */
#chat-app .chat-upload:not(:has(img)):not(.chat-upload-dark){display:flex;flex-direction:row;align-items:center;gap:10px;min-height:52px;padding-left:62px}
#chat-app .chat-upload:not(:has(img)):not(.chat-upload-dark) .chat-ring{left:0;margin-left:0;background:#247bff}
#chat-app .chat-album.files .chat-upload{height:auto}
/* Масштаб фото: снимок масштабируется и двигается через transform; пока приближено — свайп-закрытие выключено. */
#chat-app .chat-zoom{position:absolute;inset:0;overflow:hidden;touch-action:pan-x pan-y;overscroll-behavior:contain;scrollbar-width:none}
/* Приближенный снимок двигает сам просмотрщик (transform) — встроенные жесты браузера на нём выключены. */
#chat-app .chat-zoom.zoomed{touch-action:none;cursor:grab}
#chat-app .chat-photo-preview-actions .round-key{touch-action:manipulation}
#chat-app .chat-photo-preview .chat-photo-preview-actions{transition:opacity .15s ease}
#chat-app .chat-zoom img,#chat-app .chat-zoom canvas{transform-origin:0 0}
#chat-app .chat-zoom.moving img,#chat-app .chat-zoom.moving canvas{will-change:transform}
#chat-app .chat-zoom::-webkit-scrollbar{display:none}
#chat-app .chat-zoom-stage{display:grid;place-items:center;width:100%;height:100%;box-sizing:border-box;padding:64px 24px 90px}
#chat-app .chat-zoom img{display:block;max-width:100%;max-height:100%;min-width:0;min-height:0;object-fit:contain;user-select:none;-webkit-user-drag:none}
#chat-app .chat-photo-preview.zoomed .chat-viewer-scroll{overflow-y:hidden}
#chat-app .chat-photo-preview.zoomed .chat-viewer-dim{animation:none;opacity:1}
/* Альбомы и готовые наборы листает встроенная горизонтальная прокрутка. */
#chat-app .chat-viewer-pages{position:absolute;inset:0;display:flex;overflow-x:auto;overflow-y:hidden;scroll-snap-type:x mandatory;scrollbar-width:none;overscroll-behavior-x:contain}
#chat-app .chat-viewer-pages::-webkit-scrollbar{display:none}
#chat-app .chat-viewer-page{position:relative;display:flex;align-items:center;justify-content:center;flex:0 0 100%;min-width:0;height:100%;box-sizing:border-box;padding:64px 24px 90px;scroll-snap-align:start;scroll-snap-stop:always}
#chat-app .chat-photo-preview-actions :is(.chat-viewer-prev,.chat-viewer-next){top:50%;margin-top:-21px}
#chat-app .chat-photo-preview-actions .chat-viewer-next{left:auto;right:16px}
#chat-app .chat-photo-preview.zoomed .chat-viewer-pages{overflow-x:hidden}
#chat-app .chat-viewer-page>video{border-radius:20px;box-shadow:0 18px 50px #0000004d}
#chat-app .chat-photo-preview-actions .chat-viewer-source{position:absolute;left:0;right:0;width:max-content;max-width:calc(100% - 32px);margin-inline:auto;bottom:calc(20px + env(safe-area-inset-bottom));pointer-events:auto;white-space:nowrap;touch-action:manipulation}
#chat-app .chat-viewer-file{display:grid;justify-items:center;gap:20px;max-width:100%;text-align:center;overflow-wrap:anywhere}
#chat-app .chat-viewer-file>span>svg{width:80px;height:80px}
#chat-app .chat-viewer-file audio{max-width:100%}
@media(max-width:650px),(pointer:coarse){#chat-app .chat-photo-preview-actions :is(.chat-viewer-prev,.chat-viewer-next){display:none}}
/* Карточка ссылки появляется плавно (переход при появлении — рисует браузер). */
#chat-app .chat-link-card{transition:opacity .35s ease,transform .35s cubic-bezier(.16,1,.3,1)}
@starting-style{#chat-app .chat-link-card{opacity:0;transform:translateY(6px) scale(.98)}}
/* Режим выбора сообщений: панель снизу и кружки выбора проявляются, а не возникают рывком. */
#chat-app.selecting .chat-select-bar{transition:opacity .22s ease,transform .32s cubic-bezier(.16,1,.3,1)}
@starting-style{#chat-app.selecting .chat-select-bar{opacity:0;transform:translateY(8px)}}
#chat-app.selecting .chat-message[data-id]::after{transition:opacity .2s ease,transform .25s cubic-bezier(.16,1,.3,1),background .15s,border-color .15s}
@starting-style{#chat-app.selecting .chat-message[data-id]::after{opacity:0;transform:scale(.6)}}
/* Альбом с подписью: пузырь по ширине сетки (раньше подпись ограничивала пузырь 300 точками, и сетка вылезала вправо). */
#chat-app .chat-bubble.chat-album-bubble.chat-photo-bubble.with-caption{max-width:calc(min(320px, 72vw) + 4px)}
/* Мелкие появления: счётчики непрочитанных и реакции «выскакивают», галочки меняют цвет плавно. */
#chat-app .unread-badge{transition:transform .3s cubic-bezier(.16,1,.3,1),opacity .2s ease}
@starting-style{#chat-app .unread-badge{transform:scale(.4);opacity:0}}
#chat-app .chat-reactions>button{transition:transform .3s cubic-bezier(.16,1,.3,1),opacity .2s ease,background .15s ease}
@starting-style{#chat-app .chat-reactions>button{transform:scale(.5);opacity:0}}
#chat-app .chat-read-status{transition:color .25s ease}
/* Компьютер, «на всё окно»: переписка плавно расширяется, список уезжает (View Transitions морфит их размеры). */
@media(min-width:651px){#chat-app .chat-content{view-transition-name:chat-content}#chat-app .chat-list-panel{view-transition-name:chat-list}}
::view-transition-group(chat-content),::view-transition-group(chat-list){animation-duration:.38s;animation-timing-function:cubic-bezier(.16,1,.3,1)}
#chat-app .chat-photo-button img{transition:opacity .3s ease}
#chat-app .chat-photo-button img.chat-img-pending{opacity:0}

/* Поиск в открытом чате: плашка сверху под шапкой. */
#chat-app .chat-find-bar{position:absolute;left:12px;right:12px;top:calc(var(--top-h,70px) + 4px);z-index:8;display:flex;align-items:center;gap:6px;padding:5px;
  border:1px solid #e7e7ec;border-radius:999px;background:#fffffff2;backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);box-shadow:0 8px 24px #37373c1f}
#chat-app .chat-find-bar .round-key{flex:none;width:36px;height:36px;min-height:36px}
#chat-app .chat-find-input{flex:1;min-width:0;border:0;background:none;outline:none;font:inherit;font-size:16px;color:inherit;padding:0 4px}
#chat-app .chat-find-count{flex:none;font-size:13px;color:#8c8c91;white-space:nowrap;padding:0 4px}
#chat-app .chat-find-bar .round-key:disabled{opacity:.35}
@media(min-width:651px){#chat-app .chat-find-bar{top:72px;max-width:520px;margin:0 auto}}
:root[data-theme=dark] #chat-app .chat-find-bar{background:#2c2c2ef2;border-color:#3a3a3c}
::highlight(chat-find){background:#ffd60a66;color:inherit}
::highlight(chat-find-now){background:#ff9f0a;color:#000}
/* Поиск по перепискам — поле над списком; пока идёт поиск, вместо списка — найденные сообщения. */
#chat-app .chat-search{display:flex;align-items:center;gap:8px;margin:0 0 10px}
#chat-app .chat-search-field{flex:1;display:flex;align-items:center;gap:8px;min-height:40px;padding:0 14px;border:1px solid #e7e7ec;border-radius:999px;background:#fff;color:#8c8c91}
#chat-app .chat-search-field svg{width:17px;height:17px;flex:none}
#chat-app .chat-search-field input{flex:1;min-width:0;border:0;outline:none;background:none;font:inherit;font-size:16px;color:#242429}
#chat-app .chat-search-cancel{display:none;border:0;background:none;color:#247bff;font:inherit;font-size:15px;padding:0 4px;cursor:pointer}
#chat-app.searching-all .chat-search-cancel{display:block}
#chat-app.search-results .chat-list-key:not(.chat-search-hit),#chat-app.search-results .chat-section-empty:not(.chat-search-empty),
#chat-app.search-results .chat-section:not([data-kind=direct]) .chat-list-section,#chat-app.search-results .chat-list-header{display:none!important}
#chat-app .chat-search-results{display:contents}
#chat-app .chat-search-hit .chat-list-top{display:flex;justify-content:space-between;gap:8px;width:100%}
#chat-app .chat-search-hit time{font-size:12px;color:#8c8c91;flex:none}
#chat-app .chat-find-snippet{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;font-size:13px;color:#6e6e73;text-align:left}
#chat-app .chat-find-snippet mark{background:#ffd60a66;color:inherit;border-radius:3px;padding:0 1px}
#chat-app .chat-search-hit{animation:sheet-rise .3s cubic-bezier(.16,1,.3,1)}
:root[data-theme=dark] #chat-app .chat-search-field{background:#1c1c1e;border-color:#3a3a3c}
:root[data-theme=dark] #chat-app .chat-search-field input{color:#f2f2f7}
:root[data-theme=dark] #chat-app .chat-find-snippet{color:#a1a1a8}
#chat-app .chat-find-bar{transition:opacity .2s ease,transform .3s cubic-bezier(.16,1,.3,1),display .2s allow-discrete}
#chat-app .chat-find-bar[hidden]{opacity:0;transform:translateY(-8px)}
@starting-style{#chat-app .chat-find-bar:not([hidden]){opacity:0;transform:translateY(-8px)}}
#chat-app .chat-search{width:100%;min-width:0;box-sizing:border-box}
#chat-app .chat-search-field{min-width:0;box-sizing:border-box}
@media(min-width:651px){#chat-app #chat-list{overflow-x:hidden}}
#chat-app .chat-search-empty{display:block!important;margin:40px 20px;text-align:center;font-size:15px;color:#8c8c91}

/* Стикеры, как в Telegram: кнопка в поле ввода, панель наборов над полем, стикер в переписке — без пузыря. */
/* Кнопка стикеров — просто значок в поле, без капсулы (как смайлы на компьютере), и на телефоне тоже. */
#chat-app .chat-input-wrap .chat-sticker-key{flex:none;border:0;background:none;box-shadow:none;width:32px;height:32px;min-height:32px;margin:3px 0;padding:0}
#chat-app .chat-input-wrap .chat-sticker-key svg{width:21px;height:21px;color:#949499;transition:color .15s ease}
/* Наведение — только там, где есть мышь: на iPhone оно «залипает» после касания, и кнопка Fio (у неё тот же класс)
   выглядела включённой, как её ни нажимай. */
#chat-app .chat-input-wrap .chat-sticker-key[aria-expanded=true] svg{color:#242429}
@media(hover:hover){#chat-app .chat-input-wrap .chat-sticker-key:hover svg{color:#242429}}
#chat-app .chat-input-wrap .chat-sticker-key:active,#chat-app .chat-input-wrap .chat-sticker-key[aria-expanded=true]{transform:none;background:none;box-shadow:none}
:root[data-theme=dark] #chat-app .chat-input-wrap .chat-sticker-key[aria-expanded=true] svg{color:#f2f2f7}
@media(hover:hover){:root[data-theme=dark] #chat-app .chat-input-wrap .chat-sticker-key:hover svg{color:#f2f2f7}}
#chat-app .chat-live-wave:not([hidden])~.chat-sticker-key{display:none}
#chat-app .chat-fio-key[hidden],#chat-app .chat-input-wrap:has(.chat-live-wave:not([hidden])) .chat-fio-key{display:none}

/* Ответ Fio: его утверждённый контур вместо галочек, в том же месте у времени. */
#chat-app .chat-read-status.chat-fio-read svg,#chat-app .chat-list-key .chat-list-ticks.chat-fio-read svg{width:18px;height:18px;stroke-width:1.65;overflow:visible}

/* Fio слушает до повторного нажатия; состояние рисует обычный контур кнопки. */
#chat-app .chat-input-wrap .chat-fio-key[aria-pressed=true] svg{color:#242429}
#chat-app .chat-input-wrap .chat-fio-key[aria-pressed=true]{transform:translateY(1px);background:#9494991c;box-shadow:inset 0 0 0 1px #94949920}
#chat-app .chat-input-wrap .chat-fio-key{transition:transform .07s ease,background .18s ease,box-shadow .18s ease,opacity .2s ease,scale .2s ease}
/* Набран хотя бы один символ (.typed — voice-record.js) — кнопки стикеров и Fio тают, а их место сразу отходит тексту:
   ширина меняется разом, текст доезжает сдвигом (chatShift), значок гаснет на месте. Включённый Fio не прячется; пока он включён, стикеров нет и в
   пустом поле — разговор с Fio не начинается со стикера. Отступ -4px гасит промежуток между частями поля. */
#chat-app .chat-input-wrap .chat-sticker-key:not(.chat-fio-key){transition:opacity .2s ease,scale .2s ease}
#chat-app .chat-input-wrap.typed .chat-fio-key:not([aria-pressed=true]),#chat-app .chat-input-wrap.typed .chat-sticker-key:not(.chat-fio-key),
#chat-app .chat-input-wrap:has(.chat-fio-key[aria-pressed=true]:not([hidden])) .chat-sticker-key:not(.chat-fio-key){width:0;min-width:0;opacity:0;scale:.6;pointer-events:none}
#chat-app .chat-input-wrap.typed .chat-fio-key:not([aria-pressed=true]){margin-right:-4px}
#chat-app .chat-input-wrap.typed .chat-sticker-key:not(.chat-fio-key),#chat-app .chat-input-wrap:has(.chat-fio-key[aria-pressed=true]:not([hidden])) .chat-sticker-key:not(.chat-fio-key){margin-left:-4px}
:root[data-theme=dark] #chat-app .chat-input-wrap .chat-fio-key[aria-pressed=true] svg{color:#f2f2f7}

/* Fio думает: родная анимация перелива текста, без JS-кадров. */
#chat-app .chat-fio-thinking{display:block;line-height:20px}
#chat-app .chat-fio-thinking{color:#949499;background:linear-gradient(100deg,#949499 25%,#d9d9de 45%,#949499 65%);background-size:250% 100%;background-position:100% 0;background-clip:text;-webkit-background-clip:text;-webkit-text-fill-color:transparent;animation:chat-fio-thinking 2.4s linear infinite}
@keyframes chat-fio-thinking{to{background-position:-100% 0}}
@media(prefers-reduced-motion:reduce){#chat-app .chat-fio-thinking{animation:none;background:none;-webkit-text-fill-color:currentColor}}

#chat-app .fio-thinking-status[data-status]::after,#app-switch.chat-title-switch>span.fio-thinking-status[data-status]::after{background:linear-gradient(100deg,#8a8a8f 25%,#d9d9de 45%,#8a8a8f 65%);background-size:250% 100%;background-position:100% 0;background-clip:text;-webkit-background-clip:text;-webkit-text-fill-color:transparent;animation:chat-fio-thinking 2.4s linear infinite}
@media(prefers-reduced-motion:reduce){#chat-app .fio-thinking-status[data-status]::after,#app-switch.chat-title-switch>span.fio-thinking-status[data-status]::after{animation:none;background:none;-webkit-text-fill-color:currentColor}}

#chat-app .chat-stickers{--sticker-head-height:32px;position:absolute;left:var(--sticker-center,50%);bottom:calc(100% + 8px);translate:-50% 0;z-index:5;box-sizing:border-box;width:min(360px,calc(100vw - 24px));height:min(340px,55vh);max-height:min(340px,55vh);display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr);
  border:1px solid #e7e7ec;border-radius:20px;background:#fff;box-shadow:0 12px 30px #37373c26;overflow:hidden;transform-origin:var(--sticker-origin,50% 100%);
  opacity:0;transform:translate3d(0,0,0) scale(.8);pointer-events:none;will-change:transform,opacity;transition:opacity .22s cubic-bezier(.4,0,1,1),transform .22s cubic-bezier(.4,0,1,1)}
#chat-app .chat-stickers[hidden]{display:none;opacity:0;transform:translate3d(0,0,0) scale(.8)}
/* Выход ускоряется к исчезновению; вход замедляется к открытому положению.
   Одна ease-out кривая в обе стороны сжимала окно почти целиком за первые
   несколько кадров закрытия, пока opacity ещё оставалась высокой. */
#chat-app .chat-stickers.sticker-visible{opacity:1;transform:translate3d(0,0,0) scale(1);pointer-events:auto;transition-timing-function:ease,cubic-bezier(.2,.7,.2,1)}
#chat-app .chat-stickers[popover]{position:fixed;inset:auto;top:var(--sticker-top);left:var(--sticker-center);margin:0;padding:0}
#chat-app .chat-sticker-tabs{grid-column:1;grid-row:1;display:flex;gap:6px;padding:8px 8px 6px;overflow-x:auto;scrollbar-width:none;flex:none;border-bottom:1px solid #f0f0f5}
#chat-app .chat-sticker-tabs::-webkit-scrollbar{display:none}
/* Вкладка набора — его аватарка. */
#chat-app .chat-sticker-tab{flex:none;font-size:18px;font-weight:600}
#chat-app .chat-sticker-tab img{display:block;width:100%;height:100%;object-fit:contain;pointer-events:none}
#chat-app .chat-sticker-recent svg{display:block;width:26px;height:26px;margin:auto;color:#8e8e93;pointer-events:none}
#chat-app .chat-sticker-recent.active svg{color:inherit}
#chat-app .chat-sticker-tab.active{background:#e8e8ed;transform:translateY(1px);box-shadow:inset 0 1px 3px #37373c1c}
#chat-app .chat-sticker-head{grid-column:1;grid-row:2;align-self:start;z-index:2;display:flex;align-items:center;gap:8px;min-height:32px;padding:4px 8px 0 14px;pointer-events:none;background:none;font-size:13px;font-weight:600;color:#69696e}
#chat-app .chat-stickers:has(.chat-sticker-edit-key){--sticker-head-height:38.5px}
#chat-app .chat-sticker-head button{pointer-events:auto}
#chat-app .chat-sticker-head span{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.sticker-author{display:flex;gap:6px;flex:none;font-size:12px;font-weight:400;color:#8c8c91;white-space:nowrap}
.sticker-author b{font-weight:600;color:#69696e}
.sticker-sheet>.sticker-author{justify-content:center;margin:2px 0 4px}
#chat-app .chat-sticker-edit-key{display:inline-flex;align-items:center;justify-content:center;flex:none;width:34.5px;height:34.5px;min-height:34.5px;padding:0;border:0;background:none;box-shadow:none;color:inherit;cursor:pointer;transition:transform .07s ease}
#chat-app .chat-sticker-edit-key svg{width:18.4px;height:18.4px;pointer-events:none}
#chat-app .chat-sticker-edit-key:active{transform:translateY(1px)}
#chat-app .chat-sticker-edit-key:focus-visible{outline:2px solid currentColor;outline-offset:2px;border-radius:6px}
#chat-app .chat-sticker-tabs{align-items:center}
#chat-app .chat-sticker-tabs .round-key{flex:none;width:36px;height:36px;min-height:36px;padding:0}
#chat-app .chat-sticker-grid{grid-column:1;grid-row:2;min-height:0;display:grid;align-content:start;grid-template-columns:repeat(4,minmax(0,1fr));gap:4px;padding:calc(var(--sticker-head-height) + 8px) 8px 18px;overflow-y:auto;overscroll-behavior:contain}
#chat-app .chat-stickers:not(:has(.chat-sticker-head)) .chat-sticker-grid{padding-top:8px}
#chat-app .chat-sticker-choice{aspect-ratio:1;padding:6px;border:0;border-radius:14px;background:none;cursor:pointer}
#chat-app .chat-sticker-choice:active{transform:scale(.92)}
#chat-app .chat-sticker-choice img{width:100%;height:100%;object-fit:contain;pointer-events:none}
#chat-app .chat-sticker-grid .chat-sticker-choice img{transform:scale(1.15)}
#chat-app .chat-sticker-empty{grid-column:1/-1;margin:24px 0;text-align:center;font-size:14px;color:#8c8c91}
#chat-app .chat-sticker-bubble .chat-sticker-view{display:block;position:relative;overflow:hidden;width:160px;height:160px;max-width:100%}
#chat-app .chat-sticker-bubble .chat-sticker{display:block;position:absolute;left:0;top:0;width:100%;height:100%;object-fit:contain;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
#chat-app .chat-sticker-bubble .chat-sticker-view.fitted .chat-sticker{max-width:none;object-fit:fill}
:root[data-theme=dark] #chat-app .chat-stickers{border-color:#3a3a3c;background:#1c1c1e}
:root[data-theme=dark] #chat-app .chat-sticker-tabs{border-color:#2c2c2e}

/* Предпросмотр фото и видео — как всплывающие окна: мягкое затемнение с размытием вместо чёрного экрана,
   снимок со скруглением 20 и тенью, раскрывается из места нажатия и схлопывается туда же (transform/opacity). */
#chat-app .chat-photo-preview[open]{animation:none}
/* iOS рисует свою подложку у часов по цвету страницы и верхнего fixed-слоя.
   Просмотр тёмный и в светлой теме: его фон должен доходить до системной области. */
html:has(#chat-photo-preview[open]){background:#141417!important;color-scheme:dark;transition:none}
html:has(#chat-photo-preview[open]) body{background:#141417}
#chat-app .chat-photo-preview::backdrop{-webkit-backdrop-filter:none;backdrop-filter:none}
/* В полупрозрачном просмотре не должна просвечивать верхняя дымка переписки.
   Закрыли просмотр — родные подложки шапки чата возвращаются сами. */
html:has(#chat-photo-preview[open]) #chat-app .chat-blur-top,
html:has(#chat-photo-preview[open]) #chat-app .chat-content::after,
html:has(#chat-photo-preview[open]) #chat-app .chat-top-strip::before,
html:has(#chat-photo-preview[open]) .app-header::before{display:none}
/* Без размытия фона: его пришлось бы пересчитывать на весь экран в каждом кадре щипка — на iPhone масштаб шёл ступеньками. */
#chat-app .chat-viewer-dim{position:fixed;height:calc(var(--full-h,100dvh) / var(--zoom,1));background:#141417}
#chat-app .chat-zoom:not(.zoomed) img,#chat-app .chat-photo-preview canvas.chat-gif,#chat-app .chat-photo-preview-inner>video{border-radius:20px;box-shadow:0 18px 50px #0000004d}
#chat-app .chat-photo-preview .chat-photo-preview-inner{transform-origin:var(--ox,50%) var(--oy,50%);transition:transform .34s cubic-bezier(.2,.9,.3,1.05),opacity .22s ease}
@starting-style{#chat-app .chat-photo-preview[open] .chat-photo-preview-inner{transform:scale(.8);opacity:0}}
@starting-style{#chat-app .chat-photo-preview[open] .chat-viewer-dim{opacity:0}}
#chat-app .chat-photo-preview .chat-viewer-dim{transition:opacity .25s ease}
#chat-app .chat-photo-preview.closing .chat-photo-preview-inner{transform:scale(.8);opacity:0;transition-duration:.2s,.18s}

@media(prefers-reduced-motion:reduce){#chat-app .chat-photo-preview .chat-photo-preview-inner{transition:none}}
/* Телефон: фон чата стоит по высоте страницы без клавиатуры (--chat-page-h ставит код чата) и под клавиатурой не
   меняет масштаб — страница просто становится короче, фон обрезается снизу. */
@media(max-width:650px){
  #chat-app .chat-content .chat-photo{inset:-45px 0 auto;height:calc(var(--chat-page-h,100%) + 90px)}
  #chat-app .chat-content .chat-tints{inset:0 0 auto;height:var(--chat-page-h,100%)}
}
/* Телефон: пока переписка едет вместе с клавиатурой (kb-gliding ставит код чата), страница уже выглядит как карточка
   чата при открытой клавиатуре: под полем ввода — цвет полосы с часами со скруглёнными углами карточки (едет вместе
   с полем), у верха — такие же углы (проявляются). Смена раскладки в конце движения тогда не видна. */
#chat-app .chat-kb-top{display:none}
#chat-app .chat-blur{display:none}
@media(max-width:650px){
  #chat-app.kb-gliding :is(.chat-messages,.chat-reply-bar,.chat-composer){will-change:transform}
  #chat-app.kb-gliding .chat-composer::after{content:'';position:absolute;left:0;right:0;top:calc(100% - 22px);height:100vh;pointer-events:none;
    background:radial-gradient(circle at 100% 0,transparent 21.5px,var(--chat-tint,var(--status-color,#fff)) 22px) 0 0/22px 22px no-repeat,
      radial-gradient(circle at 0 0,transparent 21.5px,var(--chat-tint,var(--status-color,#fff)) 22px) 100% 0/22px 22px no-repeat,
      linear-gradient(var(--chat-tint,var(--status-color,#fff)),var(--chat-tint,var(--status-color,#fff))) 0 22px/100% 100% no-repeat}
  #chat-app.kb-gliding .chat-kb-top{display:block;position:absolute;left:0;right:0;top:0;height:22px;z-index:5;pointer-events:none;opacity:0;
    background:radial-gradient(circle at 100% 100%,transparent 21.5px,var(--chat-tint,var(--status-color,#fff)) 22px) 0 0/22px 22px no-repeat,
      radial-gradient(circle at 0 100%,transparent 21.5px,var(--chat-tint,var(--status-color,#fff)) 22px) 100% 0/22px 22px no-repeat}
}
/* Пока поле едет вместе с клавиатурой, системный курсор не следует за ним — скрыт до конца подъёма (viewport.js). */
#chat-app.caret-wait #chat-message{caret-color:transparent}

/* Окно набора стикеров (его открывают из панели стикеров; оно лежит вне #chat-app). */
.sticker-sheet{width:min(420px,calc(100vw - 24px))}
.sticker-sheet .pill-input{display:block;margin:0 auto;max-width:100%;text-align:center}
.sticker-edit-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:4px;max-height:min(46vh,380px);overflow-y:auto;overscroll-behavior:contain;margin:12px 0 4px}
.sticker-edit-grid .chat-sticker-choice{position:relative;aspect-ratio:1;padding:6px;border:0;border-radius:14px;background:none;cursor:pointer}
.sticker-edit-grid .chat-sticker-choice img{width:100%;height:100%;object-fit:contain;pointer-events:none}
:root[data-theme=dark] #chat-app .chat-sticker-tab.active{background:#2c2c2e}
/* Окно набора: поле и ряд эмодзи выбранного стикера, кольцо хода у стикера, который ещё загружается. */
.sticker-wait{position:absolute;left:50%;top:50%;width:26px;height:26px;margin:-13px 0 0 -13px;border-radius:50%;border:3px solid #247bff40;border-top-color:#247bff;animation:sticker-wait .8s linear infinite}
@keyframes sticker-wait{to{transform:rotate(360deg)}}
.sticker-edit-emoji{display:flex;flex-direction:column;align-items:center;gap:8px;margin:10px 0 2px}
.sticker-edit-emoji[hidden]{display:none}
.sticker-edit-emoji .pill-input{min-width:120px;font-size:20px}
.sticker-emoji-row{display:flex;gap:2px;max-width:100%;overflow-x:auto;scrollbar-width:none;padding:2px}
.sticker-emoji-row::-webkit-scrollbar{display:none}
.sticker-emoji{flex:none;width:38px;height:38px;padding:0;border:0;border-radius:50%;background:none;font-size:22px;cursor:pointer}
.sticker-emoji.chosen{background:#e8e8ed;box-shadow:inset 0 0 0 2px #247bff}
:root[data-theme=dark] .sticker-emoji.chosen{background:#2c2c2e}
/* Лента стикеров к набранному эмодзи — над полем ввода. */
#chat-app .chat-sticker-hints{position:absolute;left:12px;right:12px;bottom:calc(100% + 8px);z-index:4;display:flex;gap:4px;padding:6px;overflow-x:auto;scrollbar-width:none;
  border:1px solid #e7e7ec;border-radius:20px;background:#fff;box-shadow:0 12px 30px #37373c26}
#chat-app .chat-sticker-hints[hidden]{display:none}
#chat-app .chat-sticker-hints::-webkit-scrollbar{display:none}
#chat-app .chat-sticker-hints .chat-sticker-choice{flex:none;width:72px;height:72px}
:root[data-theme=dark] #chat-app .chat-sticker-hints{border-color:#3a3a3c;background:#1c1c1e}
/* Стикер в полёте — отдельный слой поверх окна (общий для конструктора и окна набора); выделен свечением по
   силуэту, как выбранный набор в панели. В окне набора выбранный стикер выделен так же, без квадрата. */
.sticker-ghost{position:absolute;inset:auto;margin:0;padding:0;border:0;background:none;overflow:visible;z-index:50;pointer-events:none}
.sticker-ghost[popover]{position:fixed}
.sticker-ghost img{display:block;width:100%;height:100%;object-fit:contain;-webkit-user-drag:none;filter:drop-shadow(0 0 1.5px #00000099) drop-shadow(0 0 4px #00000066)}
:root[data-theme=dark] .sticker-ghost img{filter:drop-shadow(0 0 1.5px #ffffffb3) drop-shadow(0 0 4px #ffffff80)}
/* Окно готового набора — в виде конструктора (его классы); здесь только своё: выбранный стикер — свечением по
   силуэту, аватарка набора — с точкой, эмодзи на подложке может быть несколько. */
dialog.sticker-set-edit .family-sticker-review-grid:focus{outline:none}
dialog.sticker-set-edit.family-sticker-review .family-sticker-review-tile.picked img{transform:none;filter:drop-shadow(0 0 1.5px #00000099) drop-shadow(0 0 4px #00000066)}
:root[data-theme=dark] dialog.sticker-set-edit .family-sticker-review-tile.picked img{filter:drop-shadow(0 0 1.5px #ffffffb3) drop-shadow(0 0 4px #ffffff80)}
dialog.sticker-set-edit .family-sticker-review-tile.cover::after{content:'';position:absolute;left:4px;top:4px;width:9px;height:9px;border-radius:50%;background:#247bff;box-shadow:0 0 0 2px #fff}
:root[data-theme=dark] dialog.sticker-set-edit .family-sticker-review-tile.cover::after{box-shadow:0 0 0 2px #1c1c1e}
dialog.sticker-set-edit .family-sticker-review-tile.pending img{opacity:.45}
dialog.sticker-set-edit .family-sticker-emoji{width:auto;min-width:26px;padding:0 5px;box-sizing:border-box;pointer-events:none}
dialog.sticker-set-edit .sticker-edit-emoji{margin:0}
dialog.sticker-set-edit .family-sticker-options{justify-content:center}
/* Окно по центру сдвинуто оболочкой вверх; с эмодзи выбранного стикера оно выше конструктора и ушло бы верхом за край. */
dialog.user-sheet.family-sticker-constructor.sticker-set-edit{max-height:min(var(--sticker-form-height),calc(100dvh / var(--zoom,1) - 132px))}
dialog.sticker-set-edit>.family-sticker-form{scrollbar-width:none}
dialog.sticker-set-edit>.family-sticker-form::-webkit-scrollbar{display:none}
dialog.sticker-set-edit .family-sticker-options[hidden]{display:none}
dialog.sticker-set-edit>.sheet-head .pill-input{justify-self:center;margin:0;max-width:100%;pointer-events:auto}
dialog.sticker-set-edit .family-sticker-review-tile.headless::before{content:'';position:absolute;right:4px;top:4px;width:9px;height:9px;border-radius:50%;background:#ff9500;box-shadow:0 0 0 2px #fff}
dialog.sticker-head-sheet .sticker-head-stage{position:relative;width:min(300px,calc(calc(100vw / var(--zoom, 1)) - 76px));margin:4px auto 18px;touch-action:none;-webkit-user-select:none;user-select:none;cursor:grab}
dialog.sticker-head-sheet .sticker-head-stage img{display:block;width:100%;height:100%;pointer-events:none}
dialog.sticker-head-sheet .sticker-head-ring{position:absolute;aspect-ratio:1;border-radius:50%;border:2px solid #fff;box-shadow:0 0 0 1.5px #000000b3,inset 0 0 0 1.5px #000000b3;pointer-events:none}
dialog.sticker-head-sheet .sticker-head-size{display:block;width:min(300px,calc(calc(100vw / var(--zoom, 1)) - 76px));margin:0 auto 18px;accent-color:#247bff}

/* Разметка в сообщениях: код, блок кода, цитата. */
#chat-app .chat-md-code{padding:1px 5px;border-radius:6px;background:#0000000f;font:13px/1.35 ui-monospace,SFMono-Regular,Menlo,monospace}
#chat-app .chat-md-pre{display:block;margin:4px 0;padding:8px 10px;border-radius:10px;background:#0000000f;font:13px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre;overflow-x:auto;max-width:100%;box-sizing:border-box}
#chat-app .chat-md-quote{display:block;margin:3px 0;padding:1px 0 1px 9px;border-left:3px solid #247bff;color:#4a4a50}
:root[data-theme=dark] #chat-app .chat-md-code,:root[data-theme=dark] #chat-app .chat-md-pre{background:#ffffff1a}
:root[data-theme=dark] #chat-app .chat-md-quote{color:#c7c7cc}
/* Отложенное сообщение (видит только автор) и окно выбора времени. */
#chat-app .chat-scheduled .chat-bubble{display:flex;flex-direction:column;align-items:flex-end;opacity:.8;border-style:dashed;border-color:#b9b9c0}
#chat-app .chat-scheduled .chat-message-text{align-self:flex-start}
#chat-app .chat-scheduled .chat-bubble>.chat-meta{position:static;display:inline-flex;align-items:center;margin:3px 0 0;float:none}
#chat-app .chat-later-mark{display:inline-flex;margin-right:3px;vertical-align:-2px}
#chat-app .chat-later-mark svg{width:13px;height:13px}
#chat-app .chat-later-file{display:block;font-weight:600}
.chat-later-row{display:flex;align-items:center;justify-content:center;gap:10px}
.chat-later-row .pill-input{width:auto!important;min-width:0}
.chat-later-row .round-key.pressed{transform:translateY(1px);background:#e8e8ed;box-shadow:inset 0 1px 3px #37373c26}
/* iPhone, режим «страница под часами»: фон чата — во весь экран, от часов до самого низа; ничего не красится —
   ни полоса у верха, ни дымка под шапкой, ни подложка под полем ввода, ни поля вокруг при открытой клавиатуре.
   Под шапкой и под полем ввода сообщения плавно размываются (.chat-blur). */
@media(max-width:650px){
  html.under-clock #chat-app .chat-content::after,html.under-clock #chat-app .chat-composer::before,
  html.under-clock #chat-app.kb-gliding .chat-composer::after,html.under-clock #chat-app.kb-gliding .chat-kb-top{display:none}
  /* Вместо растворения сообщений — размытие, нарастающее к краю (три слоя с разной силой, каждый гаснет маской). */
  html.under-clock #chat-app .chat-blur{display:block;position:absolute;left:0;right:0;z-index:1;pointer-events:none}
  html.under-clock #chat-app .chat-blur::before,html.under-clock #chat-app .chat-blur::after{content:'';position:absolute;inset:0}
  /* Кончается на пиксель выше низа плашки заголовка (она на 25 px выше --top-h). */
  html.under-clock #chat-app .chat-blur-top{top:0;height:calc(var(--top-h) - 26px);-webkit-backdrop-filter:blur(1.5px);backdrop-filter:blur(1.5px);
    -webkit-mask-image:linear-gradient(#000 70%,transparent);mask-image:linear-gradient(#000 70%,transparent)}
  html.under-clock #chat-app .chat-blur-top::before{-webkit-backdrop-filter:blur(5px);backdrop-filter:blur(5px);
    -webkit-mask-image:linear-gradient(#000 45%,transparent 85%);mask-image:linear-gradient(#000 45%,transparent 85%)}
  html.under-clock #chat-app .chat-blur-top::after{-webkit-backdrop-filter:blur(14px);backdrop-filter:blur(14px);
    -webkit-mask-image:linear-gradient(#000 20%,transparent 62%);mask-image:linear-gradient(#000 20%,transparent 62%)}
  /* Нижнее кончается у верха поля ввода (высота низа без верхнего отступа поля, 10px — composer.css): последнее
     сообщение над полем остаётся чётким. */
  html.under-clock #chat-app .chat-blur-bottom{bottom:0;height:calc(var(--chat-dock,62px) - 10px);-webkit-backdrop-filter:blur(1.5px);backdrop-filter:blur(1.5px);
    -webkit-mask-image:linear-gradient(to top,#000 60%,transparent);mask-image:linear-gradient(to top,#000 60%,transparent)}
  html.under-clock #chat-app .chat-blur-bottom::before{-webkit-backdrop-filter:blur(5px);backdrop-filter:blur(5px);
    -webkit-mask-image:linear-gradient(to top,#000 45%,transparent 85%);mask-image:linear-gradient(to top,#000 45%,transparent 85%)}
  html.under-clock #chat-app .chat-blur-bottom::after{-webkit-backdrop-filter:blur(14px);backdrop-filter:blur(14px);
    -webkit-mask-image:linear-gradient(to top,#000 20%,transparent 62%);mask-image:linear-gradient(to top,#000 20%,transparent 62%)}
  /* Клавиатура: страница чата остаётся во весь экран (фон продолжается под клавиатурой), поднимаются только
     переписка и поле ввода — без «карточки» со скруглением и цветных полей вокруг. */
  html.under-clock body.kb-open #chat-app .chat-content{isolation:auto;border-radius:0}
  html.under-clock body.kb-open #chat-app .chat-blur-bottom{bottom:var(--chat-lift)}
}
html.under-clock #chat-app .chat-photo-preview,html.under-clock #chat-app .chat-wall-preview{height:calc(var(--full-h,100lvh) / var(--zoom,1))}
/* Телефон: поле ввода и кнопки рядом приподняты над нижним краем экрана (над полоской «домой»); с клавиатурой —
   лежат прямо на ней. */
@media(max-width:650px){
  #chat-app{--chat-raise:max(12px,calc(env(safe-area-inset-bottom) - 10px))}
  #chat-app .chat-composer{padding-bottom:var(--chat-raise)}
  /* С клавиатурой низ встаёт над ней целиком, как есть, — на её высоту без своего нижнего отступа (--chat-lift): поле
     ложится на полоску iOS (стрелки и «Готово») так, чтобы до неё было столько же, сколько от неё до клавиатуры (ещё
     2 точки вниз). Размер поля и переписки при этом не меняется — путь подъёма считается точно (viewport.js). */
  body.kb-open #chat-app{--chat-lift:calc(var(--vv-bottom,0px) + 1px - var(--chat-raise) - 2px)}
}
/* Шаги и пункты в сообщении: номер в кружке или точка слева, текст справа; заголовок — жирной строкой по центру. */
#chat-app .chat-md-step{display:grid;grid-template-columns:22px minmax(0,1fr);gap:8px;align-items:start;margin:6px 0}
#chat-app .chat-md-num{display:flex;align-items:center;justify-content:center;width:22px;height:22px;border-radius:50%;font-size:12px;line-height:1;font-weight:700;background:color-mix(in srgb,currentColor 10%,transparent)}
#chat-app .chat-md-dot>.chat-md-num{background:none;font-size:16px}
#chat-app .chat-md-head{display:block;margin:8px 0 4px;font-size:16px;line-height:21px;font-weight:700;text-align:center;text-wrap:balance}
#chat-app .chat-message-text>.chat-md-head:first-child{margin-top:0}

/* familyStickers uses the current theme for constructor and preview. */
.family-sticker-sheet{max-width:620px;width:calc(100% - 24px)}
dialog.user-sheet.family-sticker-constructor{--sticker-form-height:calc(calc(100dvh / var(--zoom,1)) - var(--sticker-form-top,calc(env(safe-area-inset-top) + 26px)) - 16px);top:var(--sticker-form-top,calc(env(safe-area-inset-top) + 26px));bottom:auto;margin:0 auto;height:var(--sticker-form-height);max-height:var(--sticker-form-height);overflow:hidden}
/* Постоянный слой и обратимый переход: закрытие начинается с текущего масштаба. */
dialog.user-sheet.family-sticker-constructor[open]{display:flex;flex-direction:column;will-change:transform,opacity;transform-origin:50% 100%;animation:none;opacity:0;transform:translate3d(0,0,0) scale(.8);transition:opacity .22s ease,transform .22s cubic-bezier(.2,.7,.2,1)}
dialog.user-sheet.family-sticker-constructor[open].sticker-constructor-visible{opacity:1;transform:translate3d(0,0,0) scale(1)}
dialog.user-sheet.family-sticker-constructor[open].closing{animation:none;opacity:0;transform:translate3d(0,0,0) scale(.8);pointer-events:none}
@media(prefers-reduced-motion:reduce){dialog.user-sheet.family-sticker-constructor[open]{transition:none}}
dialog.user-sheet.compact-sheet.family-sticker-constructor{--sticker-top-blur-height:74px;width:min(420px,calc(calc(100vw / var(--zoom,1)) - 32px));padding:0;box-sizing:border-box}
/* Клавиши поверх нативной прокрутки и прозрачного плавного размытия. */
dialog.family-sticker-constructor>.sheet-head{position:absolute;top:12px;left:12px;right:12px;z-index:2;margin:0;pointer-events:none;background:none}
dialog.family-sticker-constructor>.sheet-head button{pointer-events:auto}
dialog.family-sticker-constructor>.family-sticker-form{flex:1;min-height:0;width:100%;padding:calc(var(--sticker-top-blur-height) + 2px) 16px 74px;overflow-y:auto;overscroll-behavior:contain}
dialog.family-sticker-constructor>.family-sticker-form>*{flex-shrink:0;max-width:100%}
.family-sticker-constructor-actions{position:absolute;bottom:18px;left:0;right:0;z-index:2;display:flex;justify-content:center;pointer-events:none;background:none}
.family-sticker-constructor-actions button{pointer-events:auto}
.family-sticker-create{height:44px;min-height:44px}
body.kb-open dialog.user-sheet.family-sticker-constructor{overflow:hidden}
/* Прозрачные слои разной силы перекрывают край нативной прокрутки. */
.sticker-scroll-blur{--sticker-blur-overscan:0px;z-index:1;pointer-events:none}
/* Запас разрешён только у внешнего края конструктора. В панели край блюра
   расположен внутри окна, под аватарками: выход фильтра за него недопустим.
   Маска продолжается в запасе, точки затухания привязаны к видимой области. */
.sticker-scroll-blur>span{position:absolute;inset:calc(-1*var(--sticker-blur-overscan));-webkit-backdrop-filter:blur(1.5px);backdrop-filter:blur(1.5px);
  -webkit-mask-size:100% 100%;mask-size:100% 100%;
  -webkit-mask-position:center;mask-position:center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat}
.sticker-scroll-blur>span:nth-child(2){-webkit-backdrop-filter:blur(5px);backdrop-filter:blur(5px)}
.sticker-scroll-blur>span:nth-child(3){-webkit-backdrop-filter:blur(14px);backdrop-filter:blur(14px)}
.sticker-scroll-blur>span{--from:.2;--to:1}
.sticker-scroll-blur>span:nth-child(2){--from:.08;--to:.72}
.sticker-scroll-blur>span:nth-child(3){--from:0;--to:.45}
.sticker-scroll-blur-top>span{--blur-mask:linear-gradient(#000 calc(var(--sticker-blur-overscan) + var(--sticker-blur-height)*var(--from)),transparent calc(var(--sticker-blur-overscan) + var(--sticker-blur-height)*var(--to)));-webkit-mask-image:var(--blur-mask);mask-image:var(--blur-mask)}
.sticker-scroll-blur-bottom>span{--blur-mask:linear-gradient(to top,#000 calc(var(--sticker-blur-overscan) + var(--sticker-blur-height)*var(--from)),transparent calc(var(--sticker-blur-overscan) + var(--sticker-blur-height)*var(--to)));-webkit-mask-image:var(--blur-mask);mask-image:var(--blur-mask)}
dialog.family-sticker-constructor>.sticker-scroll-blur{--sticker-blur-overscan:42px;position:absolute;left:0;right:0}
dialog.family-sticker-constructor>.sticker-scroll-blur-top{top:0;--sticker-blur-height:var(--sticker-top-blur-height);height:var(--sticker-blur-height)}
dialog.family-sticker-constructor>.sticker-scroll-blur-bottom{bottom:0;--sticker-blur-height:76px;height:var(--sticker-blur-height)}
#chat-app .chat-stickers>.sticker-scroll-blur{position:relative;grid-column:1;grid-row:2}
#chat-app .chat-stickers>.sticker-scroll-blur-top{align-self:start;--sticker-blur-height:calc(var(--sticker-head-height) + 18px);height:var(--sticker-blur-height)}
#chat-app .chat-stickers>.sticker-scroll-blur-bottom{display:none}
/* Одного blur мало: яркое содержимое у края превращается в пятна. Прокрутка
   сама растворяется в фоне окна к краю, blur лишь смягчает переход. */
dialog.family-sticker-constructor>.family-sticker-form{-webkit-mask-image:linear-gradient(transparent 10px,#00000028 26px,#00000080 42px,#000000d6 58px,#000 var(--sticker-top-blur-height),#000 calc(100% - 76px),#000000d6 calc(100% - 60px),#00000080 calc(100% - 45px),#00000028 calc(100% - 30px),transparent calc(100% - 14px));mask-image:linear-gradient(transparent 10px,#00000028 26px,#00000080 42px,#000000d6 58px,#000 var(--sticker-top-blur-height),#000 calc(100% - 76px),#000000d6 calc(100% - 60px),#00000080 calc(100% - 45px),#00000028 calc(100% - 30px),transparent calc(100% - 14px))}
#chat-app .chat-sticker-grid{--sticker-fade-top:calc(var(--sticker-head-height) + 18px);-webkit-mask-image:linear-gradient(transparent calc(var(--sticker-fade-top)*.3),#000 var(--sticker-fade-top));mask-image:linear-gradient(transparent calc(var(--sticker-fade-top)*.3),#000 var(--sticker-fade-top))}
#chat-app .chat-stickers:not(:has(.chat-sticker-head)) .chat-sticker-grid{--sticker-fade-top:8px}
.family-sticker-form,.family-sticker-field,.family-sticker-card{display:flex;flex-direction:column;gap:12px;min-width:0}
.family-sticker-field>span{font-size:14px;opacity:.65}
.family-sticker-field textarea,.family-sticker-sheet>textarea{width:100%;min-height:90px;border:0;border-radius:18px;padding:14px;resize:vertical;background:color-mix(in srgb,currentColor 7%,transparent);color:inherit;font:inherit;box-sizing:border-box}
.family-sticker-options{display:flex;gap:8px;flex-wrap:wrap}
.family-sticker-style-preview{width:180px;max-width:100%;height:auto;object-fit:contain;align-self:center}
.family-sticker-style-key{display:flex;flex-direction:column;align-items:center;gap:8px;align-self:center;max-width:100%;white-space:normal}
.family-sticker-style-key strong,.family-sticker-style-choice strong{font-size:14px;overflow-wrap:anywhere;text-align:center}
.family-sticker-style-key img[hidden],.family-sticker-style-symbol[hidden]{display:none}
.family-sticker-style-gallery{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;min-width:0}
.family-sticker-style-choice{display:flex;flex-direction:column;align-items:center;gap:8px;padding:12px;min-width:0;white-space:normal}
.family-sticker-style-choice img{display:block;width:100%;aspect-ratio:1;object-fit:contain;pointer-events:none}
.family-sticker-style-symbol{display:flex;align-items:center;justify-content:center;width:96px;max-width:100%;aspect-ratio:1}
.family-sticker-style-symbol svg{width:36px;height:36px}
/* В окне выбора стиля плитка «Свой» — того же размера, что плитки с превью: значок занимает такое же квадратное место. */
.family-sticker-style-choice .family-sticker-style-symbol{width:100%}
dialog.family-style-sheet .family-sticker-style-choice{border-radius:20px}
.family-sticker-style-tools,.family-style-actions{display:flex;justify-content:center;align-items:center;gap:12px}
.family-style-actions{margin-top:8px}
.family-sticker-style-notice{margin:0;text-align:center;font-size:14px}
.family-sticker-style-tools[hidden],.family-sticker-style-notice[hidden]{display:none}
.family-style-pack{grid-column:1/-1;display:flex;flex-direction:column;gap:10px}
dialog.user-sheet.family-style-sheet[open]{display:flex;flex-direction:column;gap:12px;width:min(420px,calc(calc(100vw / var(--zoom,1)) - 32px));box-sizing:border-box;border-radius:20px;animation:none;opacity:0;transform:scale(.8);transition:transform .18s ease,opacity .18s ease;max-height:calc(calc(100dvh / var(--zoom,1)) - 32px);overflow:auto}
dialog.user-sheet.family-style-sheet[open].family-style-visible{opacity:1;transform:scale(1)}
dialog.user-sheet.family-style-sheet[open].closing{animation:none;opacity:0;transform:scale(.8);transition-duration:.14s}
dialog.family-style-sheet>textarea{min-height:180px;text-align:center;flex-shrink:0}
dialog.family-style-sheet>.pill-input{width:100%;box-sizing:border-box;text-align:center}
.family-style-sheet .press-key{border:1px solid #e7e7ec;border-radius:999px;color:#242429;background:linear-gradient(#fff,#f5f5fa);box-shadow:0 1px 0 #f1f1f6,inset 0 1px 0 #fff}
.family-style-sheet .press-key:active,.family-style-pressed{transform:translateY(1px);box-shadow:inset 0 1px 3px #e1e1e6!important}
@media(prefers-reduced-motion:reduce){dialog.user-sheet.family-style-sheet{transition:none}}
.family-sticker-button{border:0;border-radius:18px;background:color-mix(in srgb,currentColor 7%,transparent);color:inherit;padding:10px 14px;font:inherit;cursor:pointer}
/* Общий hover клавиш подменял плоский фон светлой «клавишей». Браузер пересчитывает
   hover при открытии и закрытии системного выбора файла, на телефоне он ещё и
   залипает после касания — кнопка будто нажималась сама. Отклик нажатия остаётся в :active. */
html:root .press-key.family-sticker-button:hover:not(:active):not(.family-style-sheet *){background:color-mix(in srgb,currentColor 7%,transparent)}
html:root :is(.family-sticker-sources,.family-sticker-grid) .press-key.family-sticker-button:hover:not(:active),html:root .family-sticker-review-tile>.press-key.family-sticker-button:first-child:hover:not(:active){background:transparent}
.family-sticker-button[aria-pressed=true]{box-shadow:inset 0 0 0 2px currentColor}
.family-sticker-button:disabled{opacity:.35;cursor:default}
.family-sticker-sources,.family-sticker-grid,.family-sticker-review-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}
.family-sticker-sources img,.family-sticker-grid img,.family-sticker-review-grid img{width:100%;height:auto;aspect-ratio:1;object-fit:contain;display:block}
.family-sticker-sources button,.family-sticker-grid button,.family-sticker-review-tile>button:first-child{padding:0;background:transparent}
.family-sticker-review-tile{display:flex;flex-direction:column;gap:6px;min-width:0}
.family-sticker-quantity-title{margin-bottom:1em}
/* Над первым эмодзи — тот же отступ, что под h3: gap формы + margin заголовка. */
.family-sticker-reactions{display:flex;flex-direction:column;gap:10px;margin-top:1.17em}
.family-sticker-reaction{display:flex;align-items:flex-start;gap:10px}
.family-sticker-reaction details{flex:0 1 auto;min-width:0;width:max-content}.family-sticker-reaction summary{cursor:pointer;padding:10px}
/* Ширину задаёт надпись с маркером, а не intrinsic-размер textarea.
   Поле совпадает с ними, исключая боковые отступы summary. */
.family-sticker-reaction .family-sticker-field{width:0;min-width:calc(100% - 20px);margin:0 10px}
.family-sticker-emoji-grid{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:6px;max-height:50vh;overflow:auto}.family-sticker-emoji-grid button{font-size:26px;padding:8px}
.family-sticker-dots{display:flex;justify-content:center;align-items:center;gap:7px;min-height:100px}
.family-sticker-dots i{width:8px;height:8px;border-radius:50%;background:currentColor;animation:family-sticker-dot 1.2s ease-in-out infinite;opacity:.3}.family-sticker-dots i:nth-child(2){animation-delay:.16s}.family-sticker-dots i:nth-child(3){animation-delay:.32s}
@keyframes family-sticker-dot{0%,70%,100%{opacity:.3;transform:translateY(0)}35%{opacity:1;transform:translateY(-5px)}}
@media(prefers-reduced-motion:reduce){.family-sticker-dots i{animation:none;opacity:.7}}
@media(max-width:520px){.family-sticker-sheet{padding:16px}.family-sticker-grid,.family-sticker-review-grid{gap:8px}.family-sticker-review-tile .family-sticker-button{font-size:12px;padding:8px 4px}}

.family-sticker-grid .family-sticker-button{display:flex;flex-direction:column;white-space:normal}.family-sticker-grid .family-sticker-button img{flex-shrink:0}.family-sticker-review-tile>button:first-child{display:block}.family-sticker-sources button{display:block}

/* Ожидание набора стикеров: мозаика на холсте (рисует код чата) и дорожка шагов в левом нижнем углу рамки.
   Цвета дорожки не зависят от темы — селекторы с data-theme переводчик тёмной темы пропускает. */
.sticker-brew{position:relative;flex:none;align-self:center;width:460px;max-width:100%;}
.sticker-brew canvas{display:block;width:100%;height:auto;border-radius:18px;transition:opacity .8s ease}
.sticker-brew.final canvas{opacity:0}
.sticker-brew-sheet{position:absolute;left:0;top:0;width:100%;height:100%;object-fit:fill;filter:blur(16px);opacity:0;transition:opacity .8s ease;pointer-events:none}
.sticker-brew-sheet.on{opacity:1}
.sticker-brew-steps{transition:opacity .3s ease}
.sticker-brew-steps.off{opacity:0}
html:not([data-theme=none]) .sticker-brew-steps{position:absolute;left:12px;bottom:12px;display:flex;align-items:center;height:24px;padding:0 10px;border-radius:999px;background:#00000073;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px)}
/* Готовые стикеры встают на место размытого листа и «наводятся на резкость». */
.sticker-brew-reveal{transition:filter 1s cubic-bezier(.3,.6,.3,1)}
@starting-style{.sticker-brew-reveal{filter:blur(16px)}}
@media(prefers-reduced-motion:reduce){.sticker-brew-steps i,.sticker-brew-reveal>*{transition:none!important}}
/* Карточка набора в переписке: без имени автора и заголовка, стикеры крупные и без подложки,
   эмодзи — обычного размера на матовой подложке в правом нижнем углу стикера. */
#chat-app .chat-bubble:has(>.family-sticker-card)>:is(.chat-author,.chat-message-text:empty){display:none}
#chat-app .family-sticker-card .family-sticker-grid{grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;width:460px;max-width:100%}
#chat-app .family-sticker-card .family-sticker-grid .family-sticker-button,
#chat-app .family-sticker-card .family-sticker-grid .family-sticker-button:is(:hover,:active){position:relative;display:block;min-height:0;padding:0;border:0;border-radius:0;background:none;box-shadow:none}
#chat-app .family-sticker-card .family-sticker-grid .family-sticker-button:active{transform:scale(.97)}
.family-sticker-emoji{position:absolute;right:2px;bottom:2px;display:flex;align-items:center;justify-content:center;width:26px;height:26px;border-radius:50%;font-size:15px;line-height:1;background:color-mix(in srgb,currentColor 12%,transparent);-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px)}
.family-sticker-card-keys{display:flex;flex-direction:column;gap:8px}
#chat-app .family-sticker-card-keys .family-sticker-button{width:100%}
html:not([data-theme=none]) #chat-app .family-sticker-card-keys .family-sticker-button.danger-key{color:#ff453a}
/* Вопрос и поле названия раскрываются на месте трёх кнопок карточки. */
.family-sticker-card-keys>strong{text-align:center;font-size:15px;line-height:20px;padding:4px 0}
#chat-app .family-sticker-card-keys>.pill-input{display:block;width:100%!important;min-width:0;height:42px;box-sizing:border-box;padding:0 16px;border:0;border-radius:999px;outline:none;text-align:center;font:inherit;font-size:16px;color:inherit;background:color-mix(in srgb,currentColor 9%,transparent);-webkit-user-select:text;user-select:text}
.family-sticker-card-answer{display:flex;justify-content:center;gap:10px}
#chat-app .family-sticker-card-answer .family-sticker-button{flex:0 0 auto;width:auto;min-width:76px}
.family-sticker-card-keys>*{transition:opacity .22s ease,transform .22s cubic-bezier(.2,.7,.2,1)}
@starting-style{.family-sticker-card-keys>*{opacity:0;transform:translateY(4px)}}
.family-sticker-card-top{display:flex;align-items:center;gap:8px}
#chat-app .family-sticker-card-top>.family-sticker-button{flex:1 1 0;min-width:0;width:auto}
html:not([data-theme=none]) #chat-app .family-sticker-card-edit{flex:none;width:42px;height:42px;min-height:42px;padding:0;color:#8c8c91!important}
#chat-app .family-sticker-card-edit svg{width:19px;height:19px}
html:not([data-theme=none]) #chat-app .family-sticker-card-remove{flex:none;width:42px;height:42px;min-height:42px;padding:0;color:#ff453a!important}
#chat-app .family-sticker-card-remove svg{width:19px;height:19px}
html:not([data-theme=none]) #chat-app .family-sticker-card-remove svg{color:#ff453a!important}
html:not([data-theme=none]) #chat-app .family-sticker-card-edit svg{color:#8c8c91!important}
/* Этап создания словом: светлый блик медленно пробегает по буквам; при смене слова новое проявляется. */
html:not([data-theme=none]) .sticker-brew-steps span{font-size:12px;font-weight:500;line-height:24px;white-space:nowrap;color:transparent;-webkit-background-clip:text;background-clip:text;
  background-image:linear-gradient(90deg,#ffffff80 40%,#fffffffa 50%,#ffffff80 60%);background-size:250% 100%;animation:sticker-brew-shimmer 2.1s cubic-bezier(.45,0,.55,1) infinite;transition:opacity .28s ease}
@starting-style{.sticker-brew-steps span{opacity:0}}
@keyframes sticker-brew-shimmer{0%{background-position:105% 0}76%,100%{background-position:-5% 0}}
@media(prefers-reduced-motion:reduce){html:not([data-theme=none]) .sticker-brew-steps span{animation:none;color:#ffffffbf}}
/* Фото для набора: квадратные со скруглением, ряд собирается от центра. */
dialog.family-sticker-constructor .family-sticker-sources{display:flex;flex-wrap:wrap;justify-content:center;gap:12px}
dialog.family-sticker-constructor .family-sticker-sources:empty{display:none}
dialog.family-sticker-constructor .family-sticker-sources>button{flex:0 0 calc((100% - 24px) / 3);border-radius:18px;overflow:hidden}
dialog.family-sticker-constructor .family-sticker-sources img{object-fit:cover;border-radius:18px}
/* Окно правки набора: стикеры без подложки, точка выбора слева сверху, эмодзи справа внизу. */
dialog.family-sticker-review .family-sticker-review-grid{gap:8px}
dialog.family-sticker-review .family-sticker-review-tile{position:relative;display:block;cursor:grab}
dialog.family-sticker-review .family-sticker-review-tile img{transition:transform .18s cubic-bezier(.2,.7,.2,1);cursor:pointer}
dialog.family-sticker-review .family-sticker-review-tile.picked img{transform:scale(.86)}
dialog.family-sticker-review button.family-sticker-emoji{border:0;padding:0;min-height:0;font-family:inherit;color:inherit;cursor:pointer}
dialog.family-sticker-review .family-sticker-constructor-actions{gap:8px;align-items:center}
dialog.family-sticker-review textarea{width:100%;min-height:76px;border:0;border-radius:18px;padding:12px 14px;resize:none;text-align:center;background:color-mix(in srgb,currentColor 7%,transparent);color:inherit;font:inherit;box-sizing:border-box}
html:not([data-theme=none]) dialog.family-sticker-review .family-sticker-card-edit,html:not([data-theme=none]) dialog.family-sticker-review .family-sticker-card-remove{flex:none;width:44px;height:44px;min-height:44px;padding:0}
html:not([data-theme=none]) dialog.family-sticker-review .family-sticker-card-edit,html:not([data-theme=none]) dialog.family-sticker-review .family-sticker-card-edit svg{color:#8c8c91!important}
html:not([data-theme=none]) dialog.family-sticker-review .family-sticker-card-remove,html:not([data-theme=none]) dialog.family-sticker-review .family-sticker-card-remove svg{color:#ff453a!important}
dialog.family-sticker-review .family-sticker-card-remove:disabled{opacity:.35}
dialog.family-sticker-review textarea[hidden]{display:none}
/* Окно правки — по высоте содержимого (не выше экрана), а не во всю высоту, как конструктор. */
dialog.user-sheet.family-sticker-constructor.family-sticker-review{top:0;bottom:0;margin:auto;height:fit-content;transform-origin:50% 50%}
dialog.family-sticker-review .family-sticker-review-tile{-webkit-touch-callout:none;-webkit-user-select:none;user-select:none}
dialog.family-sticker-review .family-sticker-review-tile img{-webkit-user-drag:none}
/* Карточка набора — не сообщение, а отдельная плашка: по центру переписки, шире, скруглена со всех сторон,
   без аватарки Fio и без времени. */
#chat-app .chat-swipe:has(.family-sticker-card){justify-content:center}
#chat-app .chat-message:has(.family-sticker-card){max-width:min(100%,496px);margin-inline:auto}
#chat-app .chat-message:has(.family-sticker-card)>.chat-face{display:none}
#chat-app .chat-bubble:has(>.family-sticker-card){border-radius:26px!important;padding:12px}
#chat-app .chat-bubble:has(>.family-sticker-card)>:is(.chat-meta,.chat-meta-space){display:none}
html:not([data-theme=none]) dialog.family-sticker-review .family-sticker-constructor-actions>.round-key:not(.family-sticker-card-edit,.family-sticker-card-remove){flex:none;width:44px;height:44px;min-height:44px;padding:0}
/* Цель удаления на время перетаскивания: стоит на месте «Сохранить», под пальцем краснеет и растёт. */
html:not([data-theme=none]) dialog.family-sticker-review .family-sticker-drop{color:#ff453a!important;transition:transform .15s cubic-bezier(.2,.7,.2,1),background-color .15s ease}
html:not([data-theme=none]) dialog.family-sticker-review .family-sticker-drop.over{transform:scale(1.12);background:#ff453a!important;color:#fff!important}
/* Просьба сначала закончить эту генерацию — строкой над карточкой, по центру. */
#chat-app .chat-bubble:has(>.family-sticker-card)>.chat-message-text:not(:empty){display:block;margin:2px 0 10px;text-align:center;font-weight:600}

/* Чат с Fio на телефоне открывается своей вкладкой внизу, поэтому в «Личных» его нет. */
#chat-app .chat-fio-open{display:none}
#chat-app .chat-list-key.chat-list-fio{display:none!important}
/* Fio: на телефоне — своя вкладка внизу, на компьютере — круглая кнопка справа от поиска над списком. */
#chat-app .chat-search .chat-fio-open:not([hidden]){position:relative;display:inline-flex;align-items:center;justify-content:center;flex:none;width:40px;height:40px;min-height:40px;padding:0}
#chat-app .chat-search .chat-fio-open svg{width:20px;height:20px}
#chat-app .chat-search .chat-fio-open .unread-badge{position:absolute;top:-3px;right:-3px}
#chat-app.searching-all .chat-search .chat-fio-open{display:none}
#chat-app .chat-fio-for{margin-left:4px;white-space:nowrap}
/* Якорь нижних вкладок вне телефона ничего не значит. */
@media(min-width:651px){#chat-app .chat-pager-foot{display:contents}}
/* Телефон: заголовок списка — три названия в одном окошке капсулы; видно название текущей вкладки, и капсула — по его
   ширине (её задаёт невидимая копия названия). При смене вкладки старое название уезжает, новое въезжает, капсула
   меняет ширину — вместе с подложкой нижних вкладок (chatTabSlide в код чата); у краёв окошка названия гаснут. */
#chat-app .chat-pager-title{display:none}
@media(max-width:650px){
  #chat-app .chat-pager-head #app-switch>span:not(.chat-pager-title){display:none}
  #chat-app .chat-pager-head .chat-pager-title{display:grid;position:relative;overflow:hidden;
    -webkit-mask-image:linear-gradient(90deg,transparent,#000 13px,#000 calc(100% - 13px),transparent);mask-image:linear-gradient(90deg,transparent,#000 13px,#000 calc(100% - 13px),transparent)}
  /* Поля капсулы отданы окошку ленты: названия гаснут у самого края капсулы, а её ширина прежняя. */
  #chat-app .chat-pager-head #app-switch{padding-left:11px;padding-right:11px}
  #chat-app .chat-pager-title-size{display:block;visibility:hidden}
  #chat-app .chat-pager-title-size>span{display:none;white-space:nowrap;padding:0 14px}
  #chat-app[data-list-tab=recent] .chat-pager-title-size>span:nth-child(1),#chat-app[data-list-tab=direct] .chat-pager-title-size>span:nth-child(2),
  #chat-app[data-list-tab=groups] .chat-pager-title-size>span:nth-child(3){display:block}
  #chat-app .chat-pager-title-strip{position:absolute;inset:0;display:grid;align-items:center}
  #chat-app .chat-pager-title-strip>span{grid-area:1/1;text-align:center;white-space:nowrap;visibility:hidden}
  #chat-app[data-list-tab=recent] .chat-pager-title-strip>span:nth-child(1),#chat-app[data-list-tab=direct] .chat-pager-title-strip>span:nth-child(2),
  #chat-app[data-list-tab=groups] .chat-pager-title-strip>span:nth-child(3){visibility:visible}
}

/* Аватарка группы: в списке — фото вместо общего значка; в окне участников — крупная круглая кнопка выбора фото. */
#chat-app .chat-list-icon.chat-group-face{width:26px;height:26px;margin:-4px 0;border-radius:50%;overflow:hidden}
#chat-app .chat-list-icon.chat-group-face img{width:100%;height:100%;object-fit:cover;display:block}
@media(max-width:650px){#chat-app .chat-list-key.with-preview .chat-list-icon.chat-group-face{width:48px;height:48px;margin:0;background:none}}
#chat-app .chat-group-photo{align-self:center;width:84px;height:84px;min-height:84px;padding:0;border-radius:50%;overflow:hidden;margin:0 auto 12px;display:flex;align-items:center;justify-content:center}
#chat-app .chat-group-photo .chat-list-icon{width:100%;height:100%;border-radius:50%;justify-content:center;align-items:center;background:none}
#chat-app .chat-group-photo .chat-list-icon svg{width:34px;height:34px}
/* Поле поиска — отдельно от списка и не прокручивается с ним. Телефон: стоит под шапкой на странице списка, список
   начинается под ним и у верхнего края плавно гаснет. */
@media(max-width:650px){
  #chat-app .chat-list-panel>.chat-search{position:absolute;z-index:3;top:calc(90px + env(safe-area-inset-top));left:14px;right:14px;width:auto;margin:0}
  #chat-app #chat-list{margin-top:calc(134px + env(safe-area-inset-top));-webkit-mask-image:linear-gradient(transparent,#000 14px);mask-image:linear-gradient(transparent,#000 14px)}
  #chat-app #chat-list>.chat-section{padding-top:14px!important}
}
/* Компьютер: прокручивается сам список, а панель с полем поиска над ним стоит. */
@media(min-width:651px){
  #chat-app .chat-list-panel{display:flex;flex-direction:column;overflow:hidden}
  #chat-app .chat-list-panel>.chat-search{flex:none;margin-bottom:0}
  /* Как на телефоне и в окне стикеров: у верхнего края список плавно гаснет, а не обрезается под полем поиска. */
  #chat-app .chat-list-panel>#chat-list{flex:1 1 auto;min-height:0;overflow-y:auto;padding-top:14px;-webkit-mask-image:linear-gradient(transparent,#000 26px);mask-image:linear-gradient(transparent,#000 26px)}
}
/* Компьютер: верхние кнопки окна чата (заголовок, настройки) — на том же расстоянии от верха окна, что нижние
   (скрепка, поле ввода) от низа: 13px. */
@media(min-width:651px){#chat-app .chat-top-strip{margin-top:9px}}
@media(min-width:651px){#chat-app .chat-switch-slot{align-items:flex-start}}

/* Превью наборов над стикерами — просто картинки покрупнее: без подложки, рамки и тени клавиши и без «нажатия» при
   касании (ряд листают пальцем, и клавиши при этом продавливались). Выбранный набор обведён по силуэту самой картинки (она с прозрачным фоном):
   мягкое свечение вокруг непрозрачной части; у набора без картинки — мягкий фон. */
#chat-app .chat-sticker-tab{width:56px;height:56px;min-height:56px;padding:5px;border:0!important;border-radius:16px;background:none!important;box-shadow:none!important;transform:none!important;transition:none}
#chat-app .chat-sticker-tab:active{background:none!important;box-shadow:none!important;transform:none!important}
#chat-app .chat-sticker-tab.active img{filter:drop-shadow(0 0 1.5px #00000099) drop-shadow(0 0 4px #00000066)}
:root[data-theme=dark] #chat-app .chat-sticker-tab.active img{filter:drop-shadow(0 0 1.5px #ffffffb3) drop-shadow(0 0 4px #ffffff80)}
#chat-app .chat-sticker-tab.active:not(:has(img)){background:#ececf1!important}
:root[data-theme=dark] #chat-app .chat-sticker-tab.active:not(:has(img)){background:#2c2c2e!important}

/* Новость об обновлении от Fio — карточка в круглом пузыре по центру, как карточка набора стикеров: без имени, времени
   и аватарки. Заголовок крупно по центру, пункты — крупный эмодзи слева, название и пояснение справа. */
#chat-app .chat-swipe:has(.chat-news-card){justify-content:center}
#chat-app .chat-message:has(.chat-news-card){max-width:min(100%,496px);margin-inline:auto}
#chat-app .chat-message:has(.chat-news-card)>.chat-face{display:none}
#chat-app .chat-bubble:has(>.chat-news-card){border-radius:26px!important;padding:20px 20px 22px}
#chat-app .chat-bubble:has(>.chat-news-card)>:is(.chat-author,.chat-meta,.chat-meta-space){display:none}
#chat-app .chat-news-card{display:flex;flex-direction:column;gap:14px;min-width:0;width:456px;max-width:100%;text-align:left;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
#chat-app .chat-news-card *{-webkit-user-select:none;user-select:none}
#chat-app .chat-news-title{display:block;text-align:center;font-size:21px;line-height:26px;font-weight:700;letter-spacing:-.2px;text-wrap:balance}
#chat-app .chat-news-head{display:block;margin-top:4px;font-size:13px;line-height:18px;font-weight:600;letter-spacing:.4px;text-transform:uppercase;opacity:.55}
#chat-app .chat-news-text{display:block;font-size:15px;line-height:21px}
#chat-app .chat-news-card>.chat-news-text{text-align:center;opacity:.8;text-wrap:balance}
#chat-app .chat-news-rule{display:block;height:1px;background:currentColor;opacity:.12}
#chat-app .chat-news-item{display:grid;grid-template-columns:44px minmax(0,1fr);gap:12px;align-items:start}
/* Эмодзи пункта — без подложки, выделен мягким свечением по своему силуэту, как выбранный набор стикеров. */
#chat-app .chat-news-emoji{display:flex;align-items:center;justify-content:center;width:44px;height:44px;font-size:30px;line-height:1;filter:drop-shadow(0 0 1.5px #00000045) drop-shadow(0 0 4px #0000001f)}
:root[data-theme=dark] #chat-app .chat-news-emoji{filter:drop-shadow(0 0 1.5px #ffffff59) drop-shadow(0 0 4px #ffffff26)}
#chat-app .chat-news-body{display:flex;flex-direction:column;gap:2px;min-width:0;padding-top:1px}
#chat-app .chat-news-body>strong{display:block;margin:0;padding:0;font-size:15px;line-height:21px;font-weight:600}
#chat-app .chat-news-body>.chat-news-text{opacity:.72}
#chat-app .chat-news-version{align-self:center;padding:3px 11px;border-radius:999px;font-size:12px;line-height:18px;font-weight:600;letter-spacing:.2px;background:color-mix(in srgb,currentColor 8%,transparent);opacity:.75;margin-bottom:-4px}
#chat-app .chat-news-head{text-align:center}
/* «Архив» на доске пожеланий: клавиши «Архив» и «Назад» по центру, между ними в архиве — номера страниц. */
#chat-app .chat-news-more{align-self:center;height:34px;min-height:34px;padding:0 16px;border-radius:999px;font-size:13px}
#chat-app .chat-news-pages{display:flex;justify-content:center;align-items:center;gap:6px}
#chat-app .chat-news-page{width:34px;padding:0}
#chat-app .chat-news-page.pressed{transform:translateY(1px);box-shadow:inset 0 1px 3px #37373c26}

/* Галочки своего сообщения нажимаются (кто просмотрел): область нажатия шире самих галочек. */
#chat-app .chat-read-status.chat-read-key{position:relative;cursor:pointer;pointer-events:auto}
#chat-app .chat-read-status.chat-read-key::after{content:'';position:absolute;inset:-10px -8px}

/* Кнопка «вниз» над полем ввода по центру; под окнами смайлов и стикеров, над перепиской. */
#chat-app .chat-composer>.chat-jump-down.round-key{position:absolute;left:50%;translate:-50% 0;bottom:calc(100% + 10px);z-index:3;width:40px;height:40px;min-height:40px;padding:0;opacity:0;pointer-events:none;transform:scale(.8);transition:opacity .2s ease,transform .26s cubic-bezier(.16,1,.3,1)}
#chat-app .chat-composer>.chat-jump-down.round-key svg{width:20px;height:20px}
#chat-app .chat-composer>.chat-jump-down.round-key.shown{opacity:1;pointer-events:auto;transform:none}
#chat-app .chat-composer>.chat-jump-down.round-key.shown:active{transform:translateY(1px)}
/* Открыты смайлы, стикеры или идёт запись — кнопка не мешает. */
#chat-app .chat-composer:has(.chat-emojis:not([hidden]),.chat-stickers.sticker-visible,.chat-sticker-hints:not([hidden]))>.chat-jump-down.round-key,
#chat-app.voice-hold .chat-composer>.chat-jump-down.round-key{opacity:0;pointer-events:none}
@media(prefers-reduced-motion:reduce){#chat-app .chat-jump-down{transition:none}}

/* Кружки (видеосообщения). Запись с фронтальной камеры хранится как снята и показывается зеркально (.mirror); обложка уже зеркальна. */
#chat-app{--round-side:min(232px,62vw)}
@media(min-width:651px){#chat-app{--round-side:260px}}
/* Круг — скругление у самого видео и обложки (видеокарта скругляет слой даром). Маска или clip-path на круге заставляли
   iPhone прогонять каждый кадр каждого играющего кружка через отдельный проход отрисовки — телефон грелся; а
   скругление только у круга не обрезало видео в увеличенном (transform) круге — вылезали квадратные углы. */
#chat-app .chat-round{position:relative;display:block;flex:none;width:var(--round-side);height:var(--round-side);padding:0;border:0;border-radius:50%;
  background:#0000000f;cursor:pointer;-webkit-tap-highlight-color:transparent;
  transform-origin:100% 50%;transition:transform .32s cubic-bezier(.16,1,.3,1)}
#chat-app .chat-message:not(.own) .chat-round{transform-origin:0 50%}
#chat-app .chat-round>img,#chat-app .chat-round>video{position:absolute;inset:0;display:block;width:100%;height:100%;max-width:none;margin:0;object-fit:cover;border-radius:50%}
#chat-app .chat-round>video{opacity:0;transition:opacity .2s ease}
#chat-app .chat-round.live>video{opacity:1}
#chat-app .chat-round.mirror>video,#chat-app .chat-round>video.mirrored{transform:scaleX(-1)}
#chat-app .chat-round>video.chat-round-sound{opacity:0}
#chat-app .chat-round.sound>video.chat-round-sound{opacity:1}
/* Со звуком — крупнее и поверх соседних сообщений; время под кругом на это время прячется (круг его перекрыл бы). */
#chat-app .chat-round.active{transform:scale(1.25);touch-action:none}
#chat-app .chat-message:has(.chat-round.active){position:relative;z-index:3}
#chat-app .chat-round-wrap{position:relative;display:block}
/* Скорость — пилюлей сбоку от увеличенного круга, у его нижнего края; видна, пока кружок играет со звуком. */
#chat-app .chat-round-speed{position:absolute;bottom:calc(var(--round-side) * -.125);right:calc(100% + var(--round-side) * .25 + 8px);padding:4px 10px;font-size:13px;line-height:16px;
  background:#ffffffb8;color:#3a3a3f;opacity:0;pointer-events:none;transition:opacity .2s ease}
#chat-app .chat-message:not(.own) .chat-round-speed{right:auto;left:calc(100% + var(--round-side) * .25 + 8px)}
#chat-app .chat-round-wrap:has(.chat-round.active) .chat-round-speed{opacity:1;pointer-events:auto}
#chat-app .chat-round-bubble>.chat-meta{transition:opacity .2s ease}
#chat-app .chat-round-bubble:has(.chat-round.active)>.chat-meta{opacity:0}
/* Кольцо, пауза и время — над видео (свой слой WebKit даёт им сам, раз они его перекрывают; заранее заведённый
   слой на каждый из трёх в каждом кружке только множил слои переписки). */
#chat-app .chat-round-ring,#chat-app .chat-round-pause,#chat-app .chat-round-length{z-index:1}
#chat-app .chat-round-ring{position:absolute;inset:0;opacity:0;pointer-events:none}
#chat-app .chat-round.active .chat-round-ring{opacity:1}
/* Прогресс — как в Telegram: пока играет, только тонкая белая дуга внутри круга у края, от верха по часовой. На паузе
   и при перемотке видео притемнено, кольцо отходит внутрь, видны бледная дорожка и ползунок; кольцо можно тянуть
   пальцем — перемотка (round.js). */
#chat-app .chat-round-ring svg,#chat-app .chat-round-live-circle svg{position:absolute;inset:0;width:100%;height:100%;fill:none}
#chat-app .chat-round-ring{border-radius:50%;transition:opacity .2s ease,background-color .2s ease}
#chat-app .chat-round-ring svg{transition:transform .2s ease}
#chat-app .chat-round-ring .track,#chat-app .chat-round-ring .knob{opacity:0;transition:opacity .2s ease}
#chat-app .chat-round-ring .track{stroke:#fff3;stroke-width:2.6}
#chat-app .chat-round-ring .fill{stroke:#fff;stroke-width:1.7;stroke-linecap:round;stroke-dasharray:298.45;stroke-dashoffset:298.45;transition:stroke-width .2s ease}
#chat-app .chat-round-ring .knob{fill:#fff}
#chat-app .chat-round.paused .chat-round-ring,#chat-app .chat-round.scrub .chat-round-ring{background-color:#0000004d}
#chat-app .chat-round.paused .chat-round-ring svg,#chat-app .chat-round.scrub .chat-round-ring svg{transform:scale(.84)}
#chat-app .chat-round.paused .chat-round-ring .fill,#chat-app .chat-round.scrub .chat-round-ring .fill{stroke-width:2.6}
#chat-app .chat-round.paused .chat-round-ring .track,#chat-app .chat-round.paused .chat-round-ring .knob,
#chat-app .chat-round.scrub .chat-round-ring .track,#chat-app .chat-round.scrub .chat-round-ring .knob{opacity:1}
#chat-app .chat-round-live-circle svg{transform:rotate(-90deg)}
#chat-app .chat-round-length{position:absolute;left:50%;bottom:9%;translate:-50% 0;padding:2px 8px;border-radius:999px;background:#00000059;color:#fff;font-size:12px;font-weight:600;font-variant-numeric:tabular-nums;pointer-events:none}
#chat-app .chat-round-pause{position:absolute;left:50%;top:50%;width:48px;height:48px;margin:-24px 0 0 -24px;display:flex;align-items:center;justify-content:center;border-radius:50%;
  color:#fff;opacity:0;transition:opacity .15s ease;pointer-events:none}
#chat-app .chat-round-pause svg{width:30px;height:30px;fill:currentColor;filter:drop-shadow(0 1px 3px #0005)}
#chat-app .chat-round.paused .chat-round-pause{opacity:1}
/* Ещё не отправленный кружок: тот же круг с кольцом загрузки. */
#chat-app .chat-upload.chat-round{cursor:default}
#chat-app .chat-upload.chat-round img{height:100%;border-radius:50%}
/* Запись: слой во всё окно переписки под полем ввода (поле, замочек и время — над ним), ровное затемнение, по центру
   свободного места — превью в круге, под ним — смена камеры. */
#chat-app.round-live .chat-composer{z-index:4}
#chat-app .chat-round-live{position:absolute;inset:0;z-index:3;box-sizing:border-box;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:18px;
  background:#f2f2f7f2;pointer-events:none;animation:chat-round-in .2s ease-out}
#chat-app .chat-round-live.gone{opacity:0;transition:opacity .18s ease}
#chat-app .chat-round-live-circle{position:relative;flex:none;width:min(calc(100% - 48px),calc(100dvh - 340px),320px);aspect-ratio:1;border-radius:50%;
  background:#1c1c1e;animation:chat-round-pop .3s cubic-bezier(.16,1,.3,1)}
/* Вспышка фронтальной камеры — как в Telegram: под кругом сплошное белое, а поверх всего, и самого круга, — белое
   с прозрачностью: в середине круга 25%, к краю круга почти сплошное (размер — от ширины экрана --fw, как у них).
   Над белым — только кнопки. Появляется и уходит прозрачностью. Центр (--fx, --fy) ставит round-record.js. */
#chat-app .chat-round-live::before,#chat-app .chat-round-live::after{content:'';position:absolute;inset:0;pointer-events:none;opacity:0;transition:opacity .2s ease}
#chat-app .chat-round-live::before{z-index:-1;background:#fff}
#chat-app .chat-round-live::after{z-index:1;background:radial-gradient(circle at var(--fx,50%) var(--fy,50%),#ffffff40 0,#ffffff40 calc(var(--fw,400px)*.2),#fff calc(var(--fw,400px)*.6))}
#chat-app .chat-round-live.lit::before,#chat-app .chat-round-live.lit::after,:root[data-theme=dark] #chat-app .chat-round-live.lit::before,:root[data-theme=dark] #chat-app .chat-round-live.lit::after{opacity:1}
#chat-app .chat-round-keys{position:relative;z-index:2}
#chat-app.round-live .chat-top-strip{transition:opacity .2s ease}
#chat-app.round-lit .chat-top-strip{opacity:0;pointer-events:none}
#chat-app.round-live .chat-content::after,#chat-app.round-live .chat-composer::before{transition:opacity .2s ease}
#chat-app.round-lit .chat-content::after,#chat-app.round-lit .chat-composer::before{opacity:0}
#chat-app .chat-round-live-circle video{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;border-radius:50%}
#chat-app .chat-round-live-circle video.mirror{transform:scaleX(-1)}
#chat-app .chat-round-live-circle circle{stroke:#247bff;stroke-width:3;stroke-dasharray:304.73;stroke-dashoffset:304.73;animation:chat-round-time var(--round-max,60s) linear forwards}
/* Кнопка под кругом не сдвигает его из центра: её высота с отступом (18 + 46) погашена. */
/* Кнопки под кругом: смена камеры и фонарик. */
#chat-app .chat-round-keys{flex:none;display:flex;justify-content:center;gap:14px;margin-bottom:-64px}
#chat-app .chat-round-flip,#chat-app .chat-round-torch{flex:none;width:46px;height:46px;min-height:46px;padding:0;pointer-events:auto}
#chat-app .chat-round-torch[hidden]{display:none}
/* Включён — клавиша остаётся вдавленной, значок жёлтый. */
#chat-app .chat-round-torch[aria-pressed=true],#chat-app .chat-round-flip[aria-expanded=true]{transform:translateY(1px);box-shadow:inset 0 2px 5px #00000026}
#chat-app .chat-round-torch[aria-pressed=true] svg{color:#f5a300;stroke:#f5a300}
#chat-app .chat-round-flip[hidden]{display:flex!important;visibility:hidden}
#chat-app .chat-round-flip svg,#chat-app .chat-round-torch svg{width:21px;height:21px}
:root[data-theme=dark] #chat-app .chat-round-live{background:#000000e0}
:root[data-theme=dark] #chat-app .chat-round{background:#ffffff14}
:root[data-theme=dark] #chat-app .chat-round-speed{background:#121213b3;color:#e5e5ea}
@keyframes chat-round-in{from{opacity:0}}
@keyframes chat-round-pop{from{transform:scale(.8);opacity:0}}
@keyframes chat-round-time{to{stroke-dashoffset:0}}

/* Мини-плеер в шапке чата (mini-player.js): капсула на месте названия чата, пока играет голосовое или кружок. */
#chat-app .chat-now{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);z-index:1;display:flex;align-items:center;box-sizing:border-box;height:44px;max-width:calc(100% - 132px);padding:0 5px;
  border:1px solid #e7e7ec;border-radius:999px;background:linear-gradient(#ffffff,#f5f5fa);box-shadow:0 1px 0 #f1f1f6,inset 0 1px 0 #fff;color:#1c1c1e;pointer-events:auto}
#chat-app .chat-now[hidden]{display:none}
/* Вдвоём капсула стоит внутри блока собеседника: место и ширину задаёт он, аватарка остаётся справа. */
#chat-app .chat-peer-head>.chat-now{position:static;transform:none;max-width:100%}
#chat-app.now-playing .chat-peer-key,#chat-app.now-playing .chat-top-strip .chat-title{display:none!important}
#chat-app .chat-now button{margin:0;padding:0;border:0;background:none;color:inherit;font:inherit;cursor:pointer;-webkit-tap-highlight-color:transparent}
#chat-app .chat-now-key{flex:none;display:grid;place-items:center;width:34px;height:34px;border-radius:50%}
#chat-app .chat-now-key:active{background:#0000000f}
#chat-app .chat-now-key svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
#chat-app .chat-now-title{min-width:0;display:flex;flex-direction:column;align-items:center;padding:0 8px;font-size:15px;line-height:18px;font-weight:600;text-align:center}
#chat-app .chat-now-title span,#chat-app .chat-now-title small{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#chat-app .chat-now-title small{font-size:12px;line-height:15px;font-weight:400;color:#8e8e93}
@media(min-width:651px){#chat-app .chat-top-strip>.chat-now{max-width:calc(100% - 300px)}}
:root[data-theme=dark] #chat-app .chat-now{border-color:#3a3a3c;background:linear-gradient(#2c2c2e,#242426);box-shadow:none;color:#f2f2f7}
:root[data-theme=dark] #chat-app .chat-now-key:active{background:#ffffff1f}

/* Файл, которым поделились из «Файлов»: карточка в пузыре — предпросмотр, имя, размер, «Загрузить» во всю ширину. */
#chat-app .chat-shared-card{display:flex;flex-direction:column;gap:4px;width:250px;max-width:100%;padding:2px 0 4px}
#chat-app .chat-shared-look{position:relative;display:flex;align-items:center;justify-content:center;aspect-ratio:4/3;margin-bottom:6px;border-radius:14px;overflow:hidden;
  background:color-mix(in srgb,currentColor 7%,transparent);cursor:pointer}
#chat-app .chat-shared-look.plain{cursor:default}
#chat-app .chat-shared-look img{width:100%;height:100%;object-fit:cover;display:block}
#chat-app .chat-shared-look>svg{width:46px;height:46px;opacity:.55}
#chat-app .chat-shared-ext{position:absolute;left:50%;top:calc(50% + 34px);translate:-50% 0;font-size:12px;font-weight:700;letter-spacing:.4px;opacity:.55}
#chat-app .chat-shared-name{display:block;margin:0;padding:0;font-size:15px;line-height:20px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#chat-app .chat-shared-size{font-size:13px;line-height:17px;opacity:.6}
#chat-app .chat-shared-get{align-self:stretch;height:38px;min-height:38px;margin-top:8px;border-radius:999px;font-size:15px}

/* Пузыри «Стекло» (Настройки → Оформление). Стекло рисует chat/glass.js на одном холсте под пузырями внутри прокрутки
   (data-glass-gl); без WebGL2 — просто полупрозрачная заливка. !important — чтобы перебить цвета пузырей всех тем;
   вспышку найденного сообщения не трогаем. OLED перечислен отдельно: автоматическая копия светлого правила для OLED
   иначе сильнее тёмного. */
:root[data-bubbles=glass] #chat-app .chat-message:not(.chat-flash) .chat-bubble:not(.chat-emoji-bubble){background:#ffffff2e!important;border-color:#ffffff59!important}
:root[data-theme=dark][data-bubbles=glass] #chat-app .chat-message:not(.chat-flash) .chat-bubble:not(.chat-emoji-bubble),
:root[data-theme=dark][data-oled][data-bubbles=glass] #chat-app .chat-message:not(.chat-flash) .chat-bubble:not(.chat-emoji-bubble){background:#ffffff14!important;border-color:#ffffff1f!important}
:root[data-glass-gl][data-bubbles] #chat-app .chat-message:not(.chat-flash) .chat-bubble:not(.chat-emoji-bubble){background:transparent!important;border-color:transparent!important;box-shadow:0 6px 16px -8px #0000004d!important}
:root[data-glass-gl][data-theme=dark][data-bubbles] #chat-app .chat-message:not(.chat-flash) .chat-bubble:not(.chat-emoji-bubble),
:root[data-glass-gl][data-theme=dark][data-oled][data-bubbles] #chat-app .chat-message:not(.chat-flash) .chat-bubble:not(.chat-emoji-bubble){background:transparent!important;border-color:transparent!important;box-shadow:0 6px 16px -8px #00000099!important}
/* Холст лежит в прокрутке и едет вместе со строками; положение внутри задаёт glass.js. Под содержимым его держит
   z-index:-1 внутри прокрутки (isolation), а не порядок элементов: на iPhone стекло закрывало текст, и порядку слоёв
   отдельного холста там не доверяем. */
:root[data-glass-gl] #chat-app .chat-messages{position:relative;isolation:isolate}
#chat-app .chat-glass-layer{position:absolute;left:0;top:0;z-index:-1;width:100%;pointer-events:none}

