/* Mobile application shell */
@media (max-width: 768px), (max-height: 520px) and (orientation: landscape) {
    .comm-container {
        padding-bottom: calc(104px + env(safe-area-inset-bottom));
    }

    .comm-header-right {
        position: fixed;
        left: 50%;
        right: auto;
        bottom: max(8px, env(safe-area-inset-bottom));
        z-index: 240;
        width: min(520px, calc(100vw - 16px));
        max-width: none;
        min-height: 68px;
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        align-items: end;
        gap: 2px;
        padding: 7px 8px;
        border-color: color-mix(in srgb, var(--app-accent, #818cf8) 18%, rgba(148,163,184,.16));
        border-radius: 20px;
        background: color-mix(in srgb, var(--app-header, #081020) 94%, transparent);
        box-shadow: 0 16px 44px rgba(2,6,23,.34);
        transform: translateX(-50%);
        backdrop-filter: blur(22px) saturate(125%);
        -webkit-backdrop-filter: blur(22px) saturate(125%);
    }

    .comm-header-right > .user-badge,
    .comm-header-right > .notif-btn,
    .comm-header-right > .message-entry-btn,
    .comm-header-right > .mobile-more-toggle {
        position: relative;
        inset: auto;
        width: 100%;
        min-width: 0;
        max-width: none;
        height: 52px;
        min-height: 52px;
        margin: 0;
        padding: 5px 3px;
        border: 0;
        border-radius: 13px;
        color: var(--app-text-muted, rgba(226,232,240,.68));
        background: transparent;
        box-shadow: none;
        transform: none;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        font-size: .68rem;
        font-weight: 700;
        line-height: 1;
    }

    .comm-header-right > :is(.user-badge, .notif-btn, .message-entry-btn, .mobile-more-toggle):active {
        color: var(--app-text, #f8fafc);
        background: color-mix(in srgb, var(--app-accent, #818cf8) 11%, transparent);
    }

    .comm-header-right > .user-badge {
        flex: none;
        border-color: transparent;
    }

    .comm-header-right > .user-badge .user-avatar-sm {
        width: 27px;
        height: 27px;
        flex: 0 0 27px;
    }

    .comm-header-right > .user-badge #header-username {
        max-width: 62px;
        font-size: .65rem;
        line-height: 1.05;
    }

    .comm-header-right > .notif-btn .mobile-nav-label {
        font-size: .68rem;
        line-height: 1;
    }

    .comm-header-right > .fab-post {
        position: relative;
        inset: auto;
        align-self: center;
        justify-self: center;
        width: 50px;
        height: 50px;
        margin: 0;
        border: 1px solid color-mix(in srgb, white 35%, transparent);
        border-radius: 17px;
        box-shadow: 0 10px 25px color-mix(in srgb, var(--app-accent, #6366f1) 40%, transparent);
        transform: translateY(-10px);
    }

    .comm-header-right > .fab-post:active {
        transform: translateY(-8px) scale(.96);
    }

    .comm-header-right > .message-entry-btn::after,
    .mobile-more-menu .admin-review-entry::after,
    .mobile-more-menu #profile-home-btn::after,
    .mobile-more-menu #logout-btn::after {
        content: none;
    }

    .mobile-more-toggle {
        display: flex;
        cursor: pointer;
        color: var(--app-text-soft, var(--app-text, #cbd5e1)) !important;
    }

    .message-entry-badge,
    .notif-badge {
        top: 2px;
        right: calc(50% - 22px);
        min-width: 17px;
        height: 17px;
        padding: 0 4px;
        font-size: .62rem;
    }

    .mobile-more-menu {
        position: fixed;
        left: 50%;
        right: auto;
        bottom: calc(82px + env(safe-area-inset-bottom));
        z-index: 241;
        width: min(500px, calc(100vw - 28px));
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        padding: 10px;
        border: 1px solid color-mix(in srgb, var(--app-accent, #818cf8) 16%, rgba(148,163,184,.14));
        border-radius: 18px;
        background: color-mix(in srgb, var(--app-header, #081020) 97%, transparent);
        box-shadow: 0 20px 54px rgba(2,6,23,.42);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transform: translate(-50%, 8px) scale(.98);
        transform-origin: center bottom;
        transition: opacity .16s ease, transform .16s ease, visibility .16s;
        backdrop-filter: blur(24px) saturate(125%);
        -webkit-backdrop-filter: blur(24px) saturate(125%);
    }

    .mobile-more-menu.open {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: translate(-50%, 0) scale(1);
    }

    .mobile-more-menu > .logout-btn,
    .mobile-more-menu > .theme-settings-btn {
        position: static;
        inset: auto;
        width: 100%;
        min-height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        margin: 0;
        padding: 10px 12px;
        border: 1px solid color-mix(in srgb, var(--app-accent, #818cf8) 10%, rgba(148,163,184,.12));
        border-radius: 12px;
        color: var(--app-text, #f8fafc);
        background: color-mix(in srgb, var(--app-surface, #111827) 82%, transparent);
        box-shadow: none;
        font-size: .78rem;
        font-weight: 700;
        transform: none;
    }

    .mobile-more-menu > #logout-btn {
        color: #fca5a5;
    }

    .mobile-more-menu > [hidden] {
        display: none !important;
    }

    .notif-panel {
        left: 50%;
        right: auto;
        bottom: calc(84px + env(safe-area-inset-bottom));
        width: min(500px, calc(100vw - 28px));
        max-height: min(62dvh, 480px);
        transform: translate(-50%, 8px) scale(.98);
    }

    .notif-panel.open {
        transform: translate(-50%, 0) scale(1);
    }

    .theme-settings-panel,
    .connection-status {
        bottom: calc(86px + env(safe-area-inset-bottom));
    }

    body:has(input:focus, textarea:focus, select:focus) .comm-header-right {
        transform: translate(-50%, 12px);
    }
}

@media (max-width: 390px) {
    .comm-header-right {
        left: 50%;
        right: auto;
        width: calc(100vw - 12px);
        gap: 0;
        padding-inline: 5px;
        transform: translateX(-50%);
    }

    .comm-header-right > .user-badge #header-username {
        max-width: 52px;
    }

    .mobile-more-menu {
        width: calc(100vw - 20px);
    }
}

@media (max-height: 520px) and (orientation: landscape) {
    .comm-header-right {
        bottom: 4px;
        min-height: 58px;
    }

    .comm-header-right > .user-badge,
    .comm-header-right > .notif-btn,
    .comm-header-right > .message-entry-btn,
    .comm-header-right > .mobile-more-toggle {
        height: 44px;
        min-height: 44px;
    }

    .comm-header-right > .fab-post {
        width: 44px;
        height: 44px;
        transform: translateY(-6px);
    }

    .mobile-more-menu,
    .notif-panel {
        bottom: 68px;
        max-height: calc(100dvh - 78px);
    }
}
