* {
    box-sizing: border-box;
}

body {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: #222;
}

#image-main-wrapper {
    position: fixed;
    left: 0;
    top: 0;
    width: calc(100% - max(14%, 140px));
    height: 100%;
    transition: width 200ms ease-in-out;
}

#main-image-wrapper {
    position: absolute;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 3;
}

#main-image {
    object-fit: contain;
}

#main-bg-wrapper {
    position: absolute;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    z-index: 2;
}

#main-image-bg {
    object-fit: cover;
    filter: blur(8px);
}

#image-preview-wrapper {
    position: fixed;
    right: 0;
    top: 0;
    width: 14%;
    min-width: 140px;
    height: 100%;
    overflow: auto;
    transition: transform 200ms ease-in-out;
}

#image-main-wrapper img {
    width: 100%;
    height: 100%;
}

.preview-image-wrapper {
    width: 100%;
    padding: 0;
    overflow: hidden;
    border: 1px solid #000;
    aspect-ratio: 16/9;
    min-height: 120px;
}

.preview-image {
    width: 100%;
    height: 100%;
    background-color: #222;
    background-size: cover;
    background-position: center;
    cursor: pointer;
    object-fit: cover;
    color: white;
}

.preview-image.selected {
    border: 1px solid #fff;
}

#loadscreen {
    position: fixed;
    left: 0;
    top: 0;
    width: 86%;
    height: 100%;
    z-index: 5;
    background-color: #222;
}

#loadscreen-content {
    color: white;
    position: relative;
    display: inline-block;
    left: min(30px, 10%);
    top: min(30px, 10%);
    z-index: 6;
}

#mobile-preview-toggle {
    display: none;
}

#desktop-preview-toggle {
    display: block;
    position: fixed;
    width: 40px;
    height: 48px;
    background-color: rgba(255, 255, 255, 0.4);
    z-index: 7;
    border-radius: 8px 0px 0px 8px;
    right: max(14%, 140px);
    top: 50%;
    transform: translateY(-50%);
    transition: right 200ms ease-in-out;
}

#desktop-preview-toggle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#desktop-preview-toggle:hover {
    background-color: rgba(255, 255, 255, 0.6);
}

body.previewhidden #image-preview-wrapper {
    transform: translateX(100%);
}

body.previewhidden #image-main-wrapper {
    width: 100%;
}

body.previewhidden #desktop-preview-toggle {
    right: 0;
}

#desktop-preview-collapse {
    transition: transform 200ms ease-in-out;
}

#desktop-preview-collapse.rotatetoggle {
    transform: rotate(180deg);
}

.nodisplay {
    display: none;
}

.novisible {
    visibility: hidden;
}

@media (orientation: portrait) {
    #image-main-wrapper {
        position: fixed;
        left: 0;
        top: 0;
        width: 100%;
        height: calc(100% - max(120px, 14%));
        transition: height 200ms ease-in-out;
    }

    #image-preview-wrapper {
        position: fixed;
        left: 0;
        top: 100%;
        transform: translateY(-100%);
        width: 100%;
        height: 14%;
        min-height: 120px;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        transition: transform 200ms ease-in-out;
    }

    #loadscreen {
        position: fixed;
        left: 0;
        top: 0;
        width: 100%;
        height: 86%;
        z-index: 5;
    }

    .preview-image-wrapper {
        width: auto;
        aspect-ratio: 3/2;
        display: inline-block;
        padding: 0;
        overflow: hidden;
        border: 1px solid #000;
        height: 100%;
    }

    #mobile-preview-toggle {
        display: block;
        position: fixed;
        width: 48px;
        height: 40px;
        background-color: rgba(255, 255, 255, 0.4);
        z-index: 7;
        border-radius: 8px 8px 0px 0px;
        left: 50%;
        bottom: max(120px, 14%);
        transform: translateX(-50%);
        transition: bottom 200ms ease-in-out;
    }

    #desktop-preview-toggle {
        display: none;
    }

    #mobile-preview-collapse {
        transition: transform 200ms ease-in-out;
    }
    
    #mobile-preview-collapse.rotatetoggle {
        transform: rotate(180deg);
    }

    body.previewhidden #image-preview-wrapper{
        transform: translateY(0%);
    }
    
    body.previewhidden #image-main-wrapper {
        height: 100%;
    }
    
    body.previewhidden #mobile-preview-toggle {
        bottom: 0;
    }
}