@media screen and (max-width: 519px) {
    #grid-container {
        display: flex;
        gap: 10px;
        flex-direction: column;
    }
    #rank-indicator {
        display: flex; flex-direction: column;
        gap: 0;

        div {
            height: 20%;
            display: flex; flex-direction: column;
            justify-content: center;
            text-align: center;
        }
        .ri-elem-start {
            clip-path: polygon(0 0, 100% 0, 100% 90%, 50% 100%, 0 90%);
        }

        .ri-elem {
            clip-path: polygon(0 0, 50% 10%, 100% 0, 100% 90%, 50% 100%, 0 90%);
        }
        .off {
            opacity: 0.3;
        }
    }
}
@media screen and (min-width: 520px) {
    #grid-container {
        display: grid;
        gap: 10px;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto 1fr;
    }
    #main-profile {
        grid-column-start: 1;
        grid-column-end: 3;
    }
}
@media screen and (min-width: 820px) {
}

.ts-button-panel {
    width: 100%; height: 100%;
}
#top-banner-large-in {
    margin-bottom: 0;
}

#main-profile > div {
    width: 100%;
    border: 1px solid #dadada;
}
#main-profile {

    #background-image-wrapper:has(#background-image) {
        background-color: #000000;
    }
    #background-image-wrapper {
        position: relative;
        aspect-ratio: 32 / 9;
        border-radius: 20px 20px 0 0;
        border-bottom: none;

        #background-image {
            opacity: 0.7;
            width: 100%; height: 100%;
            border-radius: 20px 20px 0 0;
            object-fit: cover;
        }
        #no-background-image {
            width: 100%; height: 100%;
            border-radius: 20px 20px 0 0;
            background-color: #999;
        }
        #background-image-over {
            position: absolute;
            top: 0; left: 0;
            height: 100%; width: 100%;
            color: #fff;

            #avatar {
                bottom: 10px; left: 10px;
                width: 40px;

                img {
                    border: 2px solid #fff;
                }
            }
            #lab-id {
                bottom: 8px; left: 67px;
                font-size: 10px;
                letter-spacing: 1px;
                filter: drop-shadow(2px 2px 2px rgba(0, 0, 0, 0.3));
            }
            #owner-name {
                position: absolute;
                font-weight: normal;
                bottom: 30px; left: 65px;
                font-size: 20px;
                letter-spacing: 1px;
                line-height: 18px;
                filter: drop-shadow(2px 2px 2px rgba(0, 0, 0, 0.3));
            }
            #rank_icon {
                bottom: 10px; left: 35px;
                width: 22px; height: 22px;
                font-size: 10px;
            }
        }
        #background-image-over > div {
            position: absolute;
        }
    }

    #profile {
        height: fit-content;
        border-radius: 0 0 20px 20px;
        border-top: none;
        padding: 20px;
        display: flex;
        flex-direction: column;
        gap: 10px;

        #social-container {
            display: flex;
            justify-content: space-between;
            
            .following .unfollowing-t { display: none }
            .unfollowing .following-t { display: none }
        }
        #lab-tag-container {
            width: 100%; gap: 0 10px;
            display: flex;
            flex-wrap: wrap;

            .lab-tag-wrapper {
                display: block;
                color: #666666;
                font-size: 12px;
            }
        }
        #sns-container {
            flex-wrap: wrap;
            margin-top: 4px;
            display: flex;
            gap: 0 15px;
            font-size: small;
            
            a {
                color: #666666;
            }
            a:hover {
                color: #d93;
            }
        }
    }
}

#counter-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;

    #badges-container {
        display: flex;

        .badges-container {
            display: flex;
            justify-content: center; gap: 10px;
        }
        .no-badge {
            color: gray;
            font-size: small;
            text-align: center;
        }
        .badges-container:has(.user-badge-22) + .no-badge {
            display: none !important;
        }
        .badges-container:not(:has(.user-badge-22)) {
            display: none;
        }
        .badge-label {
            font-size: small;
            color: #888;
        }
    }

    .counter-wrapper {
        display: flex; flex-direction: column;
        justify-content: center;
        gap: 10px;
        min-height: 60px;
        
        .large-counter {
            font-size: 18px;
            line-height: 22px;
            width: 100%;
            text-align: center;
            color: #888;
        }
        .counter-label {
            line-height: 0.8em;
            font-size: 0.8em;
            width: 100%;
            text-align: center;
            color: #888;
        }

        .like { color: #D5309E; }
        .post { color: #497DE4; }
        .followed { color: #3db370; }
    }
    
}
#counter-container > div {
    border-radius: 20px;
    width: 100%; height: 100%;
}
#counter-container > div:not(#trl-route-map) {
    background-color: #f5f5f5;
}

/* TRL */
#trl-route-map {
    grid-row: 1 / 3;
    grid-column: 1 / 3;
    object-fit: contain;
}



#contents-container {
    display: grid;
    margin-top: 15px;
    grid-auto-flow: dense;

    .card-v2 a {
        display: block;
        text-decoration: none;
        color: #222;
        height: 100%;
        -webkit-user-drag: none;
        -khtml-user-drag: none;
    }

    .card-v2 {
        width: 100%;
        cursor: pointer;
        -webkit-user-drag:none;
        -khtml-user-drag:none;
        border-radius: 6px;
        position: relative;
        transition: all 0.15s;

        .card-desc {
            width: 100%;
            aspect-ratio: 16 / 9;
            padding: 10px;
            border-radius: 6px;
            color: white;
            overflow: hidden;
            font-size: small;
            line-height: 1.3em;
            word-break: break-all;
        }
        .card-thumb {
            width: 100%;
            aspect-ratio: 16 / 9;
            object-fit: cover;
            border-radius: 6px;
        }
        .card-title {
            width: 100%; height: fit-content;
            /* min-height: 40px; */
            max-height: 80px;
            margin-bottom: 6px;
            
            font-size: small; font-weight: bold;

            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 3;
            overflow: hidden;
        }


        .card-meta-container-up {
            display: flex;
            gap: 5px;

            .cat-indicator, .edt-indicator, .file-indicator {
                border-radius: 14px;
                font-size: small;
                padding: 2px 10px;
                height: 28px;
                transition: all 0.15s;
            }
        }
        .card-meta-container-md {
            display: flex;
            justify-content: space-between;
            margin: 7px 0;
            font-size: small;

            .counter-container {
                display: flex;
                gap: 10px;
                .counter {
                    display: flex;
                    gap: 5px;
                }
                .file-counter {
                    .icon {
                        font-size: 2.2em;
                        position: absolute;
                        width: 60px; height: 60px;
                        right: -10px; top: -5px;
                        display: flex;
                        justify-content: center;

                        div {
                            margin: auto 0;
                        }
                    }
                    .count {
                        color: white;
                        position: absolute;
                        width: 60px; height: 60px;
                        right: -10px; top: -5px;
                        display: flex;
                        justify-content: center;
                        margin: auto 0;

                        div {
                            margin-top: 22px;
                        }
                    }
                }
            }
            

            .card-date {
                text-align: right;
            }
        }
        .card-meta-container-dw {
            display: grid;
            grid-template-rows: 25px;
            grid-template-columns: auto 25px 1fr;
            gap: 5px;

            .rank_badge_bg {
                grid-row: 1 / 2;
                grid-column: 1 / 2;
                width: 25px; height: 25px;

                .rank_badge_text {
                    font-size: small;
                }
            }
            .card-avatar {
                grid-row: 1 / 2;
                grid-column: 2 / 3;
                border-radius: 50%;
            }
            .card-lab-name {
                line-height: 20px;
                grid-row: 1 / 2;
                grid-column: 3 / 4;
                font-size: small;
            }
        }
    }
    .card-v2.thumb {
        flex: 0 0 auto; /* ← shrinkさせない & 幅固定 */
    }

    /* ピン表示 */
    .card-v2.pinned {
        grid-row: 1 / 2;
        grid-column: 1 / 2;

        .card-title::before {
            font-family: "Font Awesome 6 Free";
            font-weight: 900;
            text-decoration: none;
            font-style: normal;
            content: "\f08d ";
            margin-right: 5px;
        }
    } 
}
.file-indicator { display: block; }
.file-counter { display: none; }
@media screen and ((max-width: 460px) or ((min-width: 630px) and (max-width: 689px)) or ((min-width: 910px) and (max-width: 1029px))) {
    .file-indicator { display: none; }
    .file-counter { display: block; }
}

.bookmarked-icon {
    position: absolute;

    top: 10px; right: 20px;
    font-size: 1.5em;
    color: rgb(73, 125, 228);
}
.title-bookmarked-icon {
    color: rgb(73, 125, 228);
}
#contents-container:has(.card-v2) + #empty-message { display: none; }
#empty-message {
    display: flex;
    flex-direction: column;
    margin: 30px 0 20px 0;

    div {
        width: 100%;
        text-align: center;

        i {
            color: #ddd;
            font-size: 4em;
            margin-bottom: 15px;
        }
        .large {
            font-size: large;
        }
    }
}

@media screen and (max-width: 629px) {
    #contents-container {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    #gallery-container {
        margin: 10px 0;
    }
}
@media screen and (min-width: 630px) and (max-width: 834px) {
    #contents-container {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 20px;
    }
}
@media screen and (min-width: 835px) and (max-width: 909px) {
    #contents-container {
        grid-template-columns: 1fr 1fr;
        gap: 20px;
    }
}
@media screen and (min-width: 910px) {
    #contents-container {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 20px;
    }
}

body:not(.--CLIENT-USE-TOUCH, .--CLIENT-USE-PEN) .card-v2:hover {
    transform: scale(0.97);
}


/* TRL */
.trl-users {
    flex-wrap: wrap;

    
}
.trl-users:has(> *:nth-child(4)):not(.open) {
    > *:not(:is(:nth-child(1), :nth-child(2), :nth-child(3), :last-child)) {
        display: none;
    }
}
.trl-user-container-top {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}
.trl-users:has(> *:nth-child(4)).open > *:last-child {
    display: none;
}
.user-icon-panel-title {
    line-height: 36px;
    font-size: small;
    margin: 0 4px;
    color: gray;
}
.user-icon-panel-a {
    text-decoration: none;
    color: #2d2d2d;

    .user-icon-panel {
        transition: all 0.15s;
    }
}
body:not(.--CLIENT-USE-TOUCH, .--CLIENT-USE-PEN) .user-icon-panel-a:hover {
    color: #2d2d2d;

    .user-icon-panel {
        background-color: #ccc;
    }
}
.user-icon-panel {
    height: 36px;
    width: fit-content;
    padding: 4px;
    border-radius: 18px;
    background-color: #f5f5f5;
    display: flex;
    gap: 6px;

    .user-icon-panel-text {
        line-height: 28px;
        font-size: small;
        margin: 0 4px;
    }
    .trl-user-icon{ width: 28px; }
    img {
        display: block;
        height: 28px;
    }
}
.lab-trl-logo {
    filter: drop-shadow(2px 2px 2px rgba(0, 0, 0, 0.3));
    height: 30px;
    top: 10px; right: 20px;

    img {height: 100%; }
}