/* ============================================
   WIKI + FORUM — мобильная версия
   Минималистично: сайдбар в drawer, контент на всю ширину
   ============================================ */

@media (max-width: 768px) {
    :root {
        --wf-touch: 48px;
        --wf-drawer-w: min(280px, 88vw);
    }

    body {
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    /* --- WIKI HEADER --- */
    .wiki-header {
        flex-wrap: wrap;
        padding: 10px 12px;
        padding-top: calc(10px + env(safe-area-inset-top, 0px));
        gap: 10px;
    }
    .wiki-header-left {
        flex: 1;
        min-width: 0;
    }
    .wiki-logo {
        font-size: 1rem;
    }
    .wiki-logo-text {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .wiki-header-center {
        order: 3;
        width: 100%;
    }
    .wiki-search-box {
        width: 100%;
        max-width: none;
    }
    .wiki-header-right {
        flex-wrap: wrap;
        gap: 8px;
    }
    .wiki-back-btn {
        padding: 8px 14px;
        min-height: 40px;
        font-size: 0.85em;
    }
    .wiki-editor-btn {
        min-height: 40px;
        padding: 8px 14px;
    }

    /* --- FORUM HEADER (поиск и кнопки) --- */
    .forum-search-wrap {
        order: 3;
        width: 100%;
        margin-right: 0;
        margin-top: 4px;
    }
    .forum-search-input {
        flex: 1;
        min-width: 0;
        min-height: 44px;
        font-size: 16px;
    }
    .forum-search-btn {
        min-width: 48px;
        min-height: 44px;
    }

    /* --- WIKI LAYOUT --- */
    .wiki-layout {
        flex-direction: column;
        min-height: calc(100vh - 52px);
    }
    .wiki-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: var(--wf-drawer-w);
        height: 100vh;
        height: 100dvh;
        z-index: 8001;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
        border-right: 1px solid var(--color-border);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.4);
        padding-top: calc(12px + env(safe-area-inset-top, 0));
        padding-bottom: env(safe-area-inset-bottom, 0);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .wiki-sidebar.open {
        transform: translateX(0);
    }
    .wiki-sidebar-header {
        padding: 14px 16px;
        font-size: 0.75em;
    }
    .wiki-nav-category-header {
        min-height: var(--wf-touch);
        padding: 12px 16px;
        font-size: 0.9em;
    }
    .wiki-nav-article {
        padding: 10px 16px 10px 38px;
        font-size: 0.9em;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    .wiki-content {
        flex: 1;
        width: 100%;
        padding: 14px 16px;
        padding-bottom: calc(14px + env(safe-area-inset-bottom, 0));
        max-height: none;
        min-width: 0;
    }
    .wiki-breadcrumbs {
        font-size: 0.85em;
        margin-bottom: 12px;
        padding: 8px 0;
    }
    .wiki-article {
        font-size: 0.95em;
        line-height: 1.6;
    }
    .wiki-article h1 { font-size: 1.35rem; }
    .wiki-article h2 { font-size: 1.15rem; }
    .wiki-article h3 { font-size: 1.05rem; }
    .wiki-article table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* --- FORUM LAYOUT --- */
    .forum-layout {
        flex-direction: column;
        min-height: calc(100vh - 52px);
    }
    .forum-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: var(--wf-drawer-w);
        height: 100vh;
        height: 100dvh;
        z-index: 8001;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
        border-right: 1px solid var(--color-border);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.4);
        padding-top: calc(12px + env(safe-area-inset-top, 0));
        padding-bottom: env(safe-area-inset-bottom, 0);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .forum-sidebar.open {
        transform: translateX(0);
    }
    .forum-sidebar-header {
        padding: 14px 16px;
        font-size: 0.7em;
    }
    .forum-nav-item {
        min-height: var(--wf-touch);
        padding: 12px 16px;
        font-size: 0.9em;
    }
    .forum-content {
        flex: 1;
        width: 100%;
        padding: 14px 16px;
        padding-bottom: calc(14px + env(safe-area-inset-bottom, 0));
        min-width: 0;
    }
    .forum-view {
        min-height: 200px;
    }
    .forum-guest-banner {
        padding: 12px 16px;
        font-size: 0.9em;
        margin-bottom: 14px;
    }
    .forum-breadcrumb {
        font-size: 0.85em;
        margin-bottom: 12px;
        padding: 8px 0;
    }
    .forum-section-header {
        padding: 12px 14px;
        font-size: 0.7em;
    }
    .forum-category-table {
        font-size: 0.85em;
    }
    .forum-category-table th,
    .forum-category-table td {
        padding: 10px 12px;
    }
    .forum-category-table th:nth-child(2),
    .forum-category-table th:nth-child(3) {
        width: 50px;
    }
    .forum-category-icon {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
    .forum-category-name { font-size: 0.95em; }
    .forum-category-desc { display: none; }
    .forum-btn-new {
        width: 100%;
        min-height: 44px;
        margin-top: 8px;
        border-radius: 8px;
    }
    .forum-list-item {
        padding: 12px 14px;
        font-size: 0.9em;
    }
    .forum-topic-header h2 {
        font-size: 1.1rem;
    }
    .forum-post {
        padding: 14px;
        font-size: 0.95em;
    }
    .forum-pagination {
        flex-wrap: wrap;
        gap: 8px;
        margin-top: 14px;
    }
    .forum-pagination a,
    .forum-pagination span {
        min-height: 44px;
        padding: 10px 14px;
    }

    /* Кнопка «Меню» для открытия сайдбара */
    .wiki-forum-menu-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        background: var(--color-panel-light);
        border: 1px solid var(--color-border);
        border-radius: 8px;
        color: var(--color-text);
        font-size: 1.3em;
        cursor: pointer;
        flex-shrink: 0;
    }
    .wiki-forum-menu-btn:hover {
        background: var(--color-panel-hover);
        border-color: var(--color-accent);
    }
    .wiki-forum-overlay {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 8000;
        background: rgba(0, 0, 0, 0.45);
        opacity: 0;
        transition: opacity 0.25s ease;
    }
    .wiki-forum-overlay.open {
        display: block;
        opacity: 1;
    }
}

@media (max-width: 480px) {
    .wiki-content,
    .forum-content {
        padding: 12px;
    }
    .forum-category-table {
        font-size: 0.8em;
    }
    .forum-category-table th:nth-child(4) {
        min-width: 120px;
    }
}

/* Десктоп: скрыть кнопку меню и overlay */
@media (min-width: 769px) {
    .wiki-forum-menu-btn,
    .wiki-forum-overlay {
        display: none !important;
    }
    .wiki-sidebar.open,
    .forum-sidebar.open {
        transform: none;
    }
}
