/*
 * Чат поддержки. Базовые токены берутся из cabinet.css; здесь добавлены слои поверхностей
 * и «стеклянные» блики, чтобы интерфейс не читался плоским: каждая поверхность = заливка
 * + верхний светлый кант (inset) + мягкая тень под ней.
 */

.support-body {
    overflow: hidden; /* прокручивается лента, а не страница */
}

:root {
    /* Слои поверхностей: чем выше индекс, тем «ближе» к пользователю */
    --sup-surface-0: #0c0b0f;
    --sup-surface-1: #131218;
    --sup-surface-2: #191821;
    --sup-surface-3: #201f2a;

    /* Блик по верхней кромке — главный приём объёма во всём интерфейсе */
    --sup-edge: inset 0 1px 0 rgba(255, 255, 255, 0.06);
    --sup-edge-strong: inset 0 1px 0 rgba(255, 255, 255, 0.1);

    /* Кольцо-обводка тенью вместо border: не влияет на раскладку и одинаково
       читается на любом фоне (у нас под пузырями лежит градиент оболочки). */
    --sup-ring: 0 0 0 1px rgba(255, 255, 255, 0.08);
    --sup-ring-hover: 0 0 0 1px rgba(255, 255, 255, 0.13);

    --sup-lift-sm: 0 2px 6px rgba(0, 0, 0, 0.35);
    --sup-lift: 0 10px 26px -12px rgba(0, 0, 0, 0.75);
    --sup-lift-lg: 0 28px 60px -28px rgba(0, 0, 0, 0.9);

    /* Пузырь пользователя: приглушённый янтарь. Чистый #ff6b00 на большой площади
       выжигает глаза и перетягивает внимание с текста — берём на пару тонов глубже. */
    --sup-mine-1: #dd6a24;
    --sup-mine-2: #bf4f10;
    --sup-mine-text: #fff8f3;

    /* Акценты интерфейса (кнопки, иконки) остаются яркими — они мелкие */
    --sup-accent-1: #ff7a1f;
    --sup-accent-2: #f2600b;

    --sup-ico: 20px;
}

/* ─────────────── Иконки ─────────────── */

.ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 0;
}
.ico-svg { width: var(--sup-ico); height: var(--sup-ico); display: block; }
.ico-sm .ico-svg { width: 15px; height: 15px; }
.ico-xl .ico-svg { width: 38px; height: 38px; }

/* ─────────────── Каркас страницы ─────────────── */

.support-container {
    max-width: 880px;
    padding-bottom: 20px;
    /* --app-h выставляет JS из visualViewport (клавиатура на мобильных); 100dvh — фолбэк. */
    height: var(--app-h, 100dvh);
    display: flex;
    flex-direction: column;
}

.support-container .header { padding: 20px 0 22px; }

.support-container .main-content {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.support-container .view { min-height: 0; }

#chat-view.view {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Кнопки шапки одной высоты и одной геометрии */
.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-pill {
    height: 40px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    /* Иконка слева: паддинг с её стороны на 2px меньше, иначе кнопка
       выглядит смещённой вправо. */
    padding: 0 16px 0 14px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(180deg, var(--sup-surface-2), var(--sup-surface-1));
    box-shadow: var(--sup-ring), var(--sup-edge), var(--sup-lift-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.18s var(--ease-out), border-color 0.18s var(--ease-out),
                transform 0.18s var(--ease-out), box-shadow 0.18s var(--ease-out);
}
.btn-pill .ico-svg { width: 17px; height: 17px; }
.btn-pill:hover {
    color: var(--text-primary);
    transform: translateY(-1px);
    box-shadow: var(--sup-ring-hover), var(--sup-edge-strong), var(--sup-lift);
}
.btn-pill:active { transform: scale(0.96); }

/* Выход — деструктивное действие: на hover краснеет, чтобы не нажали по инерции. */
#btn-logout:hover {
    color: var(--danger);
    background: linear-gradient(180deg, rgba(255, 77, 79, 0.16), rgba(255, 77, 79, 0.08));
    box-shadow: 0 0 0 1px rgba(255, 77, 79, 0.35), var(--sup-edge), var(--sup-lift);
}

.logo { text-decoration: none; color: inherit; }

/* Экран входа общий с кабинетом, но контейнер поддержки — флекс-колонка фиксированной
   высоты. Поэтому центрируем растяжкой вью, а не расчётом от 100dvh: высоту здесь
   задаёт --app-h (visualViewport), и вычитать из неё шапку не из чего. */
.support-container #login-view {
    flex: 1;
    min-height: 0;
    margin-bottom: 0;
}

/* Подсказка живёт под карточкой, как правовая строка в кабинете, — и повторяет
   её отступ, чтобы текст стоял в той же колонке, что поля внутри карточки. */
.login-alt-hint {
    margin-top: 16px;
    padding-inline: var(--login-card-pad);
    text-align: center;
    font-size: 13px;
    color: var(--text-faint);
    line-height: 1.6;
    text-wrap: pretty;
}
.login-alt-hint a { color: var(--orange); text-decoration: none; }
.login-alt-hint a:hover { text-decoration: underline; }

.fox-icon-login .ico-svg { width: 30px; height: 30px; }

/* ─────────────── Оболочка чата ─────────────── */

.chat-shell {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: var(--radius-xl);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0) 220px),
        var(--sup-surface-0);
    box-shadow: var(--sup-ring), var(--sup-edge), var(--sup-lift-lg);
}

.chat-head {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 15px 20px;
    border-bottom: 1px solid var(--card-border);
    background: linear-gradient(180deg, var(--sup-surface-2), var(--sup-surface-1));
    box-shadow: var(--sup-edge), 0 6px 20px -14px rgba(0, 0, 0, 0.9);
    flex-shrink: 0;
    z-index: 3;
}

.chat-head-avatar {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 15px;
    display: grid;
    place-items: center;
    background: linear-gradient(150deg, var(--sup-accent-1), var(--sup-accent-2));
    color: #fff;
    flex-shrink: 0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 8px 18px -8px rgba(255, 107, 0, 0.7);
}
.chat-head-avatar .ico-svg { width: 22px; height: 22px; }

.avatar-ring {
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--success);
    border: 2.5px solid var(--sup-surface-1);
}

.chat-head-text { flex: 1; min-width: 0; }
.chat-head-title { font-weight: 650; font-size: 16px; letter-spacing: -0.2px; }
.chat-head-sub { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

.conn-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 28px;
    padding: 0 11px;
    border-radius: 999px;
    background: rgba(40, 199, 111, 0.1);
    border: 1px solid rgba(40, 199, 111, 0.25);
    color: var(--success);
    font-size: 12px;
    font-weight: 500;
    flex-shrink: 0;
    transition-property: color, background-color, border-color;
    transition-duration: 0.3s;
    transition-timing-function: var(--ease-out);
}
.conn-pill.offline {
    background: rgba(255, 77, 79, 0.1);
    border-color: rgba(255, 77, 79, 0.28);
    color: var(--danger);
}
.conn-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 8px currentColor;
}
.conn-pill.offline .conn-dot { animation: connPulse 1.3s infinite; }
@keyframes connPulse { 50% { opacity: 0.25; } }

/* ─────────────── Лента ─────────────── */

.chat-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 8px 20px 14px;
    scroll-behavior: smooth;
}
.chat-scroll::-webkit-scrollbar { width: 10px; }
.chat-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.09);
    border-radius: 8px;
    border: 3px solid transparent;
    background-clip: content-box;
}
.chat-scroll::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.16); background-clip: content-box; }

.chat-empty {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-secondary);
    gap: 10px;
    padding: 24px 20px;
}
.chat-empty-icon {
    width: 72px;
    height: 72px;
    border-radius: 24px;
    display: grid;
    place-items: center;
    background: linear-gradient(150deg, rgba(255, 122, 31, 0.2), rgba(255, 107, 0, 0.06));
    border: 1px solid rgba(255, 107, 0, 0.22);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 18px 34px -20px rgba(255, 107, 0, 0.8);
    color: var(--orange-2);
    margin-bottom: 6px;
}
.chat-empty-icon .ico-svg { width: 30px; height: 30px; }
.chat-empty h3 { font-size: 19px; color: var(--text-primary); letter-spacing: -0.3px; }
.chat-empty p { font-size: 14px; line-height: 1.65; max-width: 380px; }

.quick-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 14px;
}
.chip {
    height: 34px;
    padding: 0 14px;
    border-radius: 999px;
    border: none;
    background: linear-gradient(180deg, var(--sup-surface-2), var(--sup-surface-1));
    box-shadow: var(--sup-ring), var(--sup-edge);
    color: var(--text-secondary);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    transition-property: color, box-shadow, transform;
    transition-duration: 0.18s;
    transition-timing-function: var(--ease-out);
}
.chip:hover {
    color: var(--orange-2);
    transform: translateY(-1px);
    box-shadow: var(--sup-ring-hover), var(--sup-edge-strong), var(--sup-lift-sm);
}
.chip:active { transform: scale(0.96); }

/* Разделитель дня липнет к верху ленты при прокрутке */
/* В потоке, без sticky: два sticky-разделителя с разной шириной пиновались к top:0
   одновременно и наслаивались друг на друга во время прокрутки. */
.day-sep {
    display: flex;
    justify-content: center;
    padding: 12px 0 14px;
    pointer-events: none;
}
.day-sep span {
    font-size: 11.5px;
    font-weight: 500;
    letter-spacing: 0.3px;
    color: var(--text-secondary);
    background: rgba(24, 23, 31, 0.9);
    border: 1px solid var(--card-border);
    box-shadow: var(--sup-edge), var(--sup-lift-sm);
    padding: 5px 13px;
    border-radius: 999px;
}

.msg-system {
    display: block;
    text-align: center;
    font-size: 12.5px;
    color: var(--text-faint);
    margin: 12px auto;
    max-width: 78%;
    line-height: 1.5;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: 999px;
    padding: 6px 14px;
    width: fit-content;
}

/* ─────────────── Сообщения ─────────────── */

.msg-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 10px;
}
.msg-row.enter {
    animation: msgIn 0.26s var(--ease-out) both;
    will-change: transform, opacity;
}
.msg-row.mine { justify-content: flex-end; }
/* Подряд идущие сообщения одного автора жмутся друг к другу */
.msg-row.grouped { margin-bottom: 3px; }
.msg-row.grouped .bubble-meta { display: none; }
.msg-row.grouped .bubble { padding-bottom: 9px; }
.msg-row.pending .bubble { opacity: 0.6; }
.msg-row.failed .bubble { box-shadow: inset 0 0 0 1px var(--danger); }

@keyframes msgIn {
    from { opacity: 0; transform: translateY(10px) scale(0.985); }
    to   { opacity: 1; transform: none; }
}

/* Аватар оператора — только у последнего сообщения группы */
.msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    background: linear-gradient(150deg, var(--sup-surface-3), var(--sup-surface-2));
    border: 1px solid var(--card-border-strong);
    box-shadow: var(--sup-edge);
    color: var(--orange-2);
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 2px;
}
.msg-avatar.hidden { visibility: hidden; }

.bubble {
    position: relative;
    max-width: min(560px, 76%);
    padding: 9px 14px 7px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.48;
    word-break: break-word;
    transition: box-shadow 0.2s var(--ease-out);
}

.msg-row.theirs .bubble {
    background: linear-gradient(180deg, var(--sup-surface-3), var(--sup-surface-2));
    box-shadow: var(--sup-ring), var(--sup-edge), var(--sup-lift-sm);
    border-bottom-left-radius: 7px;
}
.msg-row.theirs.grouped .bubble { border-bottom-left-radius: 18px; }

.msg-row.mine .bubble {
    background: linear-gradient(160deg, var(--sup-mine-1), var(--sup-mine-2));
    color: var(--sup-mine-text);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 6px 16px -12px rgba(0, 0, 0, 0.85);
    border-bottom-right-radius: 7px;
}
.msg-row.mine.grouped .bubble { border-bottom-right-radius: 18px; }

.bubble-author {
    font-size: 12.5px;
    font-weight: 650;
    color: var(--orange-2);
    margin-bottom: 3px;
}

.bubble-text { white-space: pre-wrap; }
.bubble-text a { color: inherit; text-underline-offset: 2px; }
.msg-row.theirs .bubble-text a { color: var(--orange-2); }

.bubble-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    margin-top: 3px;
    font-size: 11px;
    line-height: 1;
    color: var(--text-faint);
}
.msg-row.mine .bubble-meta { color: rgba(255, 255, 255, 0.72); }
.ticks { display: inline-flex; }
.ticks .ico-svg { width: 14px; height: 14px; }
.msg-row.mine .ticks.read { color: #fff; }

/* ─────────────── Вложения ─────────────── */

.attach { margin: 1px 0 5px; }
.attach:first-child { margin-top: 0; }

/* Альбом: несколько медиа одного сообщения в одной сетке — выглядят как одно сообщение,
   хотя на сервер каждый файл ушёл отдельным вложением. */
.attach-album {
    display: grid;
    gap: 3px;
    grid-template-columns: 1fr 1fr;
    border-radius: 12px;
    overflow: hidden;
    max-width: 380px;
}
.attach-album .attach { margin: 0; }
/* Радиусы гасим на уровне .bubble.has-media, иначе полировочные правила (3 класса)
   перебьют по специфичности и вернут скругление отдельным ячейкам. */
.bubble.has-media .attach-album .attach-media,
.bubble.has-media .attach-album .attach-skeleton { border-radius: 0; width: 100%; height: 100%; outline: none; }
.bubble.has-media .attach-album .attach-media img,
.bubble.has-media .attach-album .attach-media video {
    width: 100%;
    height: 100%;
    max-height: none;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 0;
}
/* Одиночный элемент (пока в альбоме один файл) занимает всю ширину и не квадратится. */
.attach-album[data-count="1"] { grid-template-columns: 1fr; max-width: 300px; }
.bubble.has-media .attach-album[data-count="1"] .attach-media img,
.bubble.has-media .attach-album[data-count="1"] .attach-media video { aspect-ratio: auto; max-height: 340px; }
/* Три элемента: первый на всю ширину сверху, два снизу. */
.attach-album[data-count="3"] .attach:first-child { grid-column: 1 / -1; }
.attach-album[data-count="3"] .attach:first-child .attach-media img,
.attach-album[data-count="3"] .attach:first-child .attach-media video { aspect-ratio: 16 / 9; }
/* Общая рамка вокруг сетки, а не вокруг каждой ячейки. */
.bubble.has-media .attach-album {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
}
/* Ячейка-иконка (видео/файл без превью) в оптимистичном альбоме. */
.attach-media-icon {
    display: grid;
    place-items: center;
    aspect-ratio: 1 / 1;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.35);
}
.attach-media-icon .ico-svg { width: 26px; height: 26px; }

/* Индикатор отправки поверх альбома. */
.bubble.has-media { position: relative; }
.album-uploading {
    position: absolute;
    inset: 6px;
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 12px;
    pointer-events: none;
}

.attach-media {
    position: relative;
    display: block;
    border-radius: 14px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.28);
    /* Обводка медиа — чистый белый на 10%, а не тонированный neutral:
       тонированный кант ловит цвет поверхности и читается как грязь на краю. */
    outline: 1px solid rgba(255, 255, 255, 0.1);
    outline-offset: -1px;
}
.attach-media img,
.attach-media video {
    display: block;
    max-width: 100%;
    max-height: 340px;
    border-radius: 14px;
}
.attach-media img { cursor: zoom-in; transition: transform 0.4s var(--ease-out); }
.attach-media:hover img { transform: scale(1.015); }
.attach-media video { width: 100%; }

.attach-skeleton {
    width: 220px;
    height: 150px;
    border-radius: 14px;
    background: linear-gradient(100deg, var(--sup-surface-2) 30%, var(--sup-surface-3) 50%, var(--sup-surface-2) 70%);
    background-size: 220% 100%;
    animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer { to { background-position: -120% 0; } }

/* Не загрузилось — показываем причину и даём повторить, а не «мёртвый» текст.
   Фон — собственный непрозрачный: карточка появляется и внутри оранжевого пузыря
   пользователя, где полупрозрачная заливка теряла всякий контраст. */
.attach-error {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 12px 14px;
    border-radius: 14px;
    background: #241014;
    box-shadow: inset 0 0 0 1px rgba(255, 120, 122, 0.5);
    color: #f3d9da;
    font-size: 13px;
    max-width: 320px;
}
.attach-error > .ico { color: #ff6b6d; }
.attach-error-text { flex: 1; line-height: 1.4; }
.attach-error-title { color: #fff; font-weight: 600; }
.attach-error-sub { font-size: 11.5px; color: #e0a9ab; }
.attach-retry {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 28px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid var(--card-border-strong);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    flex-shrink: 0;
}
.attach-retry:hover { color: var(--text-primary); border-color: rgba(255, 255, 255, 0.22); }
.attach-retry:active { transform: scale(0.96); }
.attach-retry {
    transition-property: color, border-color, transform;
    transition-duration: 0.15s;
    transition-timing-function: var(--ease-out);
}
.attach-retry .ico-svg { width: 13px; height: 13px; }

.file-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.22);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.09);
    border: none;
    border-radius: 11px;
    cursor: pointer;
    text-align: left;
    color: inherit;
    font: inherit;
    width: 100%;
    min-width: 210px;
    transition-property: background-color, box-shadow, transform;
    transition-duration: 0.18s;
    transition-timing-function: var(--ease-out);
}
.file-card:hover { background: rgba(0, 0, 0, 0.3); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.16); }
.file-card:active { transform: scale(0.96); }
.file-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.09);
    box-shadow: var(--sup-edge);
    flex-shrink: 0;
}
.msg-row.theirs .file-icon { color: var(--orange-2); background: var(--orange-ghost); }
.file-info { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.file-name {
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.file-size { font-size: 11.5px; opacity: 0.72; }

/* Голосовое: реальная форма волны, а не декоративная полоска */
.voice {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 230px;
    padding: 3px 0;
}
.voice-play {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    display: grid;
    place-items: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.16s var(--ease-spring), filter 0.16s var(--ease-out);
}
.msg-row.mine .voice-play {
    background: rgba(255, 255, 255, 0.92);
    color: var(--sup-mine-2);
    box-shadow: 0 4px 12px -4px rgba(0, 0, 0, 0.5);
}
.msg-row.theirs .voice-play {
    background: linear-gradient(150deg, var(--sup-accent-1), var(--sup-accent-2));
    color: #fff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 6px 14px -6px rgba(255, 107, 0, 0.85);
}
.voice-play:hover { transform: scale(1.06); }
.voice-play:active { transform: scale(0.96); }
/* play-tri уже оптически центрирован в самом SVG — margin не нужен. */
.voice-play .ico-svg { width: 17px; height: 17px; }
.voice-play .icon-swap.is-play .ico-svg { width: 19px; height: 19px; }

.voice-wave {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 3px;
    height: 30px;
    cursor: pointer;
    min-width: 100px;
    max-width: 190px;
    overflow: hidden;
}
.voice-wave i {
    /* Фиксированная ширина, а не flex: тонкие «волоски» на всю ширину читаются
       как штриховка, а не как форма волны. */
    width: 3px;
    /* Сжимаются, но не растягиваются: при flex:0 0 полоски вылезали за контейнер
       на узких экранах и наезжали на длительность. */
    flex: 0 1 3px;
    min-width: 2px;
    border-radius: 3px;
    background: currentColor;
    opacity: 0.34;
    transition: opacity 0.15s linear, height 0.3s var(--ease-out);
}
.voice-wave i.played { opacity: 1; }
.msg-row.theirs .voice-wave { color: var(--orange-2); }
.msg-row.mine .voice-wave { color: #fff; }

.voice-time {
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    font-variant-numeric: tabular-nums;
    opacity: 0.8;
    min-width: 32px;
    text-align: right;
}

.upload-stub {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13.5px;
    padding: 3px 0;
}
.upload-ring {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─────────────── Кнопка «вниз» ─────────────── */

/* Простая объёмная круглая кнопка: заливка-градиент + мягкое кольцо + чёткая тень.
   Без inset-1px-канта — на круге он рисуется дугой и читается как «полуокружность». */
.scroll-down-btn {
    position: absolute;
    right: 20px;
    bottom: 96px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: radial-gradient(120% 120% at 50% 0%, #2a2935 0%, #1b1a23 70%);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.07),
        0 6px 16px -4px rgba(0, 0, 0, 0.7);
    color: var(--text-secondary);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px) scale(0.94);
    transition-property: opacity, transform, color, box-shadow, background;
    transition-duration: 0.24s;
    transition-timing-function: var(--ease-out);
    z-index: 4;
}
.scroll-down-btn.visible { opacity: 1; pointer-events: auto; transform: none; }
.scroll-down-btn:hover {
    color: var(--text-primary);
    background: radial-gradient(120% 120% at 50% 0%, #333140 0%, #201f2a 70%);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.12),
        0 8px 20px -4px rgba(0, 0, 0, 0.75);
}
.scroll-down-btn.visible:active { transform: scale(0.96); }

.scroll-down-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 21px;
    height: 21px;
    padding: 0 6px;
    border-radius: 999px;
    background: linear-gradient(150deg, var(--sup-accent-1), var(--sup-accent-2));
    color: #fff;
    font-size: 11px;
    font-weight: 650;
    display: grid;
    place-items: center;
    border: 2px solid var(--sup-surface-0);
    box-shadow: 0 4px 10px -3px rgba(255, 107, 0, 0.9);
}

/* ─────────────── Очередь вложений ─────────────── */

.attach-tray {
    border-top: 1px solid var(--card-border);
    background: linear-gradient(180deg, var(--sup-surface-1), var(--sup-surface-0));
    box-shadow: var(--sup-edge);
    padding: 11px 16px 12px;
    flex-shrink: 0;
    animation: trayIn 0.22s var(--ease-out);
}
@keyframes trayIn { from { opacity: 0; transform: translateY(6px); } }

.attach-tray-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-faint);
    margin-bottom: 9px;
}
.attach-tray-clear {
    background: none;
    border: none;
    color: var(--text-secondary);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    padding: 2px 4px;
}
.attach-tray-clear:hover { color: var(--danger); }

.attach-list {
    display: flex;
    gap: 9px;
    overflow-x: auto;
    padding-bottom: 3px;
}
.attach-list::-webkit-scrollbar { height: 5px; }
.attach-list::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 5px; }

.attach-item {
    position: relative;
    width: 92px;
    flex-shrink: 0;
    border-radius: 13px;
    overflow: hidden;
    background: linear-gradient(180deg, var(--sup-surface-3), var(--sup-surface-2));
    box-shadow: var(--sup-ring), var(--sup-edge), var(--sup-lift-sm);
    animation: itemIn 0.2s var(--ease-spring);
}
@keyframes itemIn { from { opacity: 0; transform: scale(0.88); } }

.attach-item-thumb {
    height: 62px;
    display: grid;
    place-items: center;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.25);
}
.attach-item-thumb img { width: 100%; height: 100%; object-fit: cover; -webkit-user-drag: none; user-select: none; }
.attach-item-thumb .ico-svg { width: 22px; height: 22px; }

.attach-item-name {
    font-size: 10.5px;
    padding: 5px 7px 6px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attach-item-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.68);
    backdrop-filter: blur(4px);
    color: #fff;
    cursor: pointer;
    display: grid;
    place-items: center;
    opacity: 0;
    transition: opacity 0.16s var(--ease-out);
}
.attach-item:hover .attach-item-remove { opacity: 1; }
.attach-item-remove .ico-svg { width: 13px; height: 13px; }
.attach-item-remove:active { transform: scale(0.92); }
@media (hover: none) { .attach-item-remove { opacity: 1; } }

/* ─────────────── Запись голосового ─────────────── */

.rec-bar {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 13px 16px;
    border-top: 1px solid var(--card-border);
    background: linear-gradient(180deg, var(--sup-surface-2), var(--sup-surface-1));
    box-shadow: var(--sup-edge);
    flex-shrink: 0;
    padding-bottom: max(13px, env(safe-area-inset-bottom));
}
.rec-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--danger);
    box-shadow: 0 0 10px var(--danger);
    animation: recBlink 1.1s infinite;
    flex-shrink: 0;
}
@keyframes recBlink { 50% { opacity: 0.2; } }
.rec-time { font-size: 14px; font-variant-numeric: tabular-nums; min-width: 38px; }

.rec-wave { flex: 1; height: 34px; min-width: 60px; }

.rec-cancel,
.rec-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    display: grid;
    place-items: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.16s var(--ease-spring);
}
.rec-cancel {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border-strong);
    color: var(--text-secondary);
}
.rec-cancel:hover { color: var(--danger); border-color: rgba(255, 77, 79, 0.4); }
.rec-send {
    background: linear-gradient(150deg, var(--sup-accent-1), var(--sup-accent-2));
    color: #fff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 8px 18px -8px rgba(255, 107, 0, 0.9);
}
.rec-send:hover { transform: scale(1.06); }
.rec-send:active { transform: scale(0.96); }
.rec-cancel:active { transform: scale(0.96); }

/* ─────────────── Поле ввода ─────────────── */

.chat-composer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--card-border);
    background: linear-gradient(180deg, var(--sup-surface-1), var(--sup-surface-0));
    box-shadow: var(--sup-edge);
    flex-shrink: 0;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
}

/* Поле — «вдавленная» поверхность: инвертированный кант вместо обычной рамки */
.composer-field {
    flex: 1;
    min-width: 0;
    border-radius: 18px;
    background: var(--sup-surface-0);
    border: 1px solid var(--card-border-strong);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.45);
    transition: border-color 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
    display: flex;
}
.composer-field:focus-within {
    border-color: var(--orange-border);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.45), 0 0 0 3px rgba(255, 107, 0, 0.12);
}

.chat-composer textarea {
    flex: 1;
    min-width: 0;
    width: 100%;
    resize: none;
    border: none;
    background: transparent;
    color: var(--text-primary);
    padding: 11px 16px;
    font: inherit;
    font-size: 15px;
    line-height: 1.45;
    max-height: 150px;
    outline: none;
}
.chat-composer textarea::placeholder { color: var(--text-faint); }

.composer-btn {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    transition-property: color, background-color, border-color, transform;
    transition-duration: 0.18s;
    transition-timing-function: var(--ease-out);
}
.composer-btn:hover {
    color: var(--orange-2);
    background: var(--orange-ghost);
    border-color: rgba(255, 107, 0, 0.2);
}
.composer-btn:active { transform: scale(0.96); }
.composer-btn.recording-hint { color: var(--orange-2); }

.composer-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    display: grid;
    place-items: center;
    background: linear-gradient(150deg, var(--sup-accent-1), var(--sup-accent-2));
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 10px 20px -8px rgba(255, 107, 0, 0.9);
    transition: transform 0.16s var(--ease-spring), filter 0.16s var(--ease-out), opacity 0.16s var(--ease-out);
}
.composer-send:hover { transform: scale(1.06); }
.composer-send:active { transform: scale(0.96); }
.composer-send:disabled {
    opacity: 0.45;
    box-shadow: none;
    cursor: default;
    transform: none;
}

.chat-banned {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 18px;
    border-top: 1px solid var(--card-border);
    background: rgba(255, 77, 79, 0.05);
    color: var(--danger);
    font-size: 14px;
    flex-shrink: 0;
}

.chat-foot-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    text-align: center;
    font-size: 12px;
    color: var(--text-faint);
    margin-top: 11px;
    flex-shrink: 0;
}
.chat-foot-hint .ico-svg { width: 13px; height: 13px; }

/* ─────────────── Drag & drop ─────────────── */

.drop-hint {
    position: absolute;
    inset: 8px;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: rgba(12, 11, 15, 0.9);
    backdrop-filter: blur(6px);
    border: 2px dashed var(--orange-border);
    border-radius: calc(var(--radius-xl) - 8px);
    color: var(--orange-2);
    font-size: 15px;
    font-weight: 500;
    z-index: 6;
    pointer-events: none;
    animation: dropIn 0.16s var(--ease-out);
}
@keyframes dropIn { from { opacity: 0; } }
.chat-shell.dragging .drop-hint { display: flex; }

/* ─────────────── Лайтбокс ─────────────── */

.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(6, 5, 8, 0.94);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 44px 20px;
    animation: dropIn 0.2s var(--ease-out);
}
.lightbox-body img,
.lightbox-body video {
    max-width: 100%;
    max-height: 86dvh;
    border-radius: var(--radius-md);
    box-shadow: var(--sup-lift-lg);
}
.lightbox-close {
    position: absolute;
    top: 20px;
    right: 24px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    cursor: pointer;
    display: grid;
    place-items: center;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.18); }
.lightbox-close:active { transform: scale(0.96); }
.lightbox-close {
    transition-property: background-color, transform;
    transition-duration: 0.15s;
    transition-timing-function: var(--ease-out);
}

/* ─────────────── Мобильные ─────────────── */

@media (max-width: 720px) {
    .support-container { padding: 0 10px 8px; }
    .support-container .header { padding: 14px 0 14px; }
    .chat-shell { border-radius: var(--radius-lg); }
    .bubble { max-width: 84%; font-size: 14.5px; }
    .chat-scroll { padding: 6px 13px 12px; }
    .chat-head { padding: 12px 14px; }
    .chat-foot-hint { display: none; }
    .btn-pill-label { display: none; }
    .btn-pill { padding: 0 12px; }
    .scroll-down-btn { bottom: 88px; right: 14px; }
    .quick-chips { gap: 7px; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
    .chat-scroll { scroll-behavior: auto; }
}


/* ═══════════════════════════════════════════════════════════
   Полировка по make-interfaces-feel-better
   ═══════════════════════════════════════════════════════════ */

/* ── Концентричные радиусы ──
   Медиа и карточки лежат внутри пузыря, поэтому их радиус должен быть
   радиусом пузыря минус его паддинг. Для таких пузырей паддинг делаем
   одинаковым со всех сторон, иначе концентрику не свести. */
.bubble.has-media {
    padding: 6px 6px 4px;
}
.bubble.has-media .attach-media,
.bubble.has-media .attach-skeleton {
    border-radius: 12px; /* 18 − 6 */
}
.bubble.has-media .attach-media img,
.bubble.has-media .attach-media video {
    border-radius: 12px;
}
/* Текст-подпись под медиа не должен упираться в край пузыря */
.bubble.has-media .bubble-text { padding: 4px 8px 0; }
.bubble.has-media .bubble-meta { padding: 0 8px; }

.bubble.has-card { padding: 7px 7px 5px; }
.bubble.has-card .file-card,
.bubble.has-card .attach-error { border-radius: 11px; } /* 18 − 7 */
.bubble.has-card .bubble-text { padding: 4px 7px 0; }
.bubble.has-card .bubble-meta { padding: 0 7px; }

/* ── Типографика ── */
.chat-empty h3 { text-wrap: balance; }
.chat-empty p,
.login-alt-hint,
.chat-foot-hint,
.attach-error-text,
.msg-system { text-wrap: pretty; }
/* pre-wrap объявлен выше и сохраняет переносы; pretty правит только стиль переноса */
.bubble-text { text-wrap: pretty; }

/* ── Минимальная зона нажатия ──
   Мелкие контролы дотягиваем псевдоэлементом, не раздувая видимый размер.
   Размеры подобраны так, чтобы зоны соседних элементов не пересекались. */
.voice-play { width: 40px; height: 40px; }

.attach-item-remove::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 36px;
    height: 36px;
    transform: translate(-50%, -50%);
}

.attach-tray-clear { position: relative; }
.attach-tray-clear::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 40px;
    transform: translateY(-50%);
}

.attach-retry { position: relative; }
.attach-retry::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 40px;
    transform: translateY(-50%);
}

/* ── Контекстная анимация иконки play ⇄ pause ──
   Обе иконки остаются в DOM и кросс-фейдятся, поэтому анимируются
   и появление, и исчезновение. Motion в проекте нет, поэтому
   cubic-bezier(0.2, 0, 0, 1) как приближение пружины. */
.voice-play { position: relative; overflow: hidden; }
.icon-swap {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    opacity: 0;
    scale: 0.25;
    filter: blur(4px);
    transition-property: opacity, scale, filter;
    transition-duration: 300ms;
    transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}
.voice-play[data-state="paused"]  .icon-swap.is-play,
.voice-play[data-state="playing"] .icon-swap.is-pause,
.voice-play[data-state="loading"] .icon-swap.is-loading,
.voice-play[data-state="error"]   .icon-swap.is-error {
    opacity: 1;
    scale: 1;
    filter: blur(0px);
}
/* Сдвиг вправо нужен только треугольнику play, у паузы он симметричный */
.icon-swap.is-pause .ico-svg,
.icon-swap.is-error .ico-svg { margin-left: 0; }

/* ── Разложенный и ступенчатый вход пустого экрана ──
   Анимируем не контейнер целиком, а смысловые куски с шагом ~100 мс. */
.chat-empty > * {
    animation: fadeInUp 420ms var(--ease-out) both;
}
.chat-empty > *:nth-child(1) { animation-delay: 0ms; }
.chat-empty > *:nth-child(2) { animation-delay: 90ms; }
.chat-empty > *:nth-child(3) { animation-delay: 180ms; }
.chat-empty > *:nth-child(4) { animation-delay: 270ms; }

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); filter: blur(4px); }
    to   { opacity: 1; transform: none; filter: blur(0); }
}

/* ── Мягкий выход ──
   Уход всегда короче и тише входа: небольшой фиксированный сдвиг,
   а не схлопывание по высоте. */
.msg-row.leaving {
    opacity: 0;
    transform: translateY(-12px);
    filter: blur(4px);
    transition-property: opacity, transform, filter;
    transition-duration: 150ms;
    transition-timing-function: ease-in;
}

.lightbox.closing {
    opacity: 0;
    transition-property: opacity;
    transition-duration: 150ms;
    transition-timing-function: ease-in;
}

.voice-play[data-state="loading"] .icon-swap.is-loading .ico-svg {
    animation: spin 0.8s linear infinite;
}
