:root {
    --color-bg: #0b0b0f;
    --color-surface: rgba(255, 255, 255, 0.06);
    --color-text: #ffffff;
    --color-text-secondary: rgba(255, 255, 255, 0.6);
    --color-accent: #4d7cff;
    --color-error: #ff4d4d;
    --radius-lg: 20px;
    --radius-md: 14px;
    --blur-glass: 24px;
    --app-max-width: 768px;
}

* {
    box-sizing: border-box;
}

input, textarea, button {
    outline: none;
}

/* Без этого повторный тап по ОДНОЙ и той же кнопке (тот же эмодзи в пикере/быстрой
   реакции, та же реакция под сообщением и т.п.) мобильный браузер может принять за
   двойной тап и зумнуть страницу вместо второго клика — двойной тап на разных
   координатах так не срабатывает, поэтому баг всплывает именно на повторном выборе
   одного и того же пункта. touch-action: manipulation убирает эту задержку/жест на
   кнопках, не трогая обычный pinch-zoom всей страницы. */
button {
    touch-action: manipulation;
}

/* --- утилита: блокировать нативное выделение текста/картинок, лупу и драг иконки
   при тапе/долгом нажатии. Без неё браузер на телефоне вместо клика по кастомному
   жестовому элементу (кнопка свайпа, пункт меню и т.п.) может начать выделение или
   драг картинки — тогда первый тап "съедается", и реагирует только повторный клик.
   Вешать на любой кастомный тап/свайп/долгое-нажатие элемент — писать заново не надо. */
.no-native-select {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#app {
    min-height: 100%;
    max-width: var(--app-max-width);
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}

.input-field {
    width: 100%;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 16px;
}

.input-field.error {
    border-color: var(--color-error);
}

.liquid-glass {
    backdrop-filter: blur(var(--blur-glass));
    -webkit-backdrop-filter: blur(var(--blur-glass));
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

/* ==================== auth.php ==================== */

.auth-step {
    display: none;
}

.auth-step[data-active="true"] {
    display: flex;
}

/* --- log in / 00: splash --- */

.auth-splash {
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100dvh;
    width: 100%;
    background: linear-gradient(204.46deg, rgb(135, 147, 182) 0.12%, rgb(103, 115, 145) 20.317%, rgb(1, 5, 18) 95.897%);
    animation: auth-splash-fade-in 0.6s ease both;
}

.auth-splash.is-leaving {
    animation: auth-splash-fade-out 0.4s ease both;
}

.auth-splash__icon {
    width: 48px;
    height: 48px;
    margin-bottom: 39.5dvh;
}

.auth-splash__icon img {
    width: 100%;
    height: 100%;
}

.auth-splash__logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

.auth-splash__logo img {
    display: block;
}

.auth-splash__logo-monolit {
    width: 110px;
    height: 24.6px;
}

.auth-splash__logo-chat {
    width: 51.8px;
    height: 8.8px;
}

@keyframes auth-splash-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes auth-splash-fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* --- log in / 01: выбор способа входа --- */

.auth-method {
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 34dvh;
    height: 100dvh;
    width: 100%;
    background: #f4f4f5;
    animation: auth-step-fade-in 0.4s ease both;
}

.auth-method__top {
    display: flex;
    flex-direction: column;
    gap: 48px;
    width: 100%;
}

.auth-method__header {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
    padding: 0 24px;
    text-align: center;
}

.auth-method__title {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    color: #1c2233;
}

.auth-method__subtitle {
    margin: 0;
    font-size: 16px;
    color: #787b83;
}

.auth-method__buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 0 24px;
    width: 100%;
}

.auth-method__button {
    display: flex;
    align-items: center;
    gap: 18px;
    width: 100%;
    height: 60px;
    padding: 16px 40px;
    border: none;
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 2px 6.5px rgba(185, 190, 204, 0.16);
    font-size: 16px;
    font-weight: 600;
    color: #1c2233;
    letter-spacing: 0.08px;
    cursor: pointer;
    text-align: left;
}

.auth-method__button-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.auth-method__footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

.auth-method__footer img {
    width: 113px;
    height: 42px;
}

@keyframes auth-step-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.auth-step.is-leaving:not(.auth-splash) {
    animation: auth-step-fade-out 0.25s ease both;
}

@keyframes auth-step-fade-out {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-8px); }
}

/* --- log in / 02-04, password: форма с одним полем --- */

.auth-form {
    flex-direction: column;
    min-height: 100dvh;
    width: 100%;
    background: #f4f4f5;
    padding-top: 54px;
    animation: auth-step-fade-in 0.4s ease both;
}

.auth-form__nav {
    padding: 0 16px;
}

.auth-form__back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 10px 0;
    background: none;
    border: none;
    color: #787b83;
    font-size: 16px;
    cursor: pointer;
}

.auth-form__back img {
    width: 24px;
    height: 24px;
}

.auth-form__header {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
    text-align: center;
    padding: 44px 24px 0;
}

.auth-form__title {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    color: #1c2233;
}

.auth-form__subtitle {
    margin: 0;
    font-size: 16px;
    color: #787b83;
}

.auth-form__body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0 24px;
    margin-top: 48px;
}

.auth-form__input {
    width: 100%;
    height: 60px;
    padding: 16px 32px;
    border: none;
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 2px 6.5px rgba(185, 190, 204, 0.16);
    font-size: 16px;
    font-weight: 600;
    color: #1c2233;
    font-family: inherit;
}

.auth-form__input::placeholder {
    color: #b9becc;
    font-weight: 600;
}

.auth-form__error {
    margin: 0;
    color: #f37269;
    font-size: 14px;
    font-weight: 500;
    display: none;
}

.auth-form__error.is-visible {
    display: block;
}

.auth-form__submit-wrap {
    padding: 24px;
    margin-top: 40px;
    display: flex;
    justify-content: center;
}

.auth-form__submit {
    position: relative;
    width: 100%;
    height: 60px;
    border: none;
    border-radius: 60px;
    background: rgba(185, 190, 204, 0.3);
    color: #ffffff;
    font-size: 17px;
    font-family: inherit;
    cursor: not-allowed;
    transition: background 0.2s ease, width 0.25s cubic-bezier(0.4, 0, 0.2, 1), border-radius 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.auth-form__submit.is-enabled {
    background: #1c2233;
    cursor: pointer;
}

.auth-form__submit .btn-label {
    display: inline-block;
    transition: opacity 0.15s ease;
}

.auth-form__submit .btn-spinner {
    display: none;
    position: absolute;
    left: 50%;
    top: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    animation: btn-spin 0.7s linear infinite;
}

.auth-form__submit.is-loading {
    width: 60px;
    background: #1c2233;
    pointer-events: none;
}

.auth-form__submit.is-loading .btn-label {
    opacity: 0;
}

.auth-form__submit.is-loading .btn-spinner {
    display: block;
}

@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

@keyframes shake-x {
    10%, 90% { transform: translateX(-1px); }
    20%, 80% { transform: translateX(2px); }
    30%, 50%, 70% { transform: translateX(-4px); }
    40%, 60% { transform: translateX(4px); }
}

.is-shake {
    animation: shake-x 0.4s ease;
}

/* --- log in / 05-09: код подтверждения --- */

.auth-code {
    display: flex;
    gap: 24px;
    padding: 0 24px;
    width: 100%;
    margin-top: 48px;
    transition: opacity 0.2s ease;
}

.auth-code.is-checking {
    opacity: 0.5;
    pointer-events: none;
}

.auth-code__group {
    display: flex;
    flex: 1;
    gap: 8px;
    min-width: 0;
}

.auth-code__input {
    flex: 1;
    min-width: 0;
    height: 60px;
    border: 1.5px solid transparent;
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 2px 6.5px rgba(185, 190, 204, 0.16);
    font-size: 24px;
    font-family: inherit;
    text-align: center;
    color: #1c2233;
}

.auth-code__input:focus {
    outline: none;
    border-color: rgba(185, 190, 204, 0.3);
}

.auth-code__input.is-error {
    color: #f37269;
}

.auth-code__error {
    text-align: center;
    padding: 0 24px;
    margin-top: 16px !important;
}

.auth-code__resend-wrap {
    margin-top: 40px;
    padding: 0 24px;
    text-align: center;
}

.auth-code__timer {
    margin: 0;
    font-size: 14px;
    color: #787b83;
}

/* --- log in / 10, 23, 11: профиль --- */

.auth-profile__body {
    gap: 16px;
}

.auth-profile__field {
    position: relative;
}

.auth-form__input--with-icon {
    padding-right: 48px;
}

.auth-profile__info-button {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    opacity: 0.5;
}

.auth-profile__info-button img {
    width: 100%;
    height: 100%;
}

/* --- Bottom Sheet (переиспользуемый компонент, см. также раздел 6 ТЗ) --- */

.bottom-sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 40;
}

.bottom-sheet-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

.bottom-sheet {
    position: fixed;
    left: 50%;
    bottom: 0;
    width: 100%;
    max-width: var(--app-max-width);
    background: rgba(245, 245, 245, 0.85);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-radius: 34px 34px 0 0;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.15);
    z-index: 41;
    transform: translate(-50%, 100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    padding-bottom: env(safe-area-inset-bottom);
}

.bottom-sheet.is-dragging {
    transition: none;
}

.bottom-sheet.is-open {
    transform: translate(-50%, 0);
}

.bottom-sheet__grabber-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px 0 22px;
    margin: -10px 0 -12px;
    touch-action: none;
    cursor: grab;
    /* Тянуть за граббер — тоже жест (см. BottomSheet.init в app.js), а не просто тап;
       без этого iOS может показать callout/выделение, если палец на миг замер перед
       движением. Тот же набор свойств, что и в .no-native-select. */
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
    -webkit-tap-highlight-color: transparent;
}

.bottom-sheet__grabber-wrap:active {
    cursor: grabbing;
}

.bottom-sheet__grabber {
    width: 40px;
    height: 4px;
    border-radius: 100px;
    background: #b9becc;
    opacity: 0.6;
}

.bottom-sheet__content {
    padding: 12px 31px 32px;
}

.bottom-sheet__title {
    font-size: 20px;
    font-weight: 700;
    color: #1c2233;
    line-height: 1.3;
    margin: 0 0 16px;
}

.bottom-sheet__list {
    margin: 0;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.bottom-sheet__list li {
    font-size: 15px;
    line-height: 1.3;
    color: #1c2233;
}

/* ==================== chats.php ==================== */

.chats-page {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    background: #f8f8f8;
    color: #1c2233;
}

.liquid-glass-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 48px;
    padding: 0 14px;
    border: none;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 1px 24px rgba(153, 150, 150, 0.19);
    color: #1c2233;
    cursor: pointer;
}

.chats-navbar {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    padding: 12px 24px calc(24px + env(safe-area-inset-bottom));
}

.chats-navbar__section-btn {
    font-size: 17px;
    font-weight: 600;
    font-family: inherit;
}

.chats-navbar__dots {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chats-navbar__dots .dot {
    width: 6px;
    height: 6px;
    border-radius: 6px;
    background: #cdd0db;
}

.chats-navbar__dots .dot.is-active {
    background: #1c2233;
}

.chats-navbar__right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chats-navbar__filter-btn {
    padding: 0 22px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
}

.chats-navbar__plus-btn {
    width: 48px;
    padding: 0;
}

.chats-navbar__plus-btn img {
    width: 22px;
    height: 22px;
}

.chats-content {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: pan-y;
}

.chats-content__track {
    display: flex;
    height: 100%;
    transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
}

.chats-content__track.is-dragging {
    transition: none;
}

.chats-content__pane {
    flex: 0 0 auto;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    touch-action: pan-y;
    /* Явно серый, а не полагаемся на просвечивание сквозь .chats-page — гарантирует,
       что зазор между рядами (margin у .chat-swipe) всегда виден на сером, а не на
       случайно белом фоне. */
    background: #f8f8f8;
}

.chats-content__inner {
    min-height: 100%;
    /* margin-bottom стоит на каждой строке — но так первую строку сверху не от чего
       отделить, она упирается прямо в шапку списка. Добавляем свой отступ сверху. */
    padding-top: 16px;
    animation: auth-step-fade-in 0.25s ease both;
}

/* Группа закреплённых чатов — общий серый фон со скруглением только снизу (сверху
   ряды и так упираются в самый верх списка, скруглять нечего), как в макете Figma. */
.chats-pinned-group {
    background: #f4f4f5;
    border-radius: 0 0 38px 38px;
    overflow: hidden;
}

/* Плавный фолбэк-переход для ещё не закэшированных разделов (нечего показать вживую при драге) */
.chats-content__inner.is-leaving-left {
    animation: chats-slide-out-left 0.2s ease both;
}

.chats-content__inner.is-leaving-right {
    animation: chats-slide-out-right 0.2s ease both;
}

@keyframes chats-slide-out-left {
    to { opacity: 0; transform: translateX(-24px); }
}

@keyframes chats-slide-out-right {
    to { opacity: 0; transform: translateX(24px); }
}

/* --- empty-chats-welcome --- */

.chats-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    min-height: 100%;
    padding: 32px;
    text-align: center;
}

.chats-empty__icon {
    width: 140px;
    height: 140px;
    border-radius: 40px;
    object-fit: cover;
}

.chats-empty__text {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.chats-empty__title {
    margin: 0;
    font-size: 28px;
    font-weight: 700;
    color: #1c2233;
}

.chats-empty__subtitle {
    margin: 0;
    font-size: 16px;
    color: #787b83;
    max-width: 260px;
}

.chats-empty__button {
    margin-top: 8px;
    padding: 16px 28px;
    border: none;
    border-radius: 24px;
    background: #1c2233;
    color: #ffffff;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}

/* --- список чатов (когда есть данные) --- */

.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 0 20px;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
}

/* В расширенном/детальном режиме аватар — НЕ круг, а высокая скруглённая капсула
   56x72 (radius 40px), на всю высоту ряда (72px), как в макете Figma; круглый аватар
   только в компактном режиме (см. .chat-item-compact__avatar ниже). */
.chat-item__avatar {
    flex-shrink: 0;
    width: 56px;
    height: 72px;
}

/* Обрезка фото/инициала под скруглённую капсулу — на ОТДЕЛЬНОЙ внутренней обёртке,
   а не на .chat-item__avatar: иначе overflow:hidden срезает мьют-бейдж, который по
   макету должен выступать НАРУЖУ за край аватара, а не быть обрезанным внутри него. */
.chat-item__avatar-photo {
    width: 100%;
    height: 100%;
    border-radius: 40px;
    background: #1c2233;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    overflow: hidden;
}

.chat-item__avatar-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

.chat-item__top-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.chat-item__name {
    font-size: 16px;
    font-weight: 600;
    color: #1c2233;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item__time {
    flex-shrink: 0;
    font-size: 13px;
    color: #787b83;
}

.chat-item__bottom-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.chat-item__preview {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    color: #787b83;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item__preview.is-unread {
    color: #1c2233;
    font-weight: 600;
}

.chat-item__status-icon {
    width: 9px;
    height: 8px;
    flex-shrink: 0;
}

.chat-item__unread {
    flex-shrink: 0;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: #4d7cff;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- компактный режим списка чатов --- */

.chat-item-compact {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 8px 16px;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
}

.chat-item-compact__avatar {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
}

.chat-item-compact__avatar-photo {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #1c2233;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 600;
    overflow: hidden;
}

.chat-item-compact__avatar-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-item-compact__name {
    font-size: 17px;
    color: rgba(28, 34, 51, 0.9);
}

.chat-item-compact__name.is-unread {
    font-weight: 700;
    color: #1c2233;
}

/* --- режим массового выбора чатов --- */

.chat-item__checkbox {
    display: none;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid #cdd0db;
    align-items: center;
    justify-content: center;
}

.chat-item__checkbox img {
    width: 13px;
    height: 13px;
    opacity: 0;
}

/* Чекбоксы показываются только когда список в режиме выбора — класс вешается на
   #section-content целиком, а не на каждый ряд (см. chat-select.js). */
#section-content.is-select-mode .chat-item__checkbox {
    display: flex;
}

.chat-swipe.is-selected .chat-item__checkbox {
    background: #1c2233;
    border-color: #1c2233;
}

.chat-swipe.is-selected .chat-item__checkbox img {
    opacity: 1;
}

/* Панель массовых действий — плавающая внизу, тот же приём "стекла", что и у
   подтверждения удаления, показывается только когда что-то выбрано. */
.chats-select-bar {
    position: fixed;
    left: 50%;
    bottom: calc(16px + env(safe-area-inset-bottom));
    width: calc(100% - 32px);
    max-width: calc(var(--app-max-width) - 32px);
    z-index: 42;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 10px;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(30px) saturate(1.8);
    -webkit-backdrop-filter: blur(30px) saturate(1.8);
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.6);
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 12px);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.2s ease;
}

.chats-select-bar.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, 0);
}

.chats-select-bar__btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 13px;
    color: #1c2233;
    cursor: pointer;
    padding: 6px 10px;
}

.chats-select-bar__btn img {
    width: 22px;
    height: 22px;
}

.chats-select-bar__btn--danger {
    color: #ff3b30;
}

/* --- свайп действий на элементе чата (список чатов) --- */

.chat-swipe {
    position: relative;
    overflow: hidden;
    background: #fff;
    /* margin вместо gap — gap на обычном block-контейнере не везде надёжно
       поддерживается на мобильных браузерах, margin работает без исключений
       и не зависит от того, свайпнут ряд сейчас или нет. */
    margin-bottom: 16px;
}

.chat-swipe__front {
    --swipe-progress: 0;
    position: relative;
    z-index: 1;
    touch-action: pan-y;
    background-color: color-mix(in srgb, #ffffff, #eceef1 calc(var(--swipe-progress, 0) * 100%));
    border-radius: calc(var(--swipe-progress, 0) * 36px);
    /* Пружинный отскок при открытии/закрытии (easeOutBack) — лёгкий перехлёст и оседание,
       как в нативных iOS-жестах, без JS-анимации и сторонних библиотек. */
    transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1),
                clip-path 0.32s cubic-bezier(0.34, 1.56, 0.64, 1),
                background-color 0.32s cubic-bezier(0.34, 1.56, 0.64, 1),
                border-radius 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chat-swipe__front.is-dragging {
    transition: none;
}

/* Пока тянут (--swipe-progress растёт от 0 до 1) — имя/сообщение/время карточки
   плавно гаснут, а не просто уезжают вместе с ней целиком (см. дизайн в Figma). */
.chat-item__body,
.chat-item-compact__name {
    opacity: calc(1 - var(--swipe-progress, 0) * 1.6);
    transition: opacity 0.05s linear;
}

.chat-swipe__actions {
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
}

.chat-swipe__actions--left {
    right: 0;
    /* Доп. отступ слева — иначе первая кнопка (mute) слегка обрезается краем
       схлопывающейся карточки (overflow:hidden на .chat-swipe). */
    padding-left: 20px;
}

.chat-swipe__actions--right {
    left: 0;
}

.chat-swipe__btn {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: #eceef1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
}

.chat-swipe__btn img {
    width: 20px;
    height: 20px;
}

.chat-swipe__btn--menu {
    background: #417ee9;
}

.chat-item__avatar,
.chat-item-compact__avatar {
    position: relative;
}

.chat-item__mute-badge {
    position: absolute;
    right: -4px;
    bottom: -2px;
    width: 24px;
    height: 22px;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-item__mute-badge img {
    width: 12px;
    height: 12px;
}

/* --- меню чата (bottom sheet по клику на синюю кнопку в свайпе, "Menu - iPhone" из Figma) --- */

.chat-options-sheet {
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    /* Базовый .bottom-sheet (0.85 alpha, только blur) на практике почти не показывал
       никакого просвечивания на телефоне — при такой непрозрачности блюру буквально
       нечего было показать. Тут ниже альфа + saturate() (тот самый приём "vibrancy" из
       iOS — не просто мутит, а поднимает насыщенность того, что просвечивает) + рамка-
       блик и тень, чтобы стекло читалось как стекло, даже если backdrop-filter слабый. */
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(30px) saturate(1.8);
    -webkit-backdrop-filter: blur(30px) saturate(1.8);
    border-top: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.chat-options-sheet__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px 8px;
}

.chat-options-sheet__spacer {
    width: 36px;
}

.chat-options-sheet__close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    cursor: pointer;
}

.chat-options-sheet__close img {
    width: 18px;
    height: 18px;
}

.chat-options-sheet__item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    border: none;
    background: none;
    font-size: 17px;
    font-weight: 500;
    color: #333333;
    cursor: pointer;
    text-align: left;
}

.chat-options-sheet__item:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.chat-options-sheet__item img {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.chat-options-sheet__item--danger span {
    color: #ff5343;
}

.chat-options-sheet__separator {
    height: 1px;
    margin: 4px 20px 8px;
    background: #e6e6e6;
}

/* --- шторка "В папку" / фильтр папок по кнопке "Все" (переиспользуют один и тот же
   список — просто разный заголовок и смысл клика по строке, см. chat-folders.js) --- */

.folder-picker-sheet__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px 8px;
}

.folder-picker-sheet__spacer,
.folder-picker-sheet__add {
    width: 36px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    cursor: pointer;
}

.folder-picker-sheet__add img {
    width: 24px;
    height: 24px;
}

.folder-picker-sheet__title {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    color: #1c2233;
}

.folder-picker-sheet__list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
    max-height: 50vh;
    overflow-y: auto;
}

.folder-picker-sheet__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 48px;
    padding: 4px 16px;
    border: none;
    border-radius: 28px;
    background: none;
    cursor: pointer;
    text-align: left;
}

.folder-picker-sheet__row.is-static {
    cursor: default;
}

.folder-picker-sheet__label {
    font-size: 16px;
    letter-spacing: -0.43px;
    color: #1c2233;
}

.folder-picker-sheet__check-badge {
    display: none;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #1c2233;
}

.folder-picker-sheet__check-badge img {
    width: 12px;
    height: 12px;
}

.folder-picker-sheet__row.is-checked .folder-picker-sheet__check-badge {
    display: flex;
}

/* --- подтверждение удаления чата (маленький алерт снизу, не bottom-sheet) --- */

.chat-delete-confirm {
    position: fixed;
    left: 50%;
    bottom: calc(16px + env(safe-area-inset-bottom));
    width: calc(100% - 32px);
    max-width: calc(var(--app-max-width) - 32px);
    /* Выше .chats-select-bar (тоже 42) — иначе при массовом удалении панель
       выбора рисуется поверх диалога подтверждения и перехватывает тапы. */
    z-index: 43;
    display: flex;
    flex-direction: column;
    gap: 8px;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 12px);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.2s ease;
}

.chat-delete-confirm.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, 0);
}

.chat-delete-confirm__card {
    background: rgba(245, 245, 245, 0.85);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-radius: 20px;
    padding: 20px;
    text-align: center;
}

.chat-delete-confirm__title {
    margin: 0 0 4px;
    font-size: 17px;
    font-weight: 600;
    color: #1c2233;
}

.chat-delete-confirm__subtitle {
    margin: 0 0 16px;
    font-size: 14px;
    color: #787b83;
}

.chat-delete-confirm__delete {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.05);
    color: #ff3b30;
    font-size: 17px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}

.chat-delete-confirm__cancel {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 20px;
    background: rgba(245, 245, 245, 0.85);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    color: #1c2233;
    font-size: 17px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}

/* --- разделы-заглушки (Задачи/Заметки/Архив) --- */

.chats-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 100%;
    padding: 32px;
    text-align: center;
}

.chats-placeholder__title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #1c2233;
}

.chats-placeholder__subtitle {
    margin: 0;
    font-size: 15px;
    color: #787b83;
}

/* --- меню разделов (bottom sheet, "Menu - iPhone" из Figma) --- */

.section-menu {
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.section-menu__quick-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 16px 24px;
}

.section-menu__segments {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1;
    min-width: 0;
}

.section-menu__segment {
    height: 40px;
    padding: 6px 22px;
    border: none;
    border-radius: 20px;
    background: none;
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    color: #1c2233;
    cursor: pointer;
}

.section-menu__segment.is-active {
    background: #ededed;
}

.section-menu__avatar-btn {
    display: block;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    background: #f7f7f7;
}

.section-menu__avatar-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.section-menu__title {
    margin: 0;
    padding: 4px 24px 10px;
    font-size: 13px;
    font-weight: 510;
    color: #bfbfbf;
}

.section-menu__item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 24px;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
}

.section-menu__item-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.section-menu__item span {
    font-size: 16px;
    color: #333333;
}

.section-menu__separator {
    height: 1px;
    margin: 0 24px 8px;
    background: #e6e6e6;
}

/* --- "Новый чат" (список чатов / плюсик / 11-13) --- */

.new-chat-sheet {
    background: #ffffff;
    border-radius: 38px 38px 0 0;
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
    transition: height 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.new-chat-sheet.is-expanded {
    height: 98dvh;
    display: flex;
    flex-direction: column;
}

.new-chat-sheet.is-expanded .new-chat-sheet__results {
    flex: 1;
    height: auto;
}

.new-chat-sheet__toolbar {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.new-chat-sheet__title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 36px;
    padding: 0 16px;
}

.new-chat-sheet__spacer {
    width: 36px;
    height: 36px;
}

.new-chat-sheet__title {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    color: #1c2233;
}

.new-chat-sheet__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #f4f4f5;
    cursor: pointer;
}

.new-chat-sheet__close img {
    width: 16px;
    height: 16px;
}

.new-chat-sheet__search-wrap {
    padding: 24px 16px 0;
}

.new-chat-sheet__search {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 46px;
    padding: 0 16px;
    border-radius: 100px;
    background: #f4f4f5;
}

.new-chat-sheet__search img {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.new-chat-sheet__search input {
    flex: 1;
    min-width: 0;
    border: none;
    background: none;
    font-family: inherit;
    /* iOS Safari зумит при фокусе на инпуте с font-size < 16px. */
    font-size: 16px;
    font-weight: 500;
    color: #1c2233;
}

.new-chat-sheet__search input::placeholder {
    color: #787b83;
}

.new-chat-sheet__group-row {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    padding: 6px 16px;
    margin-top: 6px;
    border: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    background: none;
    cursor: pointer;
    text-align: left;
}

.new-chat-sheet__group-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 60px;
    background: #f8f8fa;
    flex-shrink: 0;
}

.new-chat-sheet__group-icon img {
    width: 20px;
    height: 20px;
}

.new-chat-sheet__group-label {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    color: #1c2233;
}

.new-chat-sheet__group-chevron {
    width: 16px;
    height: 16px;
    transform: rotate(90deg);
}

.new-chat-sheet__results {
    height: 45dvh;
    overflow-y: auto;
    padding-top: 10px;
}

.new-chat-sheet__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 0 48px;
}

.new-chat-sheet__empty-icon {
    width: 76px;
    height: 72px;
    border-radius: 16px;
    object-fit: cover;
    margin-bottom: 24px;
}

.new-chat-sheet__empty-title {
    margin: 0 0 12px;
    font-size: 24px;
    font-weight: 700;
    color: #1c2233;
}

.new-chat-sheet__empty-subtitle {
    margin: 0;
    font-size: 16px;
    line-height: 1.4;
    color: #787b83;
}

.new-chat-sheet__group-title {
    margin: 0;
    padding: 8px 16px 6px;
    font-size: 13px;
    color: #787b83;
}

.new-chat-result-item {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 8px 16px;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
}

.new-chat-result-item__avatar {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    border-radius: 18px;
    background: #d9d9d9;
    color: #1c2233;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    overflow: hidden;
}

.new-chat-result-item__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.new-chat-result-item__body {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.new-chat-result-item__name {
    font-size: 16px;
    font-weight: 600;
    color: #1c2233;
}

.new-chat-result-item__username {
    font-size: 14px;
    color: #787b83;
}

.new-chat-sheet__no-results {
    padding: 24px 16px;
    text-align: center;
    color: #787b83;
    font-size: 15px;
}

/* --- "Новая папка" (список чатов / плюсик / 19-20) --- */

.new-folder-sheet {
    height: 98dvh;
    display: flex;
    flex-direction: column;
    background: #f4f4f5;
    border-radius: 38px 38px 0 0;
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

.new-folder-sheet__toolbar {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
}

.new-folder-sheet__title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 36px;
    padding: 0 16px;
}

.new-folder-sheet__title {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    color: #1c2233;
}

.new-folder-sheet__close,
.new-folder-sheet__confirm {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.new-folder-sheet__close {
    background: rgba(0, 0, 0, 0.05);
}

.new-folder-sheet__close img {
    width: 16px;
    height: 16px;
}

.new-folder-sheet__confirm {
    background: #1c2233;
}

.new-folder-sheet__confirm img {
    width: 14px;
    height: 14px;
}

.new-folder-sheet__input-wrap {
    flex-shrink: 0;
    padding: 24px 16px 0;
}

.new-folder-sheet__input {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 28px;
    background: #ffffff;
    box-shadow: 0 4px 60px rgba(136, 136, 136, 0.18);
    font-family: inherit;
    font-size: 17px;
    font-weight: 600;
    color: #1c2233;
}

.new-folder-sheet__input::placeholder {
    color: #9498a3;
}

.new-folder-sheet__section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    padding: 24px 24px 10px;
    font-size: 13px;
    font-weight: 510;
    letter-spacing: -0.08px;
    color: #bfbfbf;
    text-transform: uppercase;
}

.new-folder-sheet__selected-count {
    color: #787b83;
    text-transform: none;
}

.new-folder-sheet__list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    background: #ffffff;
}

.folder-chat-row {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    min-height: 64px;
    padding: 2px 16px;
    /* Сброс на случай, если это <button> (шторка "Переслать"), а не <div>
       (шторка "Новая папка") — на div эти свойства ни на что не влияют. */
    border: none;
    background: none;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}

.folder-chat-row__name {
    flex: 1;
    min-width: 0;
    font-size: 17px;
    color: #1c2233;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.folder-chat-row .chat-item__checkbox {
    display: flex;
}

.folder-chat-row.is-selected .chat-item__checkbox {
    background: #1c2233;
    border-color: #1c2233;
}

.folder-chat-row.is-selected .chat-item__checkbox img {
    opacity: 1;
}
