* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: #faf7f2;
    color: #2b2b2b;
}

.landing {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem;
    text-align: center;
}

.landing h1 {
    margin-bottom: 1rem;
    font-size: 1.75rem;
}

.button {
    display: block;
    width: 260px;
    padding: 0.9rem 1.5rem;
    background: #b08968;
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    font-size: 1rem;
    text-align: center;
}

.button:active {
    opacity: 0.85;
}

.upload-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem 1rem;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    text-align: center;
}

.upload-page input[type="file"] {
    width: 100%;
}

.upload-page button {
    width: 100%;
    padding: 0.8rem;
    background: #b08968;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
}

#progress-wrap {
    width: 100%;
}

#progress-bar {
    width: 100%;
    height: 1rem;
}

#results {
    list-style: none;
    padding: 0;
    margin: 0;
    width: 100%;
    text-align: left;
}

#results li {
    padding: 0.4rem 0;
    font-size: 0.9rem;
    word-break: break-word;
}

.result-ok {
    color: #2e7d32;
}

.result-error {
    color: #c62828;
}

.button-small {
    width: auto;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.gallery-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: #faf7f2;
    position: sticky;
    top: 0;
    z-index: 5;
}

.gallery-header h1 {
    font-size: 1.2rem;
    margin: 0;
}

.gallery-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 4px;
    width: 100%;
}

.grid-item {
    position: relative;
    aspect-ratio: 1 / 1;
    padding: 0;
    border: none;
    background: #eee;
    cursor: pointer;
    overflow: hidden;
}

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

.video-badge {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}

#load-more-btn {
    padding: 0.7rem 1.5rem;
    background: #b08968;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
}

#empty-message {
    color: #666;
    text-align: center;
}

.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/*
 * Sin esta regla, el atributo HTML "hidden" que pone/quita gallery.js
 * (lightbox.hidden = true/false) no tiene ningún efecto visual: la regla
 * de baja prioridad del navegador "[hidden] { display: none }" siempre
 * pierde frente a la regla de arriba ".lightbox { display: flex }", que
 * es una regla de autor. Con esto se fuerza explícitamente que, mientras
 * el atributo esté presente, el overlay quede realmente oculto.
 */
.lightbox[hidden] {
    display: none;
}

.lightbox-content {
    max-width: 92vw;
    max-height: 88vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-content img,
.lightbox-content video {
    max-width: 92vw;
    max-height: 88vh;
    object-fit: contain;
}

.lightbox-close,
.lightbox-nav {
    position: absolute;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Mismo motivo que .lightbox[hidden]: gallery.js oculta prev/next con
   "hidden" según currentIndex (p.ej. no hay "anterior" en la primera
   foto); sin esta regla esas flechas seguirían visibles y pulsables. */
.lightbox-nav[hidden] {
    display: none;
}

.lightbox-close {
    top: 12px;
    right: 12px;
}

.lightbox-prev {
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
}

.lightbox-next {
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
}

.grid-item {
    position: relative;
    aspect-ratio: 1 / 1;
    padding: 0;
    border: none;
    background: #eee;
    overflow: hidden;
}

.grid-item-open {
    width: 100%;
    height: 100%;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    display: block;
}

.grid-item-checkbox {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 20px;
    height: 20px;
    accent-color: #b08968;
}

.selection-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: #2b2b2b;
    color: #fff;
    z-index: 8;
    flex-wrap: wrap;
}

.selection-bar button {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
}

#download-selection-btn {
    background: #b08968;
    color: #fff;
}

.clear-selection-btn {
    background: transparent;
    color: #fff;
    text-decoration: underline;
}

.lightbox-download {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.9rem;
}
