.portal-mobile-header { display: none; }

@media (max-width: 1050px) {
    body { margin: 0; }
    .portal-desktop-header { display: none; }
    .portal-mobile-header {
        display: block;
        padding: 0.75rem;
        background: #b6c0b5;
        border-bottom: 1px solid #566d55;
        font: 16px/1.35 system-ui, sans-serif;
    }

    .portal-mobile-top {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        margin-bottom: 0.7rem;
    }

    .portal-mobile-brand {
        display: flex;
        align-items: center;
        gap: 0.65rem;
        min-width: 0;
        font: bold clamp(1.1rem, 4.8vw, 1.55rem)/1.2 Georgia, serif;
    }

    .portal-mobile-header a { color: #17291c; text-decoration: none; }
    .portal-mobile-header :focus-visible { outline: 2px solid #243f2b; outline-offset: 2px; }
    .portal-mobile-navigation,
    .portal-mobile-options nav {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.35rem;
    }

    .portal-mobile-navigation a,
    .portal-mobile-options a,
    .portal-mobile-options summary {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 44px;
        padding: 0.25rem;
        border: 1px solid #627961;
        border-radius: 0.25rem;
        background: #e6eee3;
        text-align: center;
        box-sizing: border-box;
    }

    .portal-mobile-options summary {
        width: 44px;
        list-style: none;
        cursor: pointer;
        font-size: 1.5rem;
    }
    .portal-mobile-options summary::-webkit-details-marker { display: none; }
    .portal-mobile-options:not([open]) nav { display: none; }
    .portal-mobile-options nav {
        position: absolute;
        z-index: 2;
        inset-inline: 0;
        top: calc(100% + 0.35rem);
        max-height: 65vh;
        overflow-y: auto;
        padding: 0.45rem;
        border: 1px solid #627961;
        border-radius: 0.25rem;
        background: #b6c0b5;
        box-shadow: 0 4px 12px rgb(23 41 28 / 25%);
    }

    .portal-sidebar-options, .portal-sidebar-options + br { display: none; }

    .portal-shell, .portal-layout, .portal-footer, .portal-footer table {
        width: 100%;
        box-sizing: border-box;
    }

    .portal-shell, .portal-shell > tbody, .portal-shell > tbody > tr, .portal-shell > tbody > tr > td,
    .portal-layout, .portal-layout > tbody { display: block; }
    .portal-layout > tbody > tr { display: flex; flex-direction: column; }
    .portal-layout > tbody > tr > td { display: block; width: 100%; min-width: 0; box-sizing: border-box; }

    .portal-content {
        order: -1;
        height: auto;
        padding: 0.5rem;
        overflow-x: auto;
        overflow-wrap: anywhere;
        text-size-adjust: 100%;
    }

    .portal-content table { max-width: 100%; }
    .portal-content :is(img, iframe, video, object, embed) { max-width: 100%; }
    .portal-content img { height: auto; }
    .portal-content :is(input, select, textarea, button) { max-width: 100%; box-sizing: border-box; }
    .portal-content :is(input:not([type="hidden"], [type="image"]), select, textarea) { font-size: 16px; }
    .portal-content :is(button, input[type="submit"]) { min-height: 44px; }
    .portal-content pre { white-space: pre-wrap; overflow-wrap: anywhere; }
    .portal-sidebar { padding: 0.5rem; }
    .portal-sidebar > table { width: 100%; }
    .portal-sidebar a { display: inline-block; padding-block: 0.25rem; }

    .forum-stats { padding-inline: 0.25rem; }
    .forum-stats-periods { flex-direction: column; }
    .forum-stats-panel { box-sizing: border-box; min-width: 0; width: min(100%, 28rem); padding-inline: 0.45rem; }
    .forum-stats-panel table { width: 100%; min-width: 0; }
    .forum-stats-panel th, .forum-stats-panel td { padding-inline: 0.25rem; }
    .forum-stats-panel td { white-space: nowrap; }
    .forum-stats [data-stats-archive] { overflow-x: auto; }
}

@media (max-width: 640px) {
    .portal-content :is([class~="11px"], [class~="12px"]) { font-size: 14px; }
    .portal-mobile-static { padding: 0.5rem; overflow-wrap: anywhere; }
    .portal-mobile-static table { max-width: 100%; }
    .portal-mobile-static img { max-width: 100%; height: auto; }
    .portal-mobile-static a { overflow-wrap: anywhere; }
    .portal-mobile-static--books table[bordercolor] > tbody > tr {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .portal-mobile-static--books table[bordercolor] > tbody > tr:first-child {
        display: none;
    }
    .portal-mobile-static--books table[bordercolor] > tbody > tr > td:nth-child(1):not([colspan]) {
        width: clamp(75px, 25%, 100px);
    }
    .portal-mobile-static--books table[bordercolor] > tbody > tr > td:nth-child(2) {
        width: auto;
        flex: 1;
        min-width: 0;
    }
    .portal-mobile-static--books table[bordercolor] > tbody > tr > td:nth-child(3),
    .portal-mobile-static--books table[bordercolor] > tbody > tr > td[colspan] {
        width: 100%;
    }
}
