:root {
    --bg: #17212b;          /* Тёмный фон в стиле Telegram */
    --card-bg: #232e3c;
    --text: #ffffff;
    --accent: #5288c1;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    overflow: hidden; /* Убираем скролл body, скролл будет в галерее */
}

.screen {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    display: none;
    background-color: var(--bg);
}

.screen.active { display: flex; }

/* --- Экран с сеткой --- */
#home-screen {
    flex-direction: column;
    overflow-y: auto;
    padding: 12px;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 колонки */
    gap: 10px;
    width: 100%;
}

.gallery-item {
    background-color: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    cursor: pointer;
    transition: transform 0.1s ease;
}

.gallery-item:active {
    transform: scale(0.97);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Заполняет ячейку, обрезая края */
    display: block;
}

/* --- Экран плеера --- */
#player-screen {
    background-color: #000;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

#player-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 32px;
    color: white;
    background: rgba(0,0,0,0.5);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 101;
}

.gallery-item {
    position: relative;
}

.folder-label {
    position: absolute;
    bottom: 6px;
    right: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    background: rgba(0, 0, 0, 0.55);
    padding: 2px 7px;
    border-radius: 8px;
    pointer-events: none;
}

/* номер папки на превью */
.gallery-item { position: relative; }
.folder-label {
    position: absolute;
    bottom: 6px;
    right: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    background: rgba(0, 0, 0, 0.55);
    padding: 2px 7px;
    border-radius: 8px;
    pointer-events: none;
}

/* лёгкая пульсация, пока кадры грузятся */
#player-image.loading {
    opacity: 0.3;
    animation: pulse 1s ease-in-out infinite alternate;
}
@keyframes pulse {
    from { opacity: 0.2; }
    to   { opacity: 0.5; }
}