* { margin: 0; padding: 0; box-sizing: border-box; }

/* WebKit / Safari поддержка */
* {
    -webkit-tap-highlight-color: transparent;
}
html {
    -webkit-text-size-adjust: 100%;
}
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: #2a2a2a;
    color: #d0d0d0;
    font: 14px/1.4 Arial, sans-serif;
    padding: 20px;
}
.wrapper {
    max-width: 1000px;
    margin: 0 auto;
    background: #3a3a3a;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}
header {
    display: -webkit-flex;
    display: flex;
    -webkit-justify-content: space-between;
    justify-content: space-between;
    -webkit-align-items: center;
    align-items: center;
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
    border-bottom: 2px solid #555;
    padding-bottom: 10px;
    margin-bottom: 20px;
}
header h1 a {
    color: #e0c080;
    text-decoration: none;
    font-size: 24px;
}
header h1 a:hover {
    text-decoration: underline;
}
.user-info a, .user-info span {
    color: #b0b0b0;
    text-decoration: none;
    margin-left: 15px;
}
.user-info a:hover {
    color: #fff;
}
.flash {
    padding: 10px;
    margin: 10px 0;
    border-radius: 4px;
}
.flash.success { background: #2a6b2a; color: #c8ffc8; }
.flash.error { background: #6b2a2a; color: #ffc8c8; }
.flash.info { background: #2a4a6b; color: #c8d8ff; }

table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    background: #444;
}
th {
    background: #555;
    color: #eee;
    padding: 8px;
    text-align: left;
}
td {
    padding: 8px;
    border-bottom: 1px solid #555;
}
tr:hover {
    background: #4a4a4a;
}
a {
    color: #c8a060;
}
a:hover {
    color: #e0c080;
}
.button, .form button {
    display: inline-block;
    background: #5a5a5a;
    color: #eee;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
}
.button:hover, .form button:hover {
    background: #6a6a6a;
}
.form label {
    display: block;
    margin: 10px 0;
}
.form input, .form textarea {
    width: 100%;
    padding: 8px;
    background: #333;
    border: 1px solid #555;
    color: #ddd;
    border-radius: 4px;
}
.form textarea {
    resize: vertical;
}
.post {
    background: #3d3d3d;
    margin: 15px 0;
    padding: 10px;
    border-left: 4px solid #c8a060;
}
.post-header {
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
}
.post-header .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    -o-object-fit: cover;
    object-fit: cover;
}
.post-header strong {
    color: #e0c080;
}
.post-header .date {
    color: #888;
    font-size: 12px;
    margin-left: auto;
}
.post-header a {
    font-size: 12px;
}
.post-content {
    padding-left: 10px;
    line-height: 1.6;
}
.post-content blockquote {
    border-left: 3px solid #c8a060;
    padding-left: 15px;
    margin: 10px 0;
    background: #2d2d2d;
}
.post-footer {
    margin-top: 8px;
    border-top: 1px solid #555;
    padding-top: 6px;
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    gap: 10px;
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
}
.like-btn {
    background: #4a4a4a;
    color: #ddd;
    border: none;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}
.like-btn:hover {
    background: #6a6a6a;
}
.delete {
    background: #6b2a2a;
    color: #ffc8c8;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
}
.delete:hover {
    background: #8a3a3a;
}
.delete.small {
    padding: 1px 6px;
    font-size: 11px;
}
.button.small {
    padding: 2px 10px;
    font-size: 12px;
}
.avatar-big {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    -o-object-fit: cover;
    object-fit: cover;
    margin: 10px 0;
}
.avatar-small {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    -o-object-fit: cover;
    object-fit: cover;
}
.actions {
    margin: 15px 0;
}
footer {
    margin-top: 30px;
    border-top: 1px solid #555;
    padding-top: 15px;
    text-align: center;
    color: #777;
}
.error-page {
    text-align: center;
    padding: 40px 0;
}
.error-page h2 {
    color: #e0c080;
    font-size: 28px;
}
.error-page p {
    margin: 20px 0;
}
.search-bar {
    margin: 15px 0;
}
.search-form {
    display: -webkit-flex;
    display: flex;
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
    gap: 8px;
    -webkit-align-items: center;
    align-items: center;
}
.search-form input[type="text"] {
    -webkit-flex: 1 1 200px;
    flex: 1 1 200px;
    padding: 8px;
    background: #333;
    border: 1px solid #555;
    color: #ddd;
    border-radius: 4px;
    min-width: 150px;
}
.search-form .button {
    padding: 8px 16px;
}
.reply-form textarea {
    width: 100%;
    max-width: 700px;
    height: 120px;
    padding: 8px;
    box-sizing: border-box;
    resize: vertical;
    background: #333;
    border: 1px solid #555;
    color: #ddd;
    border-radius: 4px;
}
.reply-form .button {
    margin-top: 10px;
}
.post-content img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 8px 0;
}
.mention {
    color: #e0c080;
    font-weight: bold;
    text-decoration: none;
}
.mention:hover {
    text-decoration: underline;
    color: #ffdd44;
}

/* === ТАБЛИЦЫ В СООБЩЕНИЯХ (Markdown) – ДЕСКТОП === */
.post-content table {
    display: -webkit-table;
    display: table;
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
}
.post-content table th,
.post-content table td {
    border: 1px solid #555;
    padding: 8px 10px;
    white-space: nowrap;
    vertical-align: top;
}
.post-content table th {
    background: #4a4a4a;
    font-weight: bold;
}

/* Закреплённое поле ответа */
.reply-sticky {
    position: -webkit-sticky;
    position: sticky;
    bottom: 0;
    background: #3a3a3a;
    padding: 15px 10px;
    border-top: 2px solid #555;
    margin: 0 -20px -20px -20px;
    z-index: 10;
}
.pagination .active {
    font-weight: bold;
    background: #c8a060;
    color: #222;
}
.pagination .button.small {
    padding: 4px 10px;
    min-width: 30px;
    text-align: center;
}

/* ============================================================== */
/* ДЛЯ ТЕЛЕФОНОВ (ЭКРАНЫ МЕНЬШЕ 768px)                            */
/* ============================================================== */
@media (max-width: 768px) {
    body { padding: 5px; font-size: 12px; }
    .wrapper { padding: 5px; }
    header { -webkit-flex-direction: column; flex-direction: column; -webkit-align-items: flex-start; align-items: flex-start; gap: 8px; }
    header h1 { font-size: 18px; }

    .table-responsive {
        overflow: visible !important;
        width: 100% !important;
    }

    /* ГЛАВНАЯ ТАБЛИЦА (topics) — ПРЕВРАЩАЕМ В КАРТОЧКИ */
    table.topics, table.topics thead, table.topics tbody {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }
    table.topics thead { display: none !important; }

    table.topics tr {
        display: -webkit-flex !important;
        display: flex !important;
        -webkit-flex-direction: column !important;
        flex-direction: column !important;
        width: 100% !important;
        max-width: 100% !important;
        margin-bottom: 10px !important;
        background: #3d3d3d !important;
        border: 1px solid #555 !important;
        border-radius: 6px !important;
        padding: 10px 12px !important;
        box-sizing: border-box !important;
    }
    table.topics td {
        display: -webkit-flex !important;
        display: flex !important;
        -webkit-justify-content: space-between !important;
        justify-content: space-between !important;
        -webkit-align-items: flex-start;
        align-items: flex-start;
        width: 100% !important;
        padding: 3px 0 !important;
        border-bottom: 1px solid #4a4a4a !important;
        font-size: 12px;
    }
    table.topics td:last-child { border-bottom: none !important; }

    table.topics td:before {
        content: attr(data-label) ": ";
        font-weight: bold !important;
        color: #e0c080 !important;
        margin-right: 8px !important;
        -webkit-flex-shrink: 0 !important;
        flex-shrink: 0 !important;
        white-space: nowrap !important;
    }
    table.topics td[data-label="Управление"] {
        display: -webkit-flex !important;
        display: flex !important;
        -webkit-flex-wrap: wrap !important;
        flex-wrap: wrap !important;
        gap: 5px !important;
        border-bottom: none !important;
    }
    table.topics td[data-label="Управление"]:before { display: none !important; }

    table.topics td a {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        word-break: break-all !important;
        overflow-wrap: anywhere !important;
        white-space: normal !important;
    }

    /* АДМИНКА (users) — ПРЕВРАЩАЕМ В КАРТОЧКИ */
    table.users, table.users tbody, table.users tr, table.users td {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }
    table.users tr:first-child { display: none !important; }
    table.users tr {
        display: -webkit-flex !important;
        display: flex !important;
        -webkit-flex-direction: column !important;
        flex-direction: column !important;
        margin-bottom: 10px;
        background: #3d3d3d;
        border: 1px solid #555;
        border-radius: 6px;
        padding: 8px 10px !important;
    }
    table.users td {
        display: -webkit-flex !important;
        display: flex !important;
        -webkit-justify-content: space-between !important;
        justify-content: space-between !important;
        padding: 3px 0 !important;
        border-bottom: 1px solid #4a4a4a;
        word-break: break-all !important;
        width: 100% !important;
        min-width: 0 !important;
        font-size: 11px !important;
    }
    table.users td:last-child { border-bottom: none !important; }
    table.users td:before {
        content: attr(data-label) ": ";
        font-weight: bold;
        color: #e0c080;
        margin-right: 8px;
        -webkit-flex-shrink: 0;
        flex-shrink: 0;
        white-space: nowrap;
    }
    table.users td[data-label="Действие"] {
        display: -webkit-flex !important;
        display: flex !important;
        -webkit-flex-wrap: wrap;
        flex-wrap: wrap;
        gap: 5px;
        -webkit-justify-content: flex-start;
        justify-content: flex-start;
        border-bottom: none;
    }
    table.users td[data-label="Действие"]:before { display: none !important; }
    table.users td[data-label="Аватар"] img { width: 25px !important; height: 25px !important; }

    /* Таблицы внутри сообщений (Markdown) */
    .post-content table, .post-content th, .post-content td {
        width: 100% !important;
        max-width: 100% !important;
        table-layout: fixed !important;
        white-space: normal !important;
    }
    .post-header { -webkit-flex-wrap: wrap; flex-wrap: wrap; gap: 5px; }
    .post-header .date { margin-left: 0; width: 100%; }
    .form input, .form textarea { font-size: 16px; }
    .avatar-big { width: 60px; height: 60px; }
}
/* ===== КОНЕЦ МЕДИА-ЗАПРОСА ===== */

/* === ГЛОБАЛЬНЫЕ СТИЛИ ДЛЯ ВСЕХ УСТРОЙСТВ === */
/* Плавный скролл пальцем на iOS */
.table-wrapper,
.post-content table,
.reply-sticky {
    -webkit-overflow-scrolling: touch;
}

/* Сворачивание длинных сообщений */
.post-content.collapsed {
    max-height: 300px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.post-content:not(.collapsed) {
    max-height: none;
}
.read-more {
    display: inline-block;
    margin: 10px 0;
    background: #5a5a5a;
    color: #eee;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}
.read-more:hover {
    background: #6a6a6a;
}

/* Reactions */
.reactions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.reaction-btn { background: #4a4a4a; border: none; color: #ddd; padding: 2px 8px; border-radius: 12px; cursor: pointer; font-size: 14px; }
.reaction-btn:hover { background: #6a6a6a; }

/* Chat */
.chat-message { padding: 8px 0; border-bottom: 1px solid #444; }
.avatar-small { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; vertical-align: middle; margin-right: 6px; }

/* Themes */
body.theme-dark { background: #2a2a2a; color: #d0d0d0; }
body.theme-light { background: #f0f0f0; color: #222; }
body.theme-blue { background: #1a2a4a; color: #c0d0e0; }
body.theme-light .wrapper, body.theme-light .post, body.theme-light table.topics, body.theme-light header, body.theme-light footer { background: #fff; color: #222; }
body.theme-light a { color: #3366aa; }
body.theme-light input, body.theme-light textarea, body.theme-light select { background: #fff; color: #222; border-color: #aaa; }
body.theme-blue .wrapper, body.theme-blue .post, body.theme-blue table.topics, body.theme-blue header, body.theme-blue footer { background: #22385f; color: #c0d0e0; }
body.theme-blue a { color: #9ec5ff; }
body.theme-blue input, body.theme-blue textarea, body.theme-blue select { background: #162844; color: #c0d0e0; border-color: #5173a8; }


/* Full account themes */
body.theme-dark {
    background: #2a2a2a !important;
    color: #d0d0d0 !important;
}
body.theme-dark .wrapper,
body.theme-dark table,
body.theme-dark .post,
body.theme-dark header,
body.theme-dark footer,
body.theme-dark .reply-sticky,
body.theme-dark .chat-message {
    background: #3a3a3a;
    color: #d0d0d0;
}

body.theme-light {
    background: #f0f0f0 !important;
    color: #222 !important;
}
body.theme-light .wrapper,
body.theme-light table,
body.theme-light .post,
body.theme-light header,
body.theme-light footer,
body.theme-light .reply-sticky,
body.theme-light .chat-message {
    background: #ffffff !important;
    color: #222 !important;
    border-color: #d0d0d0 !important;
}
body.theme-light th { background: #e5e5e5 !important; color: #222 !important; }
body.theme-light td { border-bottom-color: #d0d0d0 !important; }
body.theme-light tr:hover { background: #f4f4f4 !important; }
body.theme-light a { color: #2b5f9e !important; }
body.theme-light input,
body.theme-light textarea,
body.theme-light select {
    background: #fff !important;
    color: #222 !important;
    border-color: #aaa !important;
}
body.theme-light .button,
body.theme-light button { background: #e0e0e0; color: #222; }

body.theme-blue {
    background: #1a2a4a !important;
    color: #c0d0e0 !important;
}
body.theme-blue .wrapper,
body.theme-blue table,
body.theme-blue .post,
body.theme-blue header,
body.theme-blue footer,
body.theme-blue .reply-sticky,
body.theme-blue .chat-message {
    background: #22385f !important;
    color: #c0d0e0 !important;
    border-color: #5173a8 !important;
}
body.theme-blue th { background: #2e4a78 !important; color: #e6f0ff !important; }
body.theme-blue td { border-bottom-color: #5173a8 !important; }
body.theme-blue tr:hover { background: #2a436e !important; }
body.theme-blue a { color: #9ec5ff !important; }
body.theme-blue input,
body.theme-blue textarea,
body.theme-blue select {
    background: #162844 !important;
    color: #c0d0e0 !important;
    border-color: #5173a8 !important;
}
body.theme-blue .button,
body.theme-blue button { background: #345a91; color: #eef5ff; }


/* Light/blue theme fixes: quotes, rating buttons, pinned topics */
body.theme-light .post-content blockquote {
    background: #f3f0e8 !important;
    color: #222 !important;
    border-left-color: #d39b2f !important;
}
body.theme-light .post-content blockquote * {
    color: #222 !important;
}
body.theme-light .like-btn,
body.theme-light .reaction-btn {
    background: #d8dde6 !important;
    color: #1f2937 !important;
    border: 1px solid #b8c0cc !important;
}
body.theme-light .like-btn:hover,
body.theme-light .reaction-btn:hover {
    background: #c4ccd8 !important;
}
body.theme-light table.topics tr[style*="background:#4a4a2a"],
body.theme-light table.topics tr[style*="background: #4a4a2a"] {
    background: #fff4c2 !important;
    color: #222 !important;
}
body.theme-light table.topics tr[style*="background:#4a4a2a"] td,
body.theme-light table.topics tr[style*="background: #4a4a2a"] td {
    color: #222 !important;
    border-bottom-color: #d8c56f !important;
}
body.theme-light table.topics tr[style*="background:#4a4a2a"] a,
body.theme-light table.topics tr[style*="background: #4a4a2a"] a {
    color: #245a9b !important;
}

body.theme-blue .post-content blockquote {
    background: #172944 !important;
    color: #dcecff !important;
    border-left-color: #e0b85d !important;
}
body.theme-blue .post-content blockquote * {
    color: #dcecff !important;
}
body.theme-blue .like-btn,
body.theme-blue .reaction-btn {
    background: #2f5284 !important;
    color: #eef5ff !important;
    border: 1px solid #6f94c9 !important;
}
body.theme-blue .like-btn:hover,
body.theme-blue .reaction-btn:hover {
    background: #416aa5 !important;
}
body.theme-blue table.topics tr[style*="background:#4a4a2a"],
body.theme-blue table.topics tr[style*="background: #4a4a2a"] {
    background: #34496f !important;
    color: #e6f0ff !important;
}
body.theme-blue table.topics tr[style*="background:#4a4a2a"] td,
body.theme-blue table.topics tr[style*="background: #4a4a2a"] td {
    color: #e6f0ff !important;
    border-bottom-color: #6f94c9 !important;
}
body.theme-blue table.topics tr[style*="background:#4a4a2a"] a,
body.theme-blue table.topics tr[style*="background: #4a4a2a"] a {
    color: #b9d7ff !important;
}


/* Folders */
.folder-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin: 15px 0; }
.folder-card { background: #444; border: 1px solid #555; border-radius: 8px; padding: 12px; }
.folder-card h3 { margin-bottom: 8px; }
.folder-card p { margin: 6px 0; color: #bbb; }
body.theme-light .folder-card { background: #fff !important; color: #222 !important; border-color: #d0d0d0 !important; }
body.theme-light .folder-card p { color: #555 !important; }
body.theme-blue .folder-card { background: #22385f !important; color: #c0d0e0 !important; border-color: #5173a8 !important; }
body.theme-blue .folder-card p { color: #dcecff !important; }


/* Compact tags in topic tables */
/* Теги сокращаются только когда реально не помещаются в строку. */
table.topics td.tags-cell,
table.topics td[data-label="Теги"] {
    max-width: min(420px, 45vw);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
table.topics tr {
    height: 56px;
}
@media (max-width: 700px) {
    table.topics td.tags-cell,
    table.topics td[data-label="Теги"] {
        max-width: 100% !important;
        width: auto !important;
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
    }
    table.topics tr { height: auto; }
}


/* SVG reaction icons */
.reaction-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
    vertical-align: -4px;
    margin-right: 3px;
}
.reaction-btn {
    min-height: 26px;
    line-height: 18px;
}
.wall-post { margin: 12px 0; }


/* Prefer SVG reaction icons over system emoji */
.reaction-emoji-fallback.svg-loaded {
    display: none;
}
.reaction-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
    vertical-align: -4px;
    margin-right: 3px;
}


/* SVG-only reactions */
.reaction-btn .reaction-icon {
    width: 20px !important;
    height: 20px !important;
    display: inline-block !important;
    object-fit: contain !important;
    vertical-align: -5px !important;
    margin: 0 3px 0 0 !important;
}
.reaction-btn {
    display: inline-flex !important;
    align-items: center !important;
    gap: 3px !important;
}


/* Force long post collapse/read-more */
.post-content.collapsed {
    max-height: 300px !important;
    overflow: hidden !important;
}
.read-more {
    display: inline-block !important;
    margin: 10px 0 !important;
}


/* Preserve chat quote line breaks */
.chat-content {
    white-space: pre-wrap !important;
}

/* Fix topic table width and tablet breakpoint */
.table-responsive {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
}

table.topics {
    width: 100% !important;
    max-width: 100% !important;
    table-layout: fixed !important;
    box-sizing: border-box !important;
}

table.topics th,
table.topics td {
    min-width: 0 !important;
    max-width: 100% !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    box-sizing: border-box !important;
}

table.topics td,
table.topics td a,
table.topics td span {
    overflow-wrap: anywhere !important;
    word-break: normal !important;
}

table.topics td[data-label="Тема"] a,
table.topics td[data-label="Автор"] a,
table.topics td[data-label="Посл. ответ"],
table.topics td[data-label="Статус"] span,
table.topics td.tags-cell,
table.topics td[data-label="Теги"] {
    display: block !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

table.topics td.tags-cell,
table.topics td[data-label="Теги"] {
    max-width: none !important;
}

/* Keep desktop/table layout until 700px. The old 768px breakpoint caused broken cards at 700-764px. */
@media (min-width: 701px) and (max-width: 768px) {
    .table-responsive {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    table.topics {
        display: table !important;
        width: 100% !important;
        max-width: 100% !important;
        table-layout: fixed !important;
    }

    table.topics thead {
        display: table-header-group !important;
    }

    table.topics tbody {
        display: table-row-group !important;
    }

    table.topics tr {
        display: table-row !important;
        height: 56px !important;
        width: auto !important;
        max-width: none !important;
        margin-bottom: 0 !important;
        padding: 0 !important;
        border-radius: 0 !important;
    }

    table.topics th,
    table.topics td {
        display: table-cell !important;
        width: auto !important;
        padding: 6px 4px !important;
        font-size: 11px !important;
        vertical-align: middle !important;
        border-bottom: 1px solid #555 !important;
    }

    table.topics td:before {
        display: none !important;
        content: none !important;
    }

    table.topics td a {
        display: inline-block !important;
        width: auto !important;
        max-width: 100% !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        vertical-align: bottom !important;
    }

    table.topics td[data-label="Статус"] span,
    table.topics td.tags-cell,
    table.topics td[data-label="Теги"] {
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
}

@media (max-width: 700px) {
    .table-responsive {
        overflow: visible !important;
    }
}

/* Better topic table wrapping: allow 2 lines, then ellipsis; fix tags vertical alignment */
@media (min-width: 701px) {
    table.topics {
        table-layout: fixed !important;
    }

    table.topics tr {
        height: auto !important;
        min-height: 56px !important;
    }

    table.topics th,
    table.topics td {
        vertical-align: middle !important;
        height: auto !important;
        min-height: 56px !important;
        line-height: 1.25 !important;
        padding-top: 7px !important;
        padding-bottom: 7px !important;
        border-bottom: 1px solid #555 !important;
    }

    /* Most text cells may wrap to 2 lines, then get clipped instead of stretching the table. */
    table.topics td[data-label="Тема"] a,
    table.topics td[data-label="Автор"] a,
    table.topics td[data-label="Посл. ответ"],
    table.topics td[data-label="Статус"] span,
    table.topics td.tags-cell,
    table.topics td[data-label="Теги"] {
        display: -webkit-box !important;
        -webkit-box-orient: vertical !important;
        -webkit-line-clamp: 2 !important;
        white-space: normal !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        overflow-wrap: anywhere !important;
        word-break: normal !important;
        line-height: 1.25 !important;
        max-height: 2.5em !important;
        vertical-align: middle !important;
    }

    /* Tags cell itself stays a normal table-cell, only its text wraps/clips. */
    table.topics td.tags-cell,
    table.topics td[data-label="Теги"] {
        display: table-cell !important;
        vertical-align: middle !important;
        padding-top: 7px !important;
        padding-bottom: 7px !important;
        border-bottom: 1px solid #555 !important;
    }

    table.topics td.tags-cell::before,
    table.topics td[data-label="Теги"]::before {
        display: none !important;
        content: none !important;
    }
}

/* On medium widths keep rows symmetric and stop the old tablet override from forcing single-line ellipsis. */
@media (min-width: 701px) and (max-width: 768px) {
    table.topics th,
    table.topics td {
        vertical-align: middle !important;
        border-bottom: 1px solid #555 !important;
    }

    table.topics td[data-label="Тема"] a,
    table.topics td[data-label="Автор"] a,
    table.topics td[data-label="Посл. ответ"],
    table.topics td[data-label="Статус"] span,
    table.topics td.tags-cell,
    table.topics td[data-label="Теги"] {
        display: -webkit-box !important;
        -webkit-box-orient: vertical !important;
        -webkit-line-clamp: 2 !important;
        white-space: normal !important;
        max-height: 2.5em !important;
    }

    table.topics td.tags-cell,
    table.topics td[data-label="Теги"] {
        display: table-cell !important;
        vertical-align: middle !important;
    }
}


/* Fix last reply column alignment/link */
@media (min-width: 701px) {
    table.topics td.last-reply-cell,
    table.topics td[data-label="Посл. ответ"] {
        display: table-cell !important;
        vertical-align: middle !important;
        border-bottom: 1px solid #555 !important;
        padding-top: 7px !important;
        padding-bottom: 7px !important;
        line-height: 1.25 !important;
    }
    table.topics td.last-reply-cell a,
    table.topics td[data-label="Посл. ответ"] a {
        display: -webkit-box !important;
        -webkit-box-orient: vertical !important;
        -webkit-line-clamp: 2 !important;
        white-space: normal !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-height: 2.5em !important;
        width: 100% !important;
        border-bottom: none !important;
        text-decoration: underline;
    }
}


/* Final fix: last reply cell must not draw its own shifted inner line */
@media (min-width: 701px) {
    table.topics td.last-reply-cell {
        position: static !important;
        display: table-cell !important;
        vertical-align: middle !important;
        border-bottom: 1px solid #555 !important;
        padding: 7px 8px !important;
        overflow: hidden !important;
        line-height: 1.25 !important;
    }

    table.topics td.last-reply-cell::before,
    table.topics td.last-reply-cell::after,
    table.topics td.last-reply-cell a::before,
    table.topics td.last-reply-cell a::after {
        display: none !important;
        content: none !important;
        border: 0 !important;
    }

    table.topics td.last-reply-cell a {
        display: inline !important;
        width: auto !important;
        max-width: 100% !important;
        color: inherit;
        border: 0 !important;
        border-bottom: 0 !important;
        background-image: none !important;
        box-shadow: none !important;
        text-decoration: underline;
        white-space: normal !important;
        overflow-wrap: anywhere !important;
        word-break: normal !important;
        line-height: 1.25 !important;
        max-height: none !important;
        -webkit-line-clamp: unset !important;
        -webkit-box-orient: initial !important;
    }
}


/* Last reply: remove shifted underline, keep cell border aligned */
@media (min-width: 701px) {
    table.topics td.last-reply-cell {
        display: table-cell !important;
        vertical-align: middle !important;
        border-bottom: 1px solid #555 !important;
        background-image: none !important;
        box-shadow: none !important;
    }

    table.topics td.last-reply-cell a,
    table.topics td[data-label="Посл. ответ"] a {
        text-decoration: none !important;
        border: 0 !important;
        border-bottom: 0 !important;
        box-shadow: none !important;
        background: transparent !important;
        background-image: none !important;
        display: inline !important;
        width: auto !important;
        max-width: 100% !important;
        white-space: normal !important;
        overflow-wrap: anywhere !important;
    }

    table.topics td.last-reply-cell a:hover,
    table.topics td[data-label="Посл. ответ"] a:hover {
        text-decoration: underline !important;
    }
}


/* Chat markdown/quotes final restore */
.chat-content {
    white-space: normal !important;
}
.chat-content blockquote {
    margin: 6px 0;
    padding: 6px 10px;
    border-left: 3px solid #c8a060;
    background: rgba(200,160,96,0.10);
    border-radius: 4px;
}
.chat-content p {
    margin: 4px 0;
}
