:root {
    --page-background: var(--tg-theme-bg-color, #ffffff);
    --surface-background: var(--tg-theme-secondary-bg-color, #f2f2f7);
    --primary-text: var(--tg-theme-text-color, #111111);
    --secondary-text: var(--tg-theme-hint-color, #707579);
    --link-color: var(--tg-theme-link-color, #2481cc);
    --button-color: var(--tg-theme-button-color, #2481cc);
    --button-text-color: var(--tg-theme-button-text-color, #ffffff);
    --border-color: color-mix(
        in srgb,
        var(--primary-text) 12%,
        transparent
    );
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--page-background);
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    background: var(--page-background);
    color: var(--primary-text);
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;
}

button,
input {
    font: inherit;
}

button {
    -webkit-tap-highlight-color: transparent;
}

.app-shell {
    width: min(100%, 680px);
    min-height: 100vh;
    margin: 0 auto;
    padding:
        calc(16px + env(safe-area-inset-top))
        16px
        calc(24px + env(safe-area-inset-bottom));
}

/* Верхняя панель остаётся одной строкой прежней компактной высоты. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: stretch;
  min-height: 40px;
  margin: 0 -16px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  overflow: hidden;
  border-bottom: 1px solid color-mix(
    in srgb,
    var(--primary-text) 8%,
    transparent
  );
  border-radius: 0 0 12px 12px;
  background: var(--page-background);
}

/* Группа служебных кнопок остаётся слева. */
.topbar-actions {
    display: flex;
    align-items: stretch;
    width: 100%;
}

/* Общая ячейка панели. */
.topbar-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 0;
  background: transparent;
  color: var(--link-color);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  -webkit-tap-highlight-color: transparent;
}

/* У первой ячейки нет левой разделительной линии. */
.topbar-back-spacer,
.back-button {
  flex: 0 0 44px;
}

/* Большой шеврон заметен, но панель не становится выше. */
.topbar-icon-button {
  flex: 0 0 44px;
  padding: 0;
  font-size: 29px;
  line-height: 1;
}

/* Главная команда занимает одинаковое заметное место в RU и EN интерфейсе. */
.topbar-export-button {
  flex: 0 0 142px;
  margin-left: auto;
  padding: 0;
  font-size: 15px;
  white-space: nowrap;
}

/* RU / EN — короткие обозначения, поэтому ячейка компактная. */
.topbar-language-button {
  flex: 0 0 38px;
  padding: 0;
  font-size: 13px;
  letter-spacing: 0.03em;
}

/* Контурные SVG-иконки в панели. */
.topbar-icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

/* Лёгкая обратная связь при нажатии без тяжёлой отдельной плитки. */
.topbar-cell:active {
  background: color-mix(
    in srgb,
    var(--link-color) 12%,
    transparent
  );
}

/* Невидимый элемент не занимает место. */
.topbar-cell.hidden {
  display: none;
}

@media (min-width: 720px) {
    .topbar {
        margin-left: -24px;
        margin-right: -24px;
        padding-left: 24px;
        padding-right: 24px;
    }
}

.hero-section {
    padding: 32px 0 24px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--secondary-text);
    font-size: 14px;
    font-weight: 600;
}

h1,
h2,
p {
    overflow-wrap: anywhere;
}

h1 {
    margin: 0;
    font-size: clamp(28px, 8vw, 38px);
    line-height: 1.08;
    letter-spacing: -0.6px;
}

.page-description {
    max-width: 560px;
    margin: 14px 0 0;
    color: var(--secondary-text);
    font-size: 16px;
    line-height: 1.45;
}

.input-section,
.placeholder-section {
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    background: var(--surface-background);
}

/* Сообщения больше не занимают место под кнопкой. */
.input-section {
  display: grid;
  gap: 10px;
}

label {
    color: var(--secondary-text);
    font-size: 14px;
    font-weight: 600;
}

input {
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    outline: none;
    background: var(--page-background);
    color: var(--primary-text);
    font-size: 16px;
}

input:focus {
    border-color: var(--link-color);
    box-shadow: 0 0 0 3px color-mix(
        in srgb,
        var(--link-color) 18%,
        transparent
    );
}

.primary-button {
    min-height: 48px;
    border: 0;
    border-radius: 12px;
    background: var(--button-color);
    color: var(--button-text-color);
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
}

.primary-button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.placeholder-section {
    margin-top: 16px;
}

.placeholder-section h2 {
    margin: 0;
    font-size: 18px;
    line-height: 1.2;
}

.placeholder-section p {
    margin: 8px 0 0;
    color: var(--secondary-text);
    font-size: 15px;
    line-height: 1.45;
}

@media (min-width: 720px) {
    .app-shell {
        padding-left: 24px;
        padding-right: 24px;
    }
}

.hidden {
    display: none;
}

.folder-header {
    padding: 24px 0 16px;
}

.folder-meta {
    margin: 0 0 8px;
    color: var(--secondary-text);
    font-size: 13px;
    line-height: 1.35;
}

.folder-header h1 {
    margin: 0;
    font-size: clamp(26px, 7vw, 34px);
    line-height: 1.12;
}

.folder-count {
    margin: 8px 0 0;
    color: var(--secondary-text);
    font-size: 16px;
}

.select-all-row {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    margin-top: 14px;
    color: var(--primary-text);
    cursor: pointer;
    font-size: 15px;
    font-weight: 650;
}

.select-all-row input,
.card-checkbox {
    width: 22px;
    height: 22px;
    margin: 0;
    accent-color: var(--button-color);
    cursor: pointer;
}

.folder-items {
    display: grid;
    gap: 10px;
    padding-bottom: 16px;
}

/* Одна строка: карточка чата и чекбокс выбора справа. */
.channel-item-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 34px;
    align-items: center;
    gap: 10px;
}

/* Карточка занимает всю доступную ширину левой части строки. */
.channel-item-row .channel-card {
    width: 100%;
}

.channel-card {
    /* min-width: 0 обязателен. Элемент грида по умолчанию не может стать
       уже своего содержимого, поэтому длинное название растягивало карточку
       за пределы экрана телефона. */
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    background: var(--surface-background);
    transition:
        border-color 140ms ease,
        background 140ms ease;
}

.channel-card.is-selected {
    border-color: color-mix(
        in srgb,
        var(--button-color) 55%,
        var(--border-color)
    );
}

.channel-card-top {
    display: flex;
    align-items: flex-start;
}

.channel-details {
    min-width: 0;
    flex: 1;
}

.channel-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.channel-title {
    /* Название лежит внутри flex-строки. Без min-width: 0 оно тоже отказывается
       сжиматься, и обрезка многоточием не срабатывает. */
    min-width: 0;
    flex: 0 1 auto;
    max-width: 100%;
    overflow: hidden;
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.verified-badge {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--link-color);
    color: #ffffff;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
}

.channel-link {
    display: inline-block;
    margin-top: 6px;
    color: var(--link-color);
    font-size: 15px;
    line-height: 1.3;
    text-decoration: none;
}

.channel-link:hover {
    text-decoration: underline;
}

.channel-link-unavailable {
    color: var(--secondary-text);
    cursor: default;
}

.channel-type {
    margin: 5px 0 0;
    color: var(--secondary-text);
    font-size: 13px;
    line-height: 1.3;
}

/* Чекбокс вынесен за границу карточки в отдельную правую колонку. */
.card-checkbox {
    width: 22px;
    height: 22px;
    margin: 0;
    accent-color: var(--button-color);
    cursor: pointer;
}

.screen-header {
    padding: 20px 0 12px;
}

.screen-header h1 {
    margin: 12px 0 0;
    font-size: 28px;
    line-height: 1.15;
}

.history-list {
    display: grid;
    gap: 10px;
}

.history-item:active {
    opacity: 0.8;
}

.history-item-title {
    overflow: hidden;
    font-size: 16px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-item-meta,
.history-empty {
    margin: 0;
    color: var(--secondary-text);
    font-size: 14px;
    line-height: 1.4;
}

.global-status {
    min-height: 20px;
    margin: 16px 0 0;
    color: var(--secondary-text);
    font-size: 14px;
    line-height: 1.4;
}

.dialog-backdrop {
    position: fixed;
    z-index: 30;
    inset: 0;
    display: grid;
    align-items: center;
    padding:
        16px
        16px
        calc(16px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, #000000 38%, transparent);
}

.dialog-card {
    width: min(100%, 680px);
    margin: 0 auto;
    padding: 18px;
    border-radius: 18px;
    background: var(--page-background);
    color: var(--primary-text);
}

.dialog-card h2 {
    margin: 0;
    font-size: 20px;
    line-height: 1.25;
}

.dialog-card p {
    margin: 10px 0 0;
    color: var(--secondary-text);
    font-size: 15px;
    line-height: 1.4;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

/* Короткие сообщения используют тот же визуальный язык, что и диалоги. */
.message-dialog-card {
  max-width: 420px;
}

/* Текст сообщения не должен превращать окно в слишком широкую строку. */
.message-dialog-card p {
  max-width: 360px;
}

/* Одна крупная кнопка легко нажимается пальцем. */
.message-dialog-card .dialog-actions {
  justify-content: stretch;
}

/* Кнопка закрытия занимает всю ширину нижней части popup. */
.message-dialog-card .secondary-button {
  width: 100%;
  min-height: 46px;
}

/* В окне выгрузки основное действие должно быть ближе к настройкам.
Это правило не влияет на окно удаления и окно выбора языка. */
.export-dialog-card .dialog-actions {
    margin-top: 12px;
}


.secondary-button,
.danger-button {
    min-height: 42px;
    padding: 9px 14px;
    border-radius: 11px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
}

.secondary-button {
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--primary-text);
}

.danger-button {
    border: 0;
    background: #d9534f;
    color: #ffffff;
}

.dialog-backdrop.hidden {
    display: none;
}

.input-section-main {
    margin-top: 24px;
}

.folder-link {
    display: inline-block;
    max-width: 100%;
    margin-top: 8px;
    overflow: hidden;
    color: var(--link-color);
    font-size: 14px;
    line-height: 1.35;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.folder-link:hover {
    text-decoration: underline;
}

.empty-section {
    padding: 28px 0;
}

.empty-title {
    margin: 0;
    font-size: 22px;
    font-weight: 750;
    line-height: 1.2;
}

.empty-description {
    margin: 10px 0 18px;
    color: var(--secondary-text);
    font-size: 16px;
    line-height: 1.45;
}

/* Общая строка действий: используется и на экране истории, и на экране папки. */
/* Все массовые действия собраны у правого края:
   корзина → текст «Выбрать все» → чекбокс. */
.selection-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 14px;
}

.history-select-all,
.folder-select-all {
    margin-top: 0;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    min-width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
}

.icon-button:active {
    opacity: 0.7;
}

.danger-icon-button {
    color: #d9534f;
}

.selection-hint {
    margin: 8px 0 16px;
    color: var(--secondary-text);
    font-size: 13px;
    line-height: 1.35;
}

/* Строка папки: большая кнопка открытия и отдельный чекбокс справа. */
.history-item-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 34px;
    align-items: center;
    gap: 10px;
}

/* Карточка папки визуально остаётся прежней. */
.history-open-button {
    display: grid;
    width: 100%;
    min-width: 0;
    gap: 5px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: var(--surface-background);
    color: var(--primary-text);
    cursor: pointer;
    text-align: left;
}

/* Чекбокс папки находится справа, вне визуальной карточки. */
.history-checkbox {
    width: 22px;
    height: 22px;
    margin: 0;
    accent-color: var(--button-color);
    cursor: pointer;
}

.history-open-button {
    display: grid;
    min-width: 0;
    gap: 5px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--primary-text);
    cursor: pointer;
    text-align: left;
}

.history-open-button:active {
    opacity: 0.72;
}

.history-item-title {
    overflow: hidden;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-item-meta {
    overflow: hidden;
    color: var(--secondary-text);
    font-size: 13px;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-refresh-button {
    min-height: 36px;
    padding: 7px 9px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--link-color);
    cursor: pointer;
    font-size: 14px;
    font-weight: 650;
}

.history-refresh-button:active {
    background: color-mix(
        in srgb,
        var(--link-color) 12%,
        transparent
    );
}

.language-dialog-card {
    max-width: 360px;
}

/* Небольшой отступ между заголовком «Язык» и первой языковой кнопкой. */
.language-dialog-card .language-option-button:first-of-type {
    margin-top: 14px;
}

/* Вторую кнопку слегка отделяем от первой. */
.language-dialog-card .language-option-button + .language-option-button {
    margin-top: 8px;
}

/* Отделяем выбор языка от действия «Отмена». */
.language-dialog-card .dialog-actions {
    margin-top: 14px;
}

.language-options {
    display: grid;
    gap: 8px;
    margin-top: 16px;
}

.language-option-button {
    width: 100%;
    min-height: 46px;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--surface-background);
    color: var(--primary-text);
    cursor: pointer;
    font: inherit;
    text-align: left;
}

.language-option-button.active {
    border-color: var(--button-color);
    background: color-mix(
        in srgb,
        var(--button-color) 14%,
        var(--surface-background)
    );
    color: var(--button-color);
    font-weight: 700;
}

.language-option-button:active {
    opacity: 0.8;
}

#delete-dialog.hidden {
    display: none;
}

#delete-dialog {
    z-index: 100;
}

.dialog-backdrop.hidden {
    display: none;
}
/* ==== Правки этапа 1 ==== */

/* Иконка корзины внутри круглой кнопки.
   fill: currentColor означает «возьми цвет текста кнопки»,
   поэтому красный цвет из .danger-icon-button работает и для картинки. */
.trash-icon {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* Ссылка, зашитая прямо в название чата.
   Цвет остаётся обычным цветом текста, чтобы карточка не пестрила синим,
   а подчёркивание появляется только при нажатии. */
.channel-title-link {
    color: inherit;
    text-decoration: none;
}

.channel-title-link:active {
    text-decoration: underline;
}

/* Предупреждающие метки Telegram: мошенничество и подделка.
   Они намеренно яркие: это важная информация о чате. */
.warning-badge {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    padding: 1px 6px;
    border-radius: 6px;
    background: #d9534f;
    color: #ffffff;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.3px;
    line-height: 1.5;
    text-transform: uppercase;
}

/* ===== Второй этап: аватарки, описание, похожие каналы ===== */

/* Карточка теперь реагирует на нажатие, поэтому показываем это курсором. */
.channel-card {
    cursor: pointer;
}

/* ===== Третий этап: окно выгрузки ===== */

/* Карточка окна выгрузки выше обычной, поэтому разрешаем прокрутку внутри.
   max-height в процентах от высоты экрана не даст окну уехать за край. */
.export-dialog-card {
    max-height: 86vh;
    overflow-y: auto;
}

/* Мелкий заголовок раздела внутри окна. */
.export-section-label {
    margin: 14px 0 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--secondary-text);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Список выгружаемых папок. */
.export-folders {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Одна строка списка папок. */
.export-folder-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--page-background);
}

/* Номер папки по порядку. */
.export-folder-position {
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--secondary-text);
}

/* Название папки: одна строка с многоточием. */
.export-folder-title {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Пара стрелок справа. */
.export-folder-controls {
    display: flex;
    flex-shrink: 0;
    gap: 4px;
}

/* Кнопка-стрелка порядка.
   Размер 30 пикселей — минимум, по которому удобно попасть пальцем. */
.export-order-button {
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--surface-background);
    color: var(--primary-text);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}

/* Неактивная стрелка у верхней и нижней папки. */
.export-order-button:disabled {
    opacity: 0.35;
    cursor: default;
}

/* Форматы всегда лежат в двух ровных строках по четыре кнопки. */
.export-formats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
}

/* Все кнопки одной ширины: две аккуратные строки форматов. */
.export-format-button {
    width: 100%;
    min-height: 34px;
    padding: 7px 6px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--surface-background);
    color: var(--primary-text);
    cursor: pointer;
    font-size: 12px;
    line-height: 1.15;
    text-align: center;
}

/* Выбранный формат подсвечен. */
.export-format-button.active {
    border-color: var(--button-color);
    background: var(--button-color);
    color: var(--button-text-color);
}

/* Блок с полем имени файла. */
.export-name-row {
    display: flex;
    flex-direction: column;
}

/* Поле ввода имени файла. */
.export-name-row input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--page-background);
    color: var(--primary-text);
    font-size: 14px;
    /* box-sizing нужен, чтобы padding не вылез за ширину блока. */
    box-sizing: border-box;
}

/* Мелкая строка-напоминание под списком папок. */
.export-warning {
    margin: 6px 0 0;
    font-size: 11px;
    color: var(--secondary-text);
}

/* Продвинутые настройки в двух равных колонках.
minmax(0, 1fr) не даёт длинной подписи растянуть окно за границы экрана. */
.export-advanced-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 12px;
}

/* Одна компактная настройка.
align-items: center ставит чекбокс точно по центру
относительно двух строк подписи. */
.export-option {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.25;
    color: var(--secondary-text);
    cursor: pointer;
}

.export-option span {
    white-space: pre-line;
}

/* Чекбокс достаточно крупный для нажатия, но не перетягивает внимание
с выбора формата и основной кнопки. */
.export-option input {
    flex: 0 0 auto;
    width: 15px;
    height: 15px;
    margin: 0;
}

/* Пустое описание в окне подтверждения не должно занимать место. */
#delete-dialog-description:empty {
    display: none;
}

/* Блок сохранённых папок расположен сразу под формой обработки ссылки. */
.home-folders-section {
  margin-top: 12px;
}

/* Короткий заголовок без счётчика папок. */
.home-folders-title {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

/* У заголовка нет лишнего верхнего отступа: действия идут сразу под ним. */
.home-folders-section .selection-actions {
  margin-top: 10px;
}

/* Текст идёт перед чекбоксом, поэтому сама галочка находится справа. */
.select-all-row {
    flex-direction: row;
}

/* Поясняющие тексты относятся ко всей строке, а не к левому краю. */
.selection-hint {
    text-align: center;
}

/* ===== Новая раскладка верхней панели ===== */

/* Боковые колонки равны по ширине.
   Поэтому средняя кнопка находится точно по центру всей панели. */
.topbar {
    --topbar-cell-width: 36px;
    --topbar-export-width: 112px;

    display: grid;
    grid-template-columns:
        minmax(0, 1fr)
        var(--topbar-export-width)
        minmax(0, 1fr);
    align-items: center;
    column-gap: 0;
    overflow: visible;
}

/* Каждая группа занимает свою боковую колонку. */
.topbar-group {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 0;
}

/* Слева кнопки начинаются у левого края. */
.topbar-group-left {
    justify-content: flex-start;
}

/* Справа кнопки заканчиваются у правого края. */
.topbar-group-right {
    justify-content: flex-end;
}

/* Единый размер служебных кнопок.
   Эти правила заменяют прежнюю ширину 44px и 38px. */
.topbar-group .topbar-cell {
    flex: 0 0 var(--topbar-cell-width);
    width: var(--topbar-cell-width);
    min-width: 0;
    height: 40px;
    min-height: 40px;
    padding: 0;
    border-radius: 9px;
}

/* Отменяем прежнее margin-left: auto у выгрузки.
   Теперь её положение задаёт центральная колонка. */
.topbar .topbar-export-button {
    justify-self: center;
    width: 100%;
    min-width: 0;
    height: 40px;
    min-height: 40px;
    margin: 0;
    padding: 0 4px;
    border-radius: 9px;
    font-size: 15px;
    line-height: 1.2;
    white-space: nowrap;
}

/* Краткое обозначение языка остаётся спокойным по размеру. */
.topbar .topbar-language-button {
    font-size: 14px;
    font-weight: 400;
    letter-spacing: 0.03em;
}

/* Размер шеврона не зависит от размера значка справки. */
.topbar .back-button {
    font-size: 29px;
    line-height: 1;
}

/* Конверт сохраняет контурное оформление. */
.topbar .topbar-icon {
    width: 24px;
    height: 24px;
}

/* Контурное сердце в цвет остальных служебных значков.
   Цвет наследуется от кнопки и следует теме Telegram. */
.topbar .topbar-heart-icon {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Маленький вопросительный знак внутри тонкого круга. */
.topbar-help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 21px;
    height: 21px;
    border: 1.6px solid currentColor;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
}

/* Скрытая кнопка исчезает вместе со своей шириной.
   На главном экране язык становится крайней левой кнопкой. */
.topbar .topbar-cell.hidden {
    display: none;
}

/* Видимое выделение при навигации клавишей Tab. */
.topbar-cell:focus-visible {
    outline: 2px solid var(--link-color);
    outline-offset: -2px;
}

/* На узком экране уменьшаем ширину ячеек, но сохраняем одну строку.
   При ширине 320px: 96px слева + 96px в центре + 96px справа.
   Три левые кнопки занимают 90px и не заходят на выгрузку. */
@media (max-width: 380px) {
    .topbar {
        --topbar-cell-width: 30px;
        --topbar-export-width: 96px;
    }

    .topbar .topbar-export-button {
        font-size: 14px;
    }

    .topbar .topbar-language-button {
        font-size: 12px;
    }
}

/* ===== Круглый выбор и компактные заголовки списков ===== */

/* Большая прозрачная область нажатия вокруг маленького круга. */
.selection-target {
    position: relative;
    display: inline-grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    place-items: center;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    min-height: 44px;
    margin: 0;
    padding: 0;
    cursor: pointer;
}

/* Checkbox остаётся настоящим и доступным с клавиатуры.
   Общие стили текстовых input не должны задавать ему высоту и padding. */
.selection-target input[type="checkbox"] {
    /* Настоящий checkbox находится в своей строке, а не поверх страницы. */
    position: static;
    inset: auto;
    grid-area: 1 / 1;
    justify-self: center;
    align-self: center;
    width: 22px;
    height: 22px;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    opacity: 0;
    transform: none;
    box-shadow: none;
    cursor: pointer;
}

/* Видимый круг не перехватывает нажатия у настоящего checkbox. */
.selection-indicator {
    position: relative;
    grid-area: 1 / 1;
    display: block;
    width: 22px;
    height: 22px;
    border: 2px solid color-mix(in srgb, var(--primary-text) 40%, transparent);
    /* Скруглённый квадрат вместо круга. */
    border-radius: 5px;
    background: transparent;
    pointer-events: none;
}

.selection-target input:checked + .selection-indicator,
.selection-target input:indeterminate + .selection-indicator {
    border-color: var(--button-color);
    background: var(--button-color);
}

/* Галочку рисуем CSS, без зависимости от шрифта или системного emoji. */
.selection-target input:checked + .selection-indicator::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 6px;
    width: 5px;
    height: 9px;
    border: solid var(--button-text-color);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Частичный общий выбор — горизонтальная черта вместо галочки. */
.selection-target input:indeterminate + .selection-indicator::after {
    content: "";
    position: absolute;
    top: 8px;
    left: 4px;
    width: 10px;
    height: 2px;
    border: 0;
    background: var(--button-text-color);
    transform: none;
}

.selection-target input:focus-visible + .selection-indicator {
    outline: 2px solid var(--link-color);
    outline-offset: 3px;
}

.selection-target input:disabled {
    cursor: default;
}

.selection-target input:disabled + .selection-indicator {
    opacity: 0.4;
}

/* Подпись скрыта визуально, но остаётся доступным названием общего выбора. */
.selection-label-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    margin: -1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0 !important;
}

/* Слева заголовок или счётчик, справа существующие действия. */
.selection-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
}

.selection-toolbar .selection-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0;
}

.home-folders-section .selection-toolbar .selection-actions {
    margin-top: 0;
}

.selection-toolbar .select-all-row {
    gap: 0;
    margin-top: 0;
}

.selection-toolbar .icon-button {
    width: 44px;
    min-width: 44px;
    height: 44px;
    border: 0;
    background: transparent;
}

.selection-toolbar .icon-button:disabled {
    opacity: 0.3;
    cursor: default;
}

/* Высота строки с общим количеством и выбором остаётся стабильной. */
.selection-toolbar .folder-count {
    margin: 0;
    font-size: 14px;
    line-height: 1.35;
}

.folder-header .selection-toolbar {
    margin-top: 8px;
}

/* Общий круг и круги отдельных элементов находятся на одной вертикали. */
.channel-item-row,
.history-item-row {
    grid-template-columns: minmax(0, 1fr) 44px;
    gap: 8px;
}

/* Подсказки остаются между шапкой и списком, без отдельной строки действий. */
.home-folders-section > .selection-hint,
.folder-header > .selection-hint {
    margin: 4px 0 10px;
    font-size: 12px;
    line-height: 1.35;
}

.folder-header {
    padding-bottom: 0;
}

/* Папки остаются строками без рамок. Фон обозначает состояние всей строки. */
.history-item-row {
    padding: 4px 0;
    border-radius: 12px;
    background: transparent;
    transition: background-color 140ms ease;
}

.history-item-row .history-open-button {
    padding: 6px 10px;
    border: 0;
    border-radius: 12px;
    background: transparent;
}

.history-item-row.is-selected {
    background: color-mix(in srgb, var(--button-color) 9%, transparent);
}

.history-open-button:focus-visible {
    outline: 2px solid var(--link-color);
    outline-offset: -2px;
}

/* Уменьшаем только ширину кнопки «Назад», а не размер самого шеврона. */
.topbar-group .back-button {
    flex-basis: 32px;
    width: 32px;
}

/* Подтверждение перехода выглядит как остальные диалоги приложения. */
#channel-navigation-dialog {
    z-index: 110;
}

.channel-navigation-card {
    max-width: 420px;
}

.channel-navigation-card p {
    white-space: pre-line;
}

.channel-navigation-card .dialog-actions > button {
    flex: 1;
    min-height: 44px;
    padding: 9px 14px;
}

/* Наведение включаем только для устройства, которое действительно его поддерживает. */
@media (hover: hover) and (pointer: fine) {
    .history-item-row:hover {
        background: color-mix(in srgb, var(--primary-text) 5%, transparent);
    }

    .history-item-row.is-selected:hover {
        background: color-mix(in srgb, var(--button-color) 13%, transparent);
    }

    .selection-toolbar .icon-button:not(:disabled):hover {
        background: color-mix(in srgb, #d9534f 9%, transparent);
    }
}

/* Компактный режим: широкое окно и мышь. На широком сенсорном экране
   сохраняются мобильные размеры областей нажатия. */
@media (min-width: 720px) and (hover: hover) and (pointer: fine) {
    .selection-target {
        flex-basis: 32px;
        width: 32px;
        height: 32px;
        min-height: 32px;
    }

    .selection-indicator {
        width: 20px;
        height: 20px;
    }

    .selection-target input:checked + .selection-indicator::after {
        top: 2px;
        left: 5px;
    }

    .selection-target input:indeterminate + .selection-indicator::after {
        top: 7px;
        left: 3px;
    }

    .channel-item-row,
    .history-item-row {
        grid-template-columns: minmax(0, 1fr) 32px;
    }

    .selection-toolbar .icon-button {
        width: 32px;
        min-width: 32px;
        height: 32px;
    }

    .selection-toolbar .trash-icon {
        width: 16px;
        height: 16px;
    }

    .channel-card {
        padding: 10px 12px;
    }

    .channel-title {
        font-size: 16px;
    }

    .history-item-title {
        font-size: 15px;
    }

    .history-item-meta,
    .channel-type {
        font-size: 12px;
    }

    .folder-items,
    .history-list {
        gap: 8px;
    }
}

/* Не навязываем анимацию пользователям с настройкой уменьшенного движения. */
@media (prefers-reduced-motion: reduce) {
    .history-item-row {
        transition: none;
    }
}

/* Убираем системную вспышку при касании области выбора.
   Состояние выбора по-прежнему показывает наш видимый индикатор. */
.selection-target,
.selection-target input[type="checkbox"],
.selection-indicator {
    -webkit-tap-highlight-color: transparent;
}

/* Невидимый настоящий checkbox не должен получать оформление
   текстового поля из общего правила input:focus. */
.selection-target input[type="checkbox"]:focus {
    outline: none;
    box-shadow: none;
    border-color: transparent;
}
@media (hover: hover) and (pointer: fine) {
}
@media (min-width: 720px) and (hover: hover) and (pointer: fine) {
}

/* Сохраняем компактные размеры для широкого окна с мышью. */
@media (min-width: 720px) and (hover: hover) and (pointer: fine) {
}

/* ===== Чекбоксы дополнительных параметров ===== */

/* Не показываем системную вспышку на всей подписи при касании. */
.export-option,
.export-option input[type="checkbox"] {
    -webkit-tap-highlight-color: transparent;
}

/* Отменяем размеры и отступы, предназначенные для текстовых полей.
   Сохраняем обычный системный checkbox и его галочку. */
.export-option input[type="checkbox"] {
    flex: 0 0 15px;
    width: 15px;
    height: 15px;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    outline: none;
    accent-color: var(--button-color);
}

/* Нажатие не должно рисовать рамку текстового input. */
.export-option input[type="checkbox"]:focus {
    border: 0;
    box-shadow: none;
}

/* При работе клавиатурой оставляем небольшую рамку вокруг самой галочки,
   а не вокруг всей настройки. */
.export-option input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--link-color);
    outline-offset: 3px;
}

/* ===== Выравнивание выбора папок и чатов ===== */

/* Строка занимает всю ширину списка.
   Справа — фиксированная область выбора, слева — всё остальное. */
.channel-item-row,
.history-item-row {
    --list-selection-size: 44px;

    display: grid;
    grid-template-columns:
        minmax(0, 1fr)
        var(--list-selection-size);
    align-items: center;
    column-gap: 4px;
    width: 100%;
    min-width: 0;
}

/* Карточка заполняет всю левую колонку.
   У папок сохраняется оформление без постоянной рамки. */
.channel-item-row > .channel-card,
.history-item-row > .history-open-button {
    grid-column: 1;
    grid-row: 1;
    justify-self: stretch;
    width: 100%;
    min-width: 0;
}

/* Перемещаем всю область нажатия, а не только видимый квадрат. */
.channel-item-row > .selection-target,
.history-item-row > .selection-target {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    align-self: center;
    display: grid;
    grid-template-columns: var(--list-selection-size);
    grid-template-rows: var(--list-selection-size);
    place-items: center;
    width: var(--list-selection-size);
    min-width: var(--list-selection-size);
    height: var(--list-selection-size);
    min-height: var(--list-selection-size);
    margin: 0;
    padding: 0;
}

/* Общий и индивидуальные checkbox располагаются у правого края
   своих областей нажатия. Размер областей остаётся прежним. */
.selection-toolbar .selection-target > input,
.selection-toolbar .selection-target > .selection-indicator,
.channel-item-row > .selection-target > input,
.channel-item-row > .selection-target > .selection-indicator,
.history-item-row > .selection-target > input,
.history-item-row > .selection-target > .selection-indicator {
    grid-area: 1 / 1;
    justify-self: end;
    align-self: center;
    margin: 0;
}

/* Сохраняем компактную область выбора для широкого окна с мышью. */
@media (min-width: 720px) and (hover: hover) and (pointer: fine) {
    .channel-item-row,
    .history-item-row {
        --list-selection-size: 32px;
    }
}

/* В компактном режиме вместо 68px остаётся колонка выбора 32px. */
@media (min-width: 720px) and (hover: hover) and (pointer: fine) {
}

/* В коротком уведомлении остаются только текст и кнопка закрытия.
   Убираем отступ, который раньше отделял текст от заголовка.
   Размер, начертание и цвет текста сохраняются прежними. */
#message-dialog-text {
    margin-top: 0;
}

/* Шеврон рисуется контуром, а не символом шрифта.
   Размер кнопки и область нажатия остаются прежними. */
.topbar .back-button .back-chevron {
    display: block;
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Более тонкий контур конверта.
   Размер значка и область нажатия кнопки не меняются. */
#feedback-button .topbar-icon {
    stroke-width: 1.6;
}

/* ===== Окно добровольной поддержки проекта ===== */

/* Отдельные классы не меняют выгрузку, удаление и выбор языка. */
#support-dialog {
    height: 100vh;
    height: 100dvh;
    padding-top: calc(16px + env(safe-area-inset-top));
}

.support-dialog-card {
    max-width: 440px;
    max-height: min(86vh, 100%);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.support-dialog-header,
.dialog-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.support-dialog-header h2,
.dialog-title-row h2 {
    min-width: 0;
}

/* Значок небольшой, но область нажатия остаётся удобной. */
.support-close-button,
.dialog-close-button {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--secondary-text);
    font-size: 30px;
    cursor: pointer;
}

.support-dialog-card .support-section {
    margin-top: 20px;
}

.support-dialog-card .support-section > p:first-child {
    margin-top: 0;
    color: var(--primary-text);
}

.support-wide-button {
    width: 100%;
    min-height: 46px;
    margin-top: 12px;
}

.support-dialog-card h3 {
    margin: 0 0 12px;
    font-size: 16px;
    line-height: 1.3;
}

.support-presets {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.support-preset {
    min-width: 0;
    min-height: 46px;
    padding: 9px 4px;
    white-space: nowrap;
}

.support-preset[aria-pressed="true"] {
    border-color: var(--button-color);
    background: var(--button-color);
    color: var(--button-text-color);
}

#support-stars-input {
    scroll-margin-block: 16px;
}

#support-stars-input[aria-invalid="true"] {
    border-color: #d9534f;
}

.support-dialog-card .support-input-error {
    margin-top: 6px;
    color: #d9534f;
    font-size: 13px;
}

.support-confirm-slot {
    min-height: 60px;
    padding-top: 12px;
}

#support-confirm-button {
    width: 100%;
}

.support-dialog-card .support-action-status,
.support-dialog-card .support-voluntary-text {
    margin-top: 10px;
    font-size: 13px;
    line-height: 1.45;
    white-space: pre-line;
}

.support-dialog-card .support-contact-section {
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.support-dialog-card button:focus-visible {
    outline: 2px solid var(--link-color);
    outline-offset: 2px;
}

/* Недоступный крестик не должен выглядеть как действующая кнопка. */
.dialog-close-button:disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

/* Видимая рамка при переходе к крестику клавишей Tab. */
.dialog-close-button:focus-visible {
    outline: 2px solid var(--link-color);
    outline-offset: 2px;
}

/* Число и SVG-звезда располагаются по центру одной строкой.
   Размеры самой кнопки и её disabled-состояние остаются прежними. */
.support-preset,
#support-confirm-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* Один и тот же значок используется во всех кнопках поддержки.
   Внутри PNG есть небольшие прозрачные поля вокруг звезды. */
.support-star-icon {
    display: block;
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

/* Золотая основа остаётся узнаваемой и на обычной,
   и на подсвеченной кнопке. */
.support-star-body {
    fill: #ffca28;
    stroke: #e99a00;
    stroke-width: 0.7;
    stroke-linejoin: round;
}

/* Диагональная полоска внутри звезды. */
.support-star-stripe {
    fill: none;
    stroke: #ed9800;
    stroke-width: 2.5;
    stroke-linecap: round;
}

/* Благодарность компактнее обычного окна сообщений.
   Другие уведомления сохраняют прежние размеры и оформление. */
.support-thanks-popup .message-dialog-card {
    max-width: 320px;
    text-align: center;
}

.support-thanks-popup #message-dialog-text {
    margin: 0;
    color: var(--primary-text);
    font-size: 16px;
    font-weight: 600;
    line-height: 1.45;
}

.support-thanks-popup .dialog-actions {
    margin-top: 16px;
}

/* Галочка крупнее обычной текстовой подписи.
   Ширина и область нажатия кнопки остаются удобными. */
.support-thanks-popup #message-dialog-close-button {
    min-height: 46px;
    font-size: 24px;
    line-height: 1;
}