* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #1a1a1a;
    color: #fff;
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

.view {
    min-height: 100vh;
}

/* Login */
#login-view {
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-box {
    background: #2a2a2a;
    padding: 3rem;
    border-radius: 12px;
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.login-box h1 {
    margin-bottom: 2rem;
    font-weight: 300;
}

#login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#login-form input {
    padding: 0.875rem 1rem;
    border: 1px solid #444;
    border-radius: 6px;
    background: #333;
    color: #fff;
    font-size: 1rem;
}

#login-form input:focus {
    outline: none;
    border-color: #666;
}

#login-form button {
    padding: 0.875rem;
    border: none;
    border-radius: 6px;
    background: #4a9eff;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

#login-form button:hover {
    background: #3a8eef;
}

.error {
    color: #ff6b6b;
    margin-top: 1rem;
}

/* Gallery */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: #222;
    border-bottom: 1px solid #333;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 200px;
}

.header-right {
    justify-content: flex-end;
}

.badge {
    background: #f59e0b;
    color: #000;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.filters {
    display: flex;
    gap: 0.5rem;
}

.filter-btn {
    padding: 0.5rem 1rem;
    border: 1px solid #444;
    border-radius: 6px;
    background: transparent;
    color: #aaa;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn:hover {
    border-color: #666;
    color: #fff;
}

.filter-btn.active {
    background: #4a9eff;
    border-color: #4a9eff;
    color: #fff;
}

#logout-btn {
    padding: 0.5rem 1rem;
    border: 1px solid #444;
    border-radius: 6px;
    background: transparent;
    color: #aaa;
    cursor: pointer;
}

#logout-btn:hover {
    border-color: #666;
    color: #fff;
}

.danger-btn {
    background: #dc2626 !important;
    border-color: #dc2626 !important;
    color: #fff !important;
}

.danger-btn:hover {
    background: #b91c1c !important;
    border-color: #b91c1c !important;
}

/* Confirm Dialog */
.dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.dialog-box {
    background: #2a2a2a;
    padding: 2rem;
    border-radius: 12px;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.dialog-box p {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

.dialog-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.dialog-btn {
    padding: 0.75rem 1.5rem;
    border: 1px solid #444;
    border-radius: 6px;
    background: #333;
    color: #fff;
    cursor: pointer;
    font-size: 1rem;
}

.dialog-btn:hover {
    background: #444;
}

#photo-counter {
    color: #888;
    font-size: 0.875rem;
}

/* Gallery Container */
.gallery-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: calc(100vh - 65px);
    padding: 2rem;
    gap: 2rem;
}

.nav-btn {
    width: 60px;
    height: 60px;
    border: 1px solid #444;
    border-radius: 50%;
    background: #2a2a2a;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.nav-btn:hover {
    background: #3a3a3a;
    border-color: #666;
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.photo-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    max-width: calc(100% - 160px);
    max-height: 100%;
}

#photo-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

#current-photo {
    max-width: 100%;
    max-height: calc(100vh - 220px);
    object-fit: contain;
    border-radius: 8px;
}

.photo-name {
    color: #888;
    font-size: 0.875rem;
}

.vote-buttons {
    display: flex;
    gap: 1.5rem;
}

.vote-btn {
    width: 56px;
    height: 56px;
    border: 2px solid #444;
    border-radius: 50%;
    background: #2a2a2a;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.vote-btn:hover {
    transform: scale(1.1);
}

#vote-up.active {
    background: #22c55e;
    border-color: #22c55e;
}

#vote-down.active {
    background: #ef4444;
    border-color: #ef4444;
}

/* Admin Overlay */
#admin-overlay {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.85);
    padding: 1rem;
    border-radius: 8px;
    min-width: 140px;
}

.score-display {
    text-align: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #444;
}

#score-value {
    font-size: 2rem;
    font-weight: 600;
}

.score-label {
    display: block;
    font-size: 0.75rem;
    color: #888;
    text-transform: uppercase;
}

#vote-breakdown {
    font-size: 0.8rem;
    max-height: 150px;
    overflow-y: auto;
}

#vote-breakdown .vote-entry {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
}

#vote-breakdown .vote-entry .vote-icon {
    width: 20px;
}

/* Thumbnail Grid */
#thumbnail-view {
    padding: 1.5rem;
    height: calc(100vh - 65px);
    overflow-y: auto;
}

#thumbnail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    max-width: 1400px;
    margin: 0 auto;
}

.thumbnail {
    position: relative;
    aspect-ratio: 1;
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
    background: #2a2a2a;
}

.thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s;
}

.thumbnail:hover img {
    transform: scale(1.05);
}

.thumbnail .thumb-vote {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    font-size: 1.25rem;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.thumbnail .thumb-score {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.75);
    padding: 0.375rem;
    font-size: 0.75rem;
    text-align: center;
}

.thumb-score .positive { color: #22c55e; }
.thumb-score .negative { color: #ef4444; }

/* No photos */
#no-photos {
    text-align: center;
    padding: 4rem;
    color: #888;
}

/* Responsive */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.75rem;
    }

    .header-left, .header-right {
        min-width: auto;
    }

    .header-center {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .filters {
        flex-wrap: nowrap;
        justify-content: center;
    }

    .filter-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
        white-space: nowrap;
    }

    .gallery-container {
        padding: 0.5rem;
        gap: 0.5rem;
        height: calc(100vh - 120px);
    }

    .nav-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
        flex-shrink: 0;
    }

    .photo-area {
        max-width: calc(100% - 100px);
        flex: 1;
    }

    #photo-wrapper {
        width: 100%;
        touch-action: pan-y pinch-zoom;
    }

    #current-photo {
        max-height: calc(100vh - 260px);
        width: 100%;
    }

    .photo-name {
        font-size: 0.75rem;
    }

    .vote-buttons {
        gap: 2.5rem;
        padding: 0.5rem 0;
    }

    .vote-btn {
        width: 64px;
        height: 64px;
        font-size: 1.75rem;
    }

    #admin-overlay {
        top: 0.5rem;
        right: 0.5rem;
        padding: 0.75rem;
        font-size: 0.875rem;
    }

    #score-value {
        font-size: 1.5rem;
    }

    #vote-breakdown {
        max-height: 100px;
    }

}

@media (max-width: 768px) {
    #thumbnail-view {
        padding: 0.75rem;
    }

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

    .thumbnail .thumb-vote {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .login-box {
        padding: 2rem 1.5rem;
    }

    .login-box h1 {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }

    header {
        padding: 0.5rem;
        gap: 0.5rem;
    }

    #user-greeting {
        font-size: 0.875rem;
    }

    #logout-btn {
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }

    .gallery-container {
        height: calc(100vh - 100px);
    }

    #current-photo {
        max-height: calc(100vh - 240px);
    }
}
