/* ===== Desktop viewport-locked layout ===== */
@media (min-width: 960px) {
    /* Kill page-level scrollbar when channels page is active */
    body:has(.channels-page-wrapper) {
        overflow: hidden !important;
    }

    .channels-page-wrapper {
        display: flex;
        flex-direction: column;
        height: calc(100dvh - 168px); /* 128px navbar + 40px footer */
        overflow: hidden;
    }

    .channels-filters {
        flex-shrink: 0;
    }

    .channels-columns-container {
        flex: 1 1 0%;
        min-height: 0;
        overflow: hidden;
        margin-top: 0 !important;
    }

        /* MudGrid uses flex-wrap — percentage height on children won't resolve.
       Use position:relative + absolute to give MudItems a real height. */
        .channels-columns-container > .mud-grid {
            position: relative;
            height: 100%;
        }

    .channels-column-item {
        display: flex !important;
        flex-direction: column;
        min-height: 0 !important;
        max-height: 100%;
        height: 100%;
        overflow: hidden;
    }

    .channels-bento-container {
        flex: 1 1 0% !important;
        display: flex !important;
        flex-direction: column !important;
        min-height: 0 !important;
        overflow: hidden;
    }

    .channels-list {
        flex: 1 1 0%;
        min-height: 0;
        overflow-y: auto;
        padding-right: 8px;
        padding-top: 6px;
        padding-left: 4px;
        scrollbar-width: thin;
        scrollbar-color: transparent transparent;
        transition: scrollbar-color 0.2s ease;
    }

        .channels-list:hover {
            scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
        }

        /* Chrome / Safari / Edge */
        .channels-list::-webkit-scrollbar {
            width: 6px;
        }

        .channels-list::-webkit-scrollbar-track {
            background: transparent;
        }

        .channels-list::-webkit-scrollbar-thumb {
            background-color: transparent;
            border-radius: 3px;
            transition: background-color 0.2s ease;
        }

        .channels-list:hover::-webkit-scrollbar-thumb {
            background-color: rgba(0, 0, 0, 0.2);
        }


    .posts-column-item {
        display: flex !important;
        flex-direction: column;
        min-height: 0 !important;
        max-height: 100%;
        height: 100%;
        overflow: hidden;
    }

    .posts-scroll-container {
        flex: 1 1 0%;
        min-height: 0;
        overflow-y: auto;
        padding-right: 8px;
        padding-top: 8px;
        scrollbar-width: thin;
        scrollbar-color: transparent transparent;
        transition: scrollbar-color 0.2s ease;
    }

        .posts-scroll-container:hover {
            scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
        }

        /* Chrome / Safari / Edge */
        .posts-scroll-container::-webkit-scrollbar {
            width: 6px;
        }

        .posts-scroll-container::-webkit-scrollbar-track {
            background: transparent;
        }

        .posts-scroll-container::-webkit-scrollbar-thumb {
            background-color: transparent;
            border-radius: 3px;
            transition: background-color 0.2s ease;
        }

        .posts-scroll-container:hover::-webkit-scrollbar-thumb {
            background-color: rgba(0, 0, 0, 0.2);
        }
}

/* ===== Mobile: normal scrolling ===== */
@media (max-width: 959.98px) {
    .channels-list {
        max-height: none;
        overflow-y: visible;
        padding-right: 8px;
    }

    .posts-scroll-container {
        overflow-y: visible;
        padding-top: 8px;
    }
}

.channels-list-community {
    overflow-x: auto;
    flex-wrap: nowrap;
    gap: 1.5rem;
}

.posts-list {
    padding-top: 0 !important;
}

.post-filter-container {
    width: 100%;
}

    .post-filter-container .tags-row {
        width: 100% !important;
        justify-content: flex-end !important;
    }

.create-post-fab {
    position: absolute !important;
    bottom: 24px !important;
    right: 24px !important;
    background-color: var(--mud-palette-secondary-blue) !important;
    z-index: 10 !important;
}

.create-post-fab-fixed {
    position: fixed !important;
    bottom: 24px !important;
    right: 24px !important;
    background-color: var(--mud-palette-secondary-blue) !important;
    z-index: 10 !important;
}

.create-channel-fab {
    position: absolute !important;
    bottom: 24px !important;
    right: 24px !important;
    background-color: var(--mud-palette-secondary-blue) !important;
    z-index: 10 !important;
}

/* Post channel badge - top right */
.post-channel-badge {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.6rem 0.25rem 0.25rem;
    border-radius: 1.5rem;
    background-color: var(--mud-palette-medium-gray-5O);
    transition: background-color 0.2s ease;
    flex-shrink: 0;
    max-width: 10rem;
}

    .post-channel-badge:hover {
        background-color: var(--mud-palette-secondary-blue-10O);
    }

.post-channel-badge-image {
    width: 1.75rem !important;
    height: 1.75rem !important;
    min-width: 1.75rem !important;
    min-height: 1.75rem !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    flex-shrink: 0;
}

.post-channel-badge-name {
    color: var(--mud-palette-dark-gray) !important;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 6rem;
    line-height: 1.2;
}

.modal-create-post.GD-modal {
    width: 60vw !important;
    max-width: 60vw !important;
}

    .modal-create-post.GD-modal.mud-dialog {
        height: auto !important;
        max-height: 100vh !important;
    }

.modal-create-post .mud-dialog-content {
    flex: 0 1 auto !important;
    overflow-y: auto !important;
}

.modal-create-post .mud-dialog-title {
    padding-bottom: 0 !important;
}

@media (max-width: 960px) {
    .modal-create-post.GD-modal {
        width: 100vw !important;
        max-width: 100vw !important;
    }

        .modal-create-post.GD-modal.mud-dialog {
            height: 100vh !important;
            height: 100dvh !important;
            max-height: 100vh !important;
            max-height: 100dvh !important;
            min-height: 100vh !important;
            min-height: 100dvh !important;
            margin: 0 !important;
            border-radius: 0 !important;
            display: flex !important;
            flex-direction: column !important;
            overflow: hidden !important;
        }

    .modal-create-post .mud-dialog-title {
        flex-shrink: 0 !important;
        position: sticky !important;
        top: 0 !important;
        z-index: 10 !important;
        background: white !important;
        padding-bottom: 0 !important;
    }

    .modal-create-post .GD-modal-header {
        padding-bottom: 0 !important;
        margin-top: calc(1rem + env(safe-area-inset-top, 0px)) !important;
    }

    .modal-create-post .mud-dialog-content {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        padding: 0 !important;
    }

    .modal-create-post .mud-dialog-actions {
        flex-shrink: 0 !important;
        z-index: 10 !important;
        background: white !important;
        border-top: 1px solid #e0e0e0;
    }

    .modal-create-post .create-post-upload-box {
        width: 100% !important;
        max-width: 100% !important;
        aspect-ratio: auto !important;
        min-height: 8rem;
    }

    .modal-create-post .create-post-container > .d-flex.flex-row.align-start {
        align-items: center !important;
    }

    .modal-create-post .create-post-container {
        gap: 0.25rem;
    }

        .modal-create-post .create-post-container .pb-3 {
            padding-bottom: 0.5rem !important;
        }

        .modal-create-post .create-post-container .mb-3 {
            margin-bottom: 0.5rem !important;
        }

        .modal-create-post .create-post-container .mb-7 {
            margin-bottom: 0.75rem !important;
        }

        .modal-create-post .create-post-container .mt-4 {
            margin-top: 0.5rem !important;
        }

    .modal-create-post #create-post-file-input + .create-post-upload-box,
    .modal-create-post .create-post-upload-box {
        min-height: 10rem;
    }

    .modal-create-post .ql-editor {
        min-height: 6rem !important;
        max-height: 12rem !important;
        overflow-y: auto !important;
    }

    .modal-create-post.GD-modal .GD-modal-body {
        max-height: none !important;
        height: 100% !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;
        padding: 0 1.5rem 0.75rem 1.5rem !important;
    }
}

.modal-create-post .post-avatar-image {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.modal-create-post .dark-gray {
    color: #222 !important;
}

.modal-create-post .light-gray {
    color: #666 !important;
}

.modal-create-post .mud-input-outlined .mud-input-slot {
    border-color: #e0e0e0;
}

.modal-create-post .mud-input-outlined:hover .mud-input-slot {
    border-color: var(--mud-palette-secondary-blue);
}

.modal-create-post .mud-input-outlined.mud-input-adorned-end .mud-input-slot {
    padding-right: 14px;
}

/* (mobile overrides consolidated above) */

.modal-create-channel.GD-modal {
    width: 50vw;
    max-width: 50vw;
    height: auto !important;
    max-height: 85vh !important;
}

.modal-create-channel .mud-dialog-content {
    height: auto !important;
    max-height: 100%;
    overflow-y: auto;
}

.modal-create-channel .GD-modal-body {
    max-height: none !important;
    overflow: visible !important;
}

.modal-create-channel .create-channel-modal-body {
    height: auto !important;
    max-height: none;
    overflow: visible;
    position: relative;
}

/* Create/Edit channel modal: Name input + public switch on the same row */
.create-channel-name-row {
    width: 100%;
}

.create-channel-name-field {
    flex: 1 1 260px;
    min-width: 200px;
}

.create-channel-switch-cell {
    flex: 0 0 auto;
    white-space: nowrap;
}

    .create-channel-switch-cell .create-channel-switch {
        margin-right: 0 !important;
    }

    .create-channel-switch-cell .mud-switch-label {
        white-space: nowrap;
    }

@media (max-width: 600px) {
    .create-channel-name-field {
        flex: 1 1 100%;
    }

    .create-channel-switch-cell {
        flex: 1 1 100%;
    }
}

/* Non-member overlay - Channel Page */
.channel-page-non-member-container {
    position: relative;
    height: calc(100vh - 280px);
    overflow: hidden;
}

    .channel-page-non-member-container .posts-content-blurred {
        filter: blur(6px);
        pointer-events: none;
        user-select: none;
        height: 100%;
        overflow: hidden;
    }

/* Non-member overlay - shared */
.posts-content-blurred {
    filter: blur(6px);
    pointer-events: none;
    user-select: none;
}

.channel-non-member-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(2px);
    z-index: 100;
    padding: 2rem;
}

.channel-non-member-content {
    text-align: center;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

    .channel-non-member-content .mud-icon-root {
        color: var(--mud-palette-secondary-blue);
    }

    .channel-non-member-content .dark-text {
        color: #1a1a1a;
        font-weight: 500;
    }

.channel-page-container {
    width: calc(100% - 3rem);
}

.channel-page-back {
    cursor: pointer;
}

    .channel-page-back:hover .mud-icon-root,
    .channel-page-back:hover .mud-typography {
        color: var(--mud-palette-primary) !important;
    }

.channel-page-header {
    position: relative;
}

.channel-page-avatar {
    width: 96px !important;
    height: 96px !important;
    min-width: 96px !important;
    min-height: 96px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
}

.channel-page-description {
    max-width: 600px;
    line-height: 1.5;
}

.channel-page-posts {
    padding-bottom: 5rem;
}

.channel-page-post-wrapper {
    padding: 0.5rem 0;
}

    .channel-page-post-wrapper:last-child {
        border-bottom: none;
    }

/* Channel page admin actions */
.channel-page-admin-actions {
    display: inline-flex;
    gap: 8px;
    vertical-align: middle;
}

    .channel-page-admin-actions button {
        transition: all 0.2s ease;
    }

        .channel-page-admin-actions button:hover {
            transform: scale(1.1);
        }

    .channel-page-admin-actions .edit-btn {
        color: var(--medium-gray) !important;
        background: transparent !important;
        box-shadow: none !important;
        transition: background 0.2s;
    }

        .channel-page-admin-actions .edit-btn:hover {
            color: var(--medium-gray) !important;
            background: var(--mud-palette-medium-gray-10O) !important;
            box-shadow: none !important;
        }

    .channel-page-admin-actions .delete-btn {
        color: var(--medium-gray) !important;
        background: transparent !important;
        box-shadow: none !important;
        transition: background 0.2s, color 0.2s;
    }

        .channel-page-admin-actions .delete-btn:hover {
            color: var(--mud-palette-danger-red) !important;
            background: var(--mud-palette-danger-red-lighter) !important;
            box-shadow: none !important;
        }

/* Post video thumbnail preview */
.post-video-thumbnail {
    position: relative;
    background-color: #000;
    border-radius: 0.75rem;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    max-height: 12rem;
    margin: 0 auto;
}

.post-video-preview {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 0.75rem;
    display: block;
    pointer-events: none;
}

.post-video-play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    pointer-events: none;
}

.post-video-play-icon {
    font-size: 3.5rem !important;
    color: rgba(255, 255, 255, 0.85) !important;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
}

@media (max-width: 959.98px) {
    .channel-page-container {
        overflow-x: hidden;
    }

    .channel-page-avatar {
        width: 64px !important;
        height: 64px !important;
        min-width: 64px !important;
        min-height: 64px !important;
    }

    .channel-page-header .initials-avatar-large {
        width: 64px !important;
        height: 64px !important;
        min-width: 64px !important;
        min-height: 64px !important;
        font-size: 1.2rem !important;
    }

    .channel-page-header .mud-typography-h5 {
        font-size: 1.25rem !important;
    }

    .channels-filters {
        position: relative;
        z-index: auto;
    }

        .channels-filters .mud-grid-item:first-child {
            padding-right: 0 !important;
        }

    .channels-search-item {
        padding-right: 0 !important;
    }

    .channels-filters-bar {
        flex-direction: column;
        align-items: flex-start;
    }


    .channels-filters-left {
        width: 100%;
    }


    .channels-filters-right {
        align-self: flex-start;
    }
}

.posts-list-inner {
    width: 100%;
    padding-left: 8px;
}

.channels-search-item {
    padding-right: 5rem;
}

.channels-filters-bar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.channels-filters-left {
    display: flex;
    align-items: flex-end;
    gap: 2rem;
    flex-wrap: wrap;
    flex: 1 1 auto;
}

.channels-filters-right {
    display: flex;
    align-items: flex-end;
    flex-shrink: 0;
}

.channel-page-tag-row .row-container {
    width: auto !important;
    position: static !important;
    z-index: auto !important;
}  

.channel-page-header-bento.mud-container-style-bento {
    padding: .75rem 1rem !important;
}

@media (max-width: 959.98px) {
    .channel-page-header-bento .initials-avatar-text {
        font-size: 0.5rem !important;
    }
}

.channels-list-names {
    text-align: -webkit-center;
}