/**
 * Community page — mobile & tablet only (max-width: 1023px).
 * Desktop/laptop (1024px+) is unchanged.
 */
@media (max-width: 1023px) {
    :root {
        --nle-community-header: 90px;
        --nle-community-bottom-nav: 64px;
    }

    body.nle-community-active {
        overflow-x: hidden;
    }

    .nle-community-page {
        padding-top: var(--nle-community-header) !important;
        padding-bottom: calc(var(--nle-community-bottom-nav) + env(safe-area-inset-bottom, 0px) + 8px) !important;
        overflow-x: hidden;
        width: 100%;
        max-width: 100vw;
    }

    .nle-community-page .nle-community-container {
        padding-left: 10px !important;
        padding-right: 10px !important;
        padding-top: 10px !important;
        padding-bottom: 6px !important;
        max-width: 100%;
    }

    .nle-community-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
        width: 100%;
        max-width: 100%;
    }

    /* Feed first — sidebar drawer is fixed, not in flow */
    .nle-community-feed {
        order: 1;
        min-width: 0;
        width: 100%;
        max-width: 100%;
    }

    #main-feed-content {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    /* Hide right widgets on mobile — keeps feed clean; use Menu drawer for nav */
    .nle-community-sidebar-right {
        display: none !important;
    }

    /* Left sidebar → off-canvas drawer */
    .nle-community-sidebar-left {
        position: fixed;
        top: var(--nle-community-header);
        left: 0;
        bottom: calc(var(--nle-community-bottom-nav) + env(safe-area-inset-bottom, 0px));
        width: min(320px, 92vw);
        z-index: 85;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 14px;
        background: #F6F6F1;
        transform: translateX(-110%);
        transition: transform 0.28s ease;
        box-shadow: none;
        visibility: hidden;
        pointer-events: none;
    }

    .nle-community-sidebar-left.is-open {
        transform: translateX(0);
        visibility: visible;
        pointer-events: auto;
        box-shadow: 4px 0 28px rgba(0, 0, 0, 0.18);
    }

    .nle-community-sidebar-left > .sticky {
        position: static !important;
        top: auto !important;
    }

    .nle-community-sidebar-overlay {
        display: none;
        position: fixed;
        top: var(--nle-community-header);
        left: 0;
        right: 0;
        bottom: calc(var(--nle-community-bottom-nav) + env(safe-area-inset-bottom, 0px));
        background: rgba(0, 0, 0, 0.5);
        z-index: 80;
    }

    .nle-community-sidebar-overlay.is-open {
        display: block;
    }

    /* Search + cards */
    .nle-community-feed > .bg-white.rounded-2xl {
        padding: 12px !important;
        border-radius: 14px !important;
    }

    #community-search {
        font-size: 14px !important;
        padding: 10px 12px !important;
    }

    #post-creation-area {
        padding: 14px !important;
        border-radius: 14px !important;
    }

    #post-creation-area > .flex.gap-3.mb-4 {
        flex-direction: column;
        align-items: stretch;
        gap: 10px !important;
    }

    #post-creation-area > .flex.gap-3.mb-4 > img {
        width: 40px !important;
        height: 40px !important;
    }

    #post-content {
        min-height: 72px !important;
        font-size: 14px !important;
        padding: 12px !important;
        width: 100%;
        box-sizing: border-box;
    }

    #composer-toolbar {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
        gap: 6px !important;
        scrollbar-width: none;
        max-width: 100%;
    }

    #composer-toolbar::-webkit-scrollbar {
        display: none;
    }

    #composer-toolbar button {
        flex-shrink: 0;
        white-space: nowrap;
        font-size: 11px !important;
        padding: 7px 10px !important;
    }

    #submit-post {
        width: 100%;
        text-align: center;
        padding: 12px !important;
    }

    /* Post cards */
    .community-post-card {
        border-radius: 14px !important;
        transform: none !important;
        max-width: 100%;
        overflow: hidden;
    }

    .community-post-card:hover {
        transform: none !important;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1) !important;
    }

    .community-post-card > div.p-6,
    .community-post-card > div[class*="px-6"] {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .community-post-card > div.p-6.pb-4 {
        padding-top: 12px !important;
        padding-bottom: 8px !important;
    }

    .community-post-card .flex.items-center.justify-between.mb-4 {
        flex-wrap: wrap;
        gap: 8px;
    }

    .community-post-card .flex.items-center.gap-5.text-sm {
        gap: 8px !important;
        font-size: 11px !important;
        flex-wrap: wrap;
    }

    .community-post-card .flex.items-center.gap-1.border-b {
        display: grid !important;
        grid-template-columns: 1fr 1fr 1fr auto;
        gap: 4px !important;
        padding-bottom: 10px !important;
    }

    .community-post-card .like-btn,
    .community-post-card .comment-btn,
    .community-post-card .share-btn {
        flex: none !important;
        min-width: 0;
        padding: 8px 4px !important;
        font-size: 11px !important;
        gap: 3px !important;
        justify-content: center;
    }

    .community-post-card .like-btn .like-text {
        display: none;
    }

    .community-post-card .comment-btn,
    .community-post-card .share-btn {
        font-size: 0 !important;
    }

    .community-post-card .comment-btn svg,
    .community-post-card .share-btn svg,
    .community-post-card .like-btn svg {
        width: 20px !important;
        height: 20px !important;
    }

    .community-post-card .save-btn {
        padding: 8px !important;
        justify-self: end;
    }

    .community-post-card .post-media-image,
    .community-post-card .post-media video {
        max-width: 100% !important;
        border-radius: 0 !important;
        transform: none !important;
    }

    .community-post-card .post-media-image:hover {
        transform: none !important;
    }

    .community-post-card img:not(.post-media-image):not(.rounded-full),
    .community-post-card video:not(.post-media video) {
        max-width: 100% !important;
    }

    .community-post-card .comment-composer {
        flex-direction: column;
        align-items: stretch !important;
        gap: 8px !important;
    }

    .community-post-card .comment-composer > .flex-1.flex {
        flex-direction: column;
        align-items: stretch !important;
        gap: 8px !important;
    }

    .community-post-card .comment-input {
        width: 100% !important;
        box-sizing: border-box;
    }

    .community-post-card .comment-submit-btn {
        width: 100%;
        padding: 10px !important;
    }

    .community-post-card .reply-composer {
        flex-direction: column;
        align-items: stretch !important;
    }

    .community-post-card .reply-composer > .flex-1.flex {
        flex-direction: column;
        align-items: stretch !important;
        gap: 8px !important;
    }

    .community-post-card .reply-submit-btn,
    .community-post-card .reply-cancel-btn {
        width: 100%;
    }

    /* Section filters */
    #activities-section .flex.flex-wrap.gap-2,
    #events-section .flex.gap-2 {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
        scrollbar-width: none;
        max-width: 100%;
    }

    #activities-section .flex.flex-wrap.gap-2::-webkit-scrollbar {
        display: none;
    }

    #activities-section .activity-filter-btn {
        flex-shrink: 0;
    }

    /* Chat fullscreen */
    #chat-window:not(.hidden) {
        position: fixed !important;
        top: var(--nle-community-header) !important;
        left: 0 !important;
        right: 0 !important;
        bottom: calc(var(--nle-community-bottom-nav) + env(safe-area-inset-bottom, 0px)) !important;
        width: 100% !important;
        max-width: 100vw !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        margin: 0 !important;
        border-radius: 0 !important;
        z-index: 95 !important;
    }

    #chat-window .messenger-messages {
        min-height: 0 !important;
    }

    /* Notifications sheet */
    #notifications-panel.nle-mobile-notifications-sheet {
        position: fixed !important;
        top: var(--nle-community-header) !important;
        left: 0 !important;
        right: 0 !important;
        bottom: calc(var(--nle-community-bottom-nav) + env(safe-area-inset-bottom, 0px)) !important;
        z-index: 90 !important;
        max-height: none !important;
        border-radius: 0 !important;
        margin: 0 !important;
        display: flex !important;
        flex-direction: column;
    }

    #notifications-panel.nle-mobile-notifications-sheet #notifications-list {
        max-height: none !important;
        flex: 1;
        overflow-y: auto;
    }

    /* Modals */
    #tag-user-modal,
    #new-chat-modal,
    #emoji-picker-modal {
        padding: 12px !important;
        align-items: flex-end !important;
    }

    #tag-user-modal .bg-white,
    #new-chat-modal .bg-white,
    #emoji-picker-modal #emoji-modal-content {
        max-height: 88vh;
        overflow-y: auto;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 16px 16px 0 0 !important;
        margin-bottom: 0 !important;
    }

    /* Bottom nav */
    .nle-community-mobile-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 100;
        display: flex !important;
        align-items: stretch;
        justify-content: space-around;
        gap: 0;
        padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px));
        background: #fff;
        border-top: 1px solid #e5e7eb;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
    }

    .nle-mobile-nav-btn {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        min-height: 54px;
        padding: 4px 2px;
        border: 0;
        background: transparent;
        color: rgb(74, 56, 54);
        font-family: 'Inter', sans-serif;
        font-size: 10px;
        font-weight: 600;
        border-radius: 10px;
        cursor: pointer;
        position: relative;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    .nle-mobile-nav-btn svg {
        width: 22px;
        height: 22px;
        flex-shrink: 0;
    }

    .nle-mobile-nav-btn.is-active {
        color: #909A78;
        background: #F6F6F1;
    }

    .nle-mobile-nav-badge {
        position: absolute;
        top: 2px;
        right: calc(50% - 26px);
        min-width: 16px;
        height: 16px;
        padding: 0 4px;
        border-radius: 999px;
        background: #ef4444;
        color: #fff;
        font-size: 9px;
        font-weight: 700;
        display: flex;
        align-items: center;
        justify-content: center;
        line-height: 1;
    }

    .nle-mobile-nav-badge.hidden {
        display: none !important;
    }
}

@media (min-width: 1024px) {
    .nle-community-mobile-nav,
    .nle-community-sidebar-overlay {
        display: none !important;
    }

    .nle-community-sidebar-left {
        position: relative !important;
        transform: none !important;
        width: auto !important;
        top: auto !important;
        bottom: auto !important;
        left: auto !important;
        padding: 0 !important;
        overflow: visible !important;
        box-shadow: none !important;
        background: transparent !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }

    .nle-community-sidebar-right {
        display: block !important;
    }
}

/* Post images/GIFs: no hover zoom, square corners (all viewports) */
.community-post-card .post-media-image {
    border-radius: 0 !important;
    transform: none !important;
    transition: none !important;
}

.community-post-card .post-media-image:hover {
    transform: none !important;
}
