* { box-sizing: border-box; }

html { background: #111; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: Arial, Helvetica, sans-serif;
    background: #111;
    color: #f5f5f5;
}

button, input, textarea { font: inherit; }

.gallery-app {
    width: min(1500px, 100%);
    margin: 0 auto;
    padding: 20px;
}

.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}

.gallery-header h1 {
    margin: 0 0 5px;
    font-size: clamp(1.8rem, 4vw, 2.8rem);
}

.gallery-header p {
    margin: 0;
    color: #aaa;
}

.header-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.control-button {
    border: 1px solid #555;
    background: #242424;
    color: #fff;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
}

.control-button:hover {
    background: #333;
}

.logout-link {
    display: inline-flex;
    align-items: center;
}

.viewer { width: 100%; }

.image-stage {
    position: relative;
    width: 100%;
    height: min(70vh, 820px);
    min-height: 350px;
    overflow: hidden;
    border-radius: 12px;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-layer {
    position: absolute;
    inset: 0;
}

.main-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    user-select: none;
    opacity: 0;
    transition: opacity 0.8s ease-in-out;
}

.main-image.active-image { opacity: 1; }

.nav-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 56px;
    height: 72px;
    border: 0;
    background: rgba(0, 0, 0, 0.45);
    color: white;
    font-size: 36px;
    cursor: pointer;
}

.nav-prev { left: 0; border-radius: 0 8px 8px 0; }
.nav-next { right: 0; border-radius: 8px 0 0 8px; }

.stage-fullscreen-button {
    position: absolute;
    z-index: 10;
    top: 15px;
    right: 15px;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 24px;
    cursor: pointer;
}

.counter {
    position: absolute;
    z-index: 10;
    right: 15px;
    bottom: 15px;
    padding: 7px 11px;
    background: rgba(0, 0, 0, 0.65);
    border-radius: 7px;
    font-size: 14px;
}

.image-info {
    padding: 12px 4px 20px;
    text-align: center;
    color: #ddd;
}

.thumbnail-section { margin-top: 10px; }

.thumbnail-section h2 {
    margin: 0 0 14px;
    font-size: 1.2rem;
}

.thumbnail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.thumbnail {
    border: 2px solid transparent;
    background: #1d1d1d;
    padding: 5px;
    border-radius: 8px;
    cursor: pointer;
    color: #ccc;
    overflow: hidden;
}

.thumbnail.active { border-color: #fff; }

.thumbnail img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 5px;
}

.thumbnail span {
    display: block;
    margin-top: 6px;
    padding: 0 3px 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13px;
}

.empty-state {
    padding: 50px 20px;
    text-align: center;
    border: 1px solid #333;
    border-radius: 12px;
    background: #1a1a1a;
}

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-box {
    width: min(520px, 100%);
    background: #1b1b1b;
    border: 1px solid #333;
    border-radius: 14px;
    padding: 28px;
}

.login-box h1 {
    margin-top: 0;
}

.login-box p {
    color: #bbb;
}

.login-box label {
    display: block;
    margin-bottom: 8px;
}

.login-box input,
.hash-output textarea {
    width: 100%;
    padding: 12px 14px;
    margin-bottom: 16px;
    border: 1px solid #555;
    border-radius: 8px;
    background: #111;
    color: #fff;
}

.login-button {
    width: 100%;
}

.login-error {
    margin-bottom: 16px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #3a1717;
    color: #ffd8d8;
}

.hash-output {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid #333;
}

.hash-output textarea {
    resize: vertical;
}

.warning-text {
    color: #f0c674 !important;
}

.viewer:fullscreen {
    background: #000;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.viewer:fullscreen .image-stage {
    width: 100vw;
    height: 100vh;
    min-height: 100vh;
    border-radius: 0;
}

.viewer:fullscreen .image-info,
.viewer:fullscreen .thumbnail-section {
    display: none;
}

@media (max-width: 700px) {
    .gallery-app { padding: 10px; }

    .gallery-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .image-stage {
        height: 55vh;
        min-height: 260px;
    }

    .thumbnail-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 8px;
    }
}
