.explorer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 0.7rem;
}

.explorer-grid.is-filtering {
    opacity: 0.65;
}

.explorer-card {
    position: relative;
    display: flex;
    flex-direction: column;
    border: 1px solid #d9e0e6;
    border-radius: 0.75rem;
    background: #ffffff;
    text-decoration: none;
    color: inherit;
    min-height: 0;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.explorer-file {
    aspect-ratio: 4 / 3;
}

.explorer-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
}

.explorer-open {
    border: 0;
    background: transparent;
    padding: 0;
    text-align: left;
    color: inherit;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
}

.explorer-check {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 5;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #d9e0e6;
    border-radius: 0.35rem;
    padding: 0.2rem 0.35rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.explorer-check .form-check-input {
    margin: 0;
    cursor: pointer;
}

.explorer-thumb {
    height: auto;
    flex: 1 1 auto;
    border-bottom: 1px solid #e8edf1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f6f8fa;
    overflow: hidden;
}

.explorer-file .explorer-thumb {
    position: relative;
    border-bottom: 0;
}

.folder-svg,
.folder-svg svg {
    width: 100%;
    height: 100%;
}

.folder-default,
.file-default {
    font-size: 2.4rem;
    color: #6b7a88;
}

.explorer-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.explorer-title-overlay {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 0.45rem 0.55rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.2;
    word-break: break-word;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.75) 72%);
}

.explorer-download-corner {
    position: absolute;
    top: 0.45rem;
    right: 0.45rem;
    z-index: 7;
    width: 1.35rem;
    height: 1.35rem;
    padding: 0;
    font-size: 0.66rem;
    line-height: 1;
    border-radius: 0.45rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: rgba(0, 0, 0, 0.38);
    border: 1px solid rgba(255, 255, 255, 0.7);
}

.explorer-download-corner:hover,
.explorer-download-corner:focus {
    color: #fff;
    background: rgba(0, 0, 0, 0.52);
    border-color: rgba(255, 255, 255, 0.9);
}

.explorer-title {
    padding: 0.65rem 0.65rem 0.25rem;
    font-size: 0.85rem;
    font-weight: 600;
    word-break: break-word;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.explorer-meta {
    padding: 0 0.65rem 0.65rem;
    margin-top: 0;
    font-size: 0.78rem;
    color: #6c757d;
}

.explorer-actions {
    padding: 0.35rem 0.5rem 0.5rem;
}

.lang-flag {
    font-size: 1.22rem;
    line-height: 1;
}

.lang-flag-circle {
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(0, 0, 0, 0.14);
    background: #fff;
}

.lang-flag-current {
    border-width: 2px;
    border-color: #0d6efd;
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.16);
}

.lang-link-active .lang-flag-circle {
    border-width: 1px;
    border-color: rgba(255, 255, 255, 0.55);
    background: rgba(255, 255, 255, 0.08);
}

.floating-download-actions {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1050;
    display: flex;
    flex-direction: row;
    gap: 0.55rem;
    align-items: center;
}

.floating-download-actions .btn {
    min-width: 190px;
    text-align: center;
}

.image-viewer {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.92);
    display: none;
    align-items: center;
    justify-content: center;
}

.image-viewer.is-open {
    display: flex;
}

.image-viewer img {
    max-width: min(92vw, 1800px);
    max-height: 90vh;
    object-fit: contain;
}

.image-viewer-nav,
.image-viewer-close {
    position: absolute;
    border: 0;
    color: #fff;
    background: rgba(0, 0, 0, 0.45);
}

.image-viewer-nav {
    top: 50%;
    transform: translateY(-50%);
    width: 56px;
    height: 80px;
    font-size: 2.1rem;
}

.image-viewer-prev {
    left: 0.5rem;
    border-radius: 0 8px 8px 0;
}

.image-viewer-next {
    right: 0.5rem;
    border-radius: 8px 0 0 8px;
}

.image-viewer-close {
    top: 0.8rem;
    right: 0.8rem;
    width: 40px;
    height: 40px;
    border-radius: 999px;
}

body.viewer-open {
    overflow: hidden;
}

.code-path {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.9rem;
    word-break: break-all;
}

@media (max-width: 767px) {
    .explorer-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .floating-download-actions {
        left: 0.75rem;
        right: 0.75rem;
        bottom: 0.75rem;
        flex-direction: column;
        align-items: stretch;
    }

    .floating-download-actions .btn {
        min-width: 0;
        width: 100%;
    }

    .navbar .container {
        flex-wrap: nowrap;
        gap: 0.35rem;
    }

    .navbar .navbar-brand {
        margin-right: 0.25rem;
        white-space: nowrap;
        font-size: 1.15rem;
    }

    .navbar .navbar-collapse {
        display: flex;
        flex-basis: auto;
        flex-grow: 1;
        align-items: center;
        justify-content: flex-start;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
    }

    .navbar .navbar-nav {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
    }

    .navbar .navbar-nav .nav-link {
        padding: 0.2rem 0.35rem;
    }
}

@media (max-width: 480px) {
    .explorer-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
