/* Списки тем форума: компактнее на узких экранах и в APK WebView. */

@media (max-width: 767.98px) {
    .forum-header {
        height: min(200px, 26vh);
        min-height: 140px;
    }

    .forum-table.forum-table--topics-5 th:nth-child(4),
    .forum-table.forum-table--topics-5 td:nth-child(4) {
        display: none;
    }

    .forum-table.forum-table--topics-6 th:nth-child(5),
    .forum-table.forum-table--topics-6 td:nth-child(5) {
        display: none;
    }

    .forum-topics-list {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
        padding-left: max(8px, env(safe-area-inset-left, 0px)) !important;
        padding-right: max(8px, env(safe-area-inset-right, 0px)) !important;
        padding-top: 10px !important;
        padding-bottom: 10px !important;
    }

    .forum-table.forum-table--topics-5,
    .forum-table.forum-table--topics-6 {
        table-layout: fixed;
        width: 100%;
        font-size: 0.8125rem;
        border-collapse: collapse;
    }

    /* Заголовки — одна базовая линия; ячейки тем — сверху из‑за переносов */
    .forum-table.forum-table--topics-5 thead th,
    .forum-table.forum-table--topics-6 thead th {
        vertical-align: middle !important;
        padding: 0.45rem 0.3rem !important;
        line-height: 1.15;
        font-size: 0.72rem;
    }

    .forum-table.forum-table--topics-5 tbody td,
    .forum-table.forum-table--topics-6 tbody td {
        padding: 0.35rem 0.3rem !important;
        vertical-align: top !important;
        word-wrap: break-word;
    }

    /* Тема | Автор (минимальный зазор до ответов) | Ответы | Активность */
    .forum-table.forum-table--topics-5 td:nth-child(1),
    .forum-table.forum-table--topics-5 thead th:nth-child(1) {
        width: 40%;
        max-width: 0;
    }

    .forum-table.forum-table--topics-5 thead th:nth-child(2),
    .forum-table.forum-table--topics-5 tbody td:nth-child(2) {
        width: 24%;
        max-width: 0;
        font-size: 0.75rem;
    }

    .forum-table.forum-table--topics-5 tbody td:nth-child(2) {
        padding-right: 0.05rem !important;
        padding-left: 0.2rem !important;
    }

    .forum-table.forum-table--topics-5 thead th:nth-child(3) {
        width: 11%;
        min-width: 2.85rem;
        text-align: center;
        vertical-align: middle !important;
    }

    .forum-table.forum-table--topics-5 tbody td:nth-child(3) {
        width: 11%;
        min-width: 2.85rem;
        text-align: center;
        white-space: normal;
        font-size: 0.74rem;
        padding-left: 0.05rem !important;
        padding-right: 0.15rem !important;
        overflow: visible;
        vertical-align: top;
    }

    .forum-table.forum-table--topics-5 thead th:nth-child(5) {
        width: 25%;
        vertical-align: middle !important;
        text-align: right;
    }

    .forum-table.forum-table--topics-5 tbody td:nth-child(5) {
        width: 25%;
        font-size: 0.71rem;
        white-space: normal;
        overflow: visible;
        text-align: right;
        line-height: 1.25;
        padding-left: 0.1rem !important;
        word-break: break-word;
        vertical-align: top;
    }

    /* «Последние»: сумма столбцов 36 + 17 + 17 + 8 + 22 = 100 (просмотры скрыты) */
    .forum-table.forum-table--topics-6 thead th:nth-child(1),
    .forum-table.forum-table--topics-6 tbody td:nth-child(1) {
        width: 36%;
        max-width: 0;
    }

    .forum-table.forum-table--topics-6 thead th:nth-child(2),
    .forum-table.forum-table--topics-6 tbody td:nth-child(2) {
        width: 17%;
        max-width: 0;
    }

    .forum-table.forum-table--topics-6 tbody td:nth-child(2) {
        font-size: 0.72rem;
    }

    .forum-table.forum-table--topics-6 thead th:nth-child(3),
    .forum-table.forum-table--topics-6 tbody td:nth-child(3) {
        width: 17%;
        max-width: 0;
        font-size: 0.73rem;
        padding-right: 0.05rem !important;
    }

    .forum-table.forum-table--topics-6 thead th:nth-child(3) {
        vertical-align: middle !important;
    }

    .forum-table.forum-table--topics-6 tbody td:nth-child(3) {
        vertical-align: top;
        padding-right: 0.05rem !important;
    }

    .forum-table.forum-table--topics-6 thead th:nth-child(4) {
        width: 8%;
        min-width: 2.5rem;
        text-align: center;
        vertical-align: middle !important;
    }

    .forum-table.forum-table--topics-6 tbody td:nth-child(4) {
        width: 8%;
        min-width: 2.5rem;
        text-align: center;
        font-size: 0.72rem;
        padding-left: 0.05rem !important;
        padding-right: 0.15rem !important;
        white-space: normal;
        overflow: visible;
        vertical-align: top;
    }

    .forum-table.forum-table--topics-6 thead th:nth-child(6) {
        width: 22%;
        text-align: right;
        vertical-align: middle !important;
    }

    .forum-table.forum-table--topics-6 tbody td:nth-child(6) {
        width: 22%;
        font-size: 0.71rem;
        white-space: normal;
        overflow: visible;
        text-align: right;
        line-height: 1.25;
        word-break: break-word;
        padding-left: 0.1rem !important;
        vertical-align: top;
    }

    .forum-table.forum-table--topics-5 thead th,
    .forum-table.forum-table--topics-6 thead th {
        white-space: nowrap;
        overflow: visible;
        text-overflow: clip;
    }

    /*
     * Сначала полная строка — ссылка с названием темы (в DOM она после бэйджей дополнения,
     * order:-1 поднимает её визуально наверх). Ниже — 📌 🔒, бэйдж дополнения, теги раздела/статуса.
     */
    .forum-topic-title {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.28rem 0.35rem;
        min-width: 0;
    }

    .forum-topic-title a {
        order: -1;
        flex: 1 1 100%;
        min-width: 0;
        overflow: visible;
        white-space: normal;
        word-break: break-word;
        overflow-wrap: anywhere;
        line-height: 1.3;
        font-weight: 600;
    }

    .forum-topic-title .forum-pinned,
    .forum-topic-title .forum-locked {
        flex-shrink: 0;
        line-height: 1;
    }

    .forum-topic-title .forum-exp-badge,
    .forum-topic-title .forum-subcategory-badge {
        flex: 0 1 auto;
        max-width: 100%;
        overflow: visible;
        white-space: normal;
        word-break: break-word;
        font-size: 0.7rem;
        line-height: 1.25;
        margin: 0;
    }

    .forum-topic-author {
        gap: 0.2rem !important;
    }

    .forum-topic-author-server {
        display: none !important;
    }

    .forum-topic-author-name {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 100%;
        display: inline-block;
        vertical-align: bottom;
    }

    .forum-latest-section-link {
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 100%;
    }
}
