.ps-post__background-selector {
    width: 100%;
    max-width: 300px;
    font-size: 13px;
    border-radius: var(--BORDER-RADIUS--MD);
    box-shadow: var(--BOX-SHADOW--XL);

    a {
        padding: 5px;

        &:hover {
            background-color: var(--PS-COLOR--APP--GRAY);
        }
    }

    .ps-avatar {
        --width: 32px;

        img {
            width: var(--width);
        }
    }
}

// Modifiers
.pso-modal--postbox {
    position: relative;

    .ps-postbox__url-preview {
        margin-top: var(--G2);
    }

    .pso-modal__footer {
        padding-top: 0;
        border-top: none;

        .pso-btn {
            width: 100%;
        }
    }

    // Temporary overrides, replace with new CSS in the future
    .ps-postbox__photos-list {
        padding: 0;
    }

    .ps-postbox__photos-info {
        font-size: var(--F-M);
        color: var(--c-contrast-light);
        border: 2px dashed var(--COLOR--APP--GRAY);
        border-radius: var(--BORDER-RADIUS--MD);
        transition: var(--TRANS);

        &:hover {
            color: var(--c-contrast);
            border-color: var(--COLOR--APP--DARKGRAY);
        }
    }

    .ps-postbox__media-action {
        padding: var(--PADD);
        font-size: var(--F-M);
        color: var(--c-contrast-light);
        border: 2px dashed var(--COLOR--APP--GRAY);
        border-radius: var(--BORDER-RADIUS--MD);
        transition: var(--TRANS);

        &:hover {
            color: var(--c-contrast);
            border-color: var(--COLOR--APP--DARKGRAY);
        }
    }

    .ps-media--iframe {
        border-top-left-radius: var(--BORDER-RADIUS--MD);
        border-top-right-radius: var(--BORDER-RADIUS--MD);
        overflow: hidden;
    }

    .ps-postbox__media-embed,
    .ps-media--embed {
        padding: 0;

        .ps-media__inner {
            background-color: var(--PS-COLOR--APP--LIGHTGRAY);
            border: none;
            border-top-left-radius: 0;
            border-top-right-radius: 0;
        }
    }

    .ps-postbox__poll-options {
        padding: 0;
    }

    .ps-postbox__poll-actions {
        padding-inline: 0;
        padding-bottom: 0;
        border: none;
    }

    .ps-postbox__file-add {
        padding: var(--PADD);
        font-size: var(--F-M);
        color: var(--c-contrast-light);
        background: none;
        border: 2px dashed var(--COLOR--APP--GRAY);
        border-radius: var(--BORDER-RADIUS--MD);
        transition: var(--TRANS);

        &:hover {
            color: var(--c-contrast);
            border-color: var(--COLOR--APP--DARKGRAY);
        }
    }

    .ps-postbox__file-items {
        padding-top: 0;
        padding-inline: 0;
        border: none;
    }

    .ps-postbox__file-add {
        border-radius: var(--R);
    }

    .ps-postbox__file-previews {
        border: none;
    }

    .ps-postbox__files-info {
        padding: var(--PADD);
        font-size: var(--F-M);
        color: var(--c-contrast-light);
        border: 2px dashed var(--COLOR--APP--GRAY);
        border-radius: var(--BORDER-RADIUS--MD);
        transition: var(--TRANS);

        &:hover {
            color: var(--c-contrast);
            border-color: var(--COLOR--APP--DARKGRAY);
        }
    }

    .ps-giphy__search {
        border: 1px solid var(--DIVIDER--LIGHT);
    }

    .ps-post__background,
    .ps-postbox__backgrounds {
        border-radius: var(--BORDER-RADIUS--MD);
    }

    .ps-post__background-text {
        span {
            color: var(--PS-COLOR--PRIMARY--DARK);
        }
    }

    .pso-postbox-inputs__view {
        margin-bottom: var(--G3);
    }

    .ps-tagging-dropdown-item {
        .ps-avatar {
            --width: 32px;

            img {
                width: var(--width);
            }
        }
    }

    .ps-postbox__input-beautifier .ps-tag {
        box-shadow: 0 0 0 1px var(--bg);
    }
    //

    .pso-modal__footer {
        @include mq($until: desktop) {
            flex-direction: column;
            align-items: stretch;
            justify-content: unset;
        }
    }
}

// Postbox component
.pso-postbox {
    --bg: var(--c-base);
    --radius: var(--BORDER-RADIUS--XL);
    --shadow: var(--BOX-SHADOW--HARD);

    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--G3);
    margin-bottom: var(--G3);
    padding: var(--G4);
    background-color: var(--bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);

    @include mq($from: desktop) {
        gap: var(--G4);
        margin-bottom: var(--G4);
        padding: var(--G4);
    }
}

.pso-postbox__filter {
    background-color: var(--c-base);
    //backdrop-filter: blur(8px);
    border-radius: var(--R);
    animation: backdrop-entry .1s linear;
}

@keyframes backdrop-entry {
    0% {
        opacity: 0;
    }

    100% {
        opacity: 1;
    }
}

.pso-postbox__head {
    display: flex;
    align-items: center;
    gap: var(--G2);
}

.pso-postbox-head__avatar {}

.pso-postbox-head__title {
    display: flex;
    align-items: center;
    flex-grow: 1;
    height: 40px;
    padding: var(--G2);
    font-size: 14px;
    color: var(--c-contrast-slight);
    background-color: transparent;
    border-radius: var(--R-S);
    cursor: pointer;

    @include mq($from: desktop) {
        background-color: transparent;
        transition: var(--TRANS);

        &:hover {
            color: var(--c-contrast-light);
            background-color: var(--PS-COLOR--APP--GRAY);
        }
    }
}

.pso-postbox-head__privacy {}

.pso-postbox-head__actions {
    .pso-btn {
        --w: 40px;
    }
}

.pso-postbox__inputs {}

.pso-postbox-inputs__wrapper {}

.pso-postbox-inputs__view {
    margin-bottom: var(--G4);
}

.pso-postbox-input__wrapper {
    position: relative;
}

.pso-postbox__input {
    position: relative;
    max-height: 300px;
    overflow: auto;

    * {
        line-height: 1.4;
        font-size: var(--c-ps-post-font-size);
    }

    textarea,
    textarea:hover,
    textarea:focus,
    .pso-postbox-input__shadow {
        height: auto;
        width: 100% !important;
        border: 0;
        margin: 0;
        padding: 0;
        font-size: var(--c-ps-post-font-size);
        font-weight: 400;
        line-height: 1.4;
        color: inherit;
        border-radius: 0;
        background: none;
        box-shadow: none;
        outline: none;
        resize: none;
    }

    .pso-postbox-input__shadow {
        color: transparent;
    }
}

.pso-postbox-input__shadow {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    pointer-events: none;
    color: transparent;

    & + textarea {
        background: none;
    }
}

.pso-postbox__options {}

.pso-postbox-options__list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--G3);
    row-gap: var(--G1);

    @include mq($from: desktop) {
        gap: var(--G4);
    }
}

.pso-postbox-options__item {
    @extend %btn-reset;

    --g: var(--G1);
    --h: 30px;
    --p: var(--G1) 0;
    --fs: var(--F-XS);
    --is: var(--F-M);
    --c: var(--c-contrast-slight);
    --ic: var(--c-contrast-slight);
    --bg: transparent;
    --hv-c: var(--c-contrast-light);
    --hv-ic: var(--c-contrast-light);
    --hv-bg: transparent;
    --ac-c: var(--c-contrast);
    --ac-ic: var(--c-contrast);
    --ac-bg: transparent;
    --ds-c: var(--c-contrast-elight);
    --ds-ic: var(--c-contrast-elight);
    --ds-bg: transparent;
}

.pso-postbox__option--active,
.pso-postbox-options__item--active {
    &:before {
        content: " ";
        position: absolute;
        left: 0;
        bottom: var(--G1);
        width: 6px;
        height: 6px;
        background-color: var(--c-primary);
        border-radius: 50%;
        box-shadow: 0 0 0 2px var(--c-base);
    }
}

.pso-postbox-options__tabs {}

.pso-postbox-options__tab {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
}

.pso-postbox__types {
    display: flex;
    flex-wrap: wrap;
    gap: var(--G2);

    @include mq($from: desktop) {
        display: flex;
        flex-wrap: nowrap;

        &:has(> *:nth-child(3)) > * {
            flex-grow: 1;
        }
    }

    &:empty {
        display: none;
    }
}

.pso-postbox__types--wrap {
    flex-wrap: wrap;

    .pso-postbox__type {
        flex-grow: unset !important;
    }
}

.pso-postbox__types--show {
    span {
        display: block;
    }

    .pso-postbox__modal & {
        .pso-postbox__type {
            &:after {
                content: attr(aria-label);
            }
        }

        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: var(--G2);

        @include mq($from: desktop) {
            display: flex;
            flex-wrap: wrap;

            .pso-postbox__type {
                flex-grow: unset;
            }
        }
    }
}

.pso-postbox__types--hide {
    span {
        display: none;
    }

    .pso-postbox__modal & {
        @include mq($from: desktop) {
            display: flex;
            flex-wrap: nowrap;
        }
    }
}

.pso-postbox__types--mobile {
    span {
        @include mq($from: desktop) {
            display: none;
        }
    }

    .pso-postbox__modal & {
        .pso-postbox__type {
            &:after {
                content: attr(aria-label);
            }
        }

        @include mq($until: desktop) {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: var(--G2);
        }

        @include mq($from: desktop) {
            &:after {
                content: unset;
            }
        }
    }
}

.pso-postbox__types--desktop {
    span {
        display: none;

        @include mq($from: desktop) {
            display: block;
        }
    }

    .pso-postbox__modal & {
        @include mq($from: desktop) {
            flex-wrap: wrap;

            .pso-postbox__type {
                flex-grow: unset;

                &:after {
                    content: attr(aria-label);
                }
            }
        }
    }
}

.pso-postbox__type {
    @extend %btn-reset;

    --h: 35px;
    --p: var(--G2) var(--G2);
    --g: var(--G1);
    --fs: 12px;
    --is: calc(var(--fs) + 4px);
    --ic: var(--c-primary);
    --hv-c: var(--c-contrast-light);
    --hv-ic: var(--c-primary);
    --hv-bg: var(--c-primary-ulight);
    --ac-c: var(--c-contrast-light);
    --ac-ic: var(--c-primary);
    --ac-bg: var(--c-primary-elight);

    @include mq($from: desktop) {
        --h: 40px;
        --p: var(--G2) var(--G3);
        --fs: 14px;

        //flex-grow: 1;
    }
}

.pso-postbox__type--more {
    --ic: var(--c-contrast-light);
    --fs: 10px;

    max-width: 40px;
}

.pso-postbox__modal {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--G3);

    .pso-postbox-head__title {
        align-items: start;
        justify-content: center;
        flex-direction: column;
        gap: 3px;
        padding: 0;
        font-weight: 500;
        color: var(--c-contrast);
        cursor: default;
        transition: none;

        @include mq($from: desktop) {
            &:hover {
                background-color: transparent;
            }
        }
    }

    .pso-postbox__type {
        --ic: var(--c-contrast-slight);

        &.pso-active {
            --ac-bg: var(--c-primary-ulight);
        }

        @include mq($until: desktop) {
            justify-content: start;
        }
    }

    @include mq($from: desktop) {
        gap: var(--G4);
    }
}

.pso-postbox__post-to {
    > span {
        max-width: 200px;
        white-space: nowrap;
        line-height: 1.2;
        text-overflow: ellipsis;
        overflow: hidden;
    }
}

.pso-postbox-post-to__dropdown {
    bottom: 100%;

    @include mq($from: desktop) {
        top: 100%;
        bottom: auto;
    }
}

.pso-postbox__loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    width: 40px;
    height: 40px;
    line-height: 40px;
    border-radius: var(--R) !important;
    background-color: var(--c-base);
    box-shadow: var(--BOX-SHADOW--MD);

    img {
        vertical-align: middle;
    }
}
