.gallery-container {
    display: flex;
    flex: 1;
    position: relative;
    height: 100%;
    width: 100%;
    overflow: hidden;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-large);
    background-color: var(--color-bg-primary);
    touch-action: pan-y; /* Allow vertical scroll, block horizontal for swipe */
}

/* Simulated fullscreen toggle logic overriding parent properties */
.gallery-fullscreen-mode {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100dvh !important;
    z-index: 9999;
    border-radius: 0;
}

.gallery-track {
    display: flex;
    width: 100%;
    height: 100%;
    /* Hardware acceleration for smooth sliding in Safari/Gecko */
    will-change: transform;
    transform: translateZ(0);
    transition: transform var(--transition-speed) ease-in-out;
}

.gallery-slide {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    /* Prevents content flashing */
    backface-visibility: hidden;
}

.gallery-image {
    height: 100%;
    width: 100%;
    display: block;
    object-fit: contain;
    /* Prevent dragging the image element itself */
    pointer-events: none;
    user-select: none;
}

/* Password Screen */
.gallery-password-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 0.3s ease;
    gap: 1.5rem;
}

.gallery-password-screen h1 {
    margin: 0;
    color: var(--color-icon);
    font-size: 1.5rem;
    font-weight: 600;
}

.gallery-password-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--color-btn-hover);
    backdrop-filter: blur(8px);
    padding: 2rem 3rem;
    border-radius: 12px;
    box-shadow: var(--shadow-large);
}

.gallery-pwd-input-wrap {
    display: flex;
    position: relative;
    align-items: center;
}

.gallery-pwd-input-wrap input {
    width: 100%;
    padding: 0.75rem 3rem 0.75rem 1rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: box-shadow 0.2s ease;
    background: #fff;
    color: var(--color-icon);
}

.gallery-pwd-input-wrap input:focus {
    box-shadow: 0 0 0 3px var(--color-primary-muted);
}

.gallery-pwd-error {
    color: var(--color-error);
    font-size: 0.9rem;
    text-align: center;
    min-height: 1.2rem;
    font-weight: 500;
}

.gallery-pwd-toggle {
    position: absolute;
    right: 0.5rem;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--color-icon);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
}

.gallery-pwd-toggle svg {
    width: 1.25rem;
    height: 1.25rem;
    stroke: var(--color-icon);
}

.gallery-password-form button[type="submit"] {
    background-color: var(--color-dot);
    color: var(--color-icon);
    font-weight: 600;
    border: none;
    padding: 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    box-shadow: var(--shadow-base);
}

.gallery-password-form button[type="submit"]:hover {
    background-color: var(--color-dot-active);
}

/* Nav & Tools Buttons */
.gallery-nav-btn,
.gallery-fullscreen-btn,
.gallery-download-btn {
    display: grid;
    place-items: center;
    position: absolute;
    background-color: var(--color-btn-bg);
    border: none;
    border-radius: 9999px;
    padding: 0.75rem;
    cursor: pointer;
    box-shadow: var(--shadow-base);
    transition:
        background-color 0.2s ease,
        opacity 0.3s ease;
    z-index: 10;
}

.gallery-nav-btn:hover,
.gallery-fullscreen-btn:hover,
.gallery-download-btn:hover {
    background-color: var(--color-btn-hover);
}

.gallery-nav-btn svg,
.gallery-fullscreen-btn svg,
.gallery-download-btn svg {
    width: 2rem;
    height: 2rem;
    stroke: var(--color-icon);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.gallery-arrows-hidden svg {
    stroke: var(--color-primary-muted);
}

/* Arrow specifics */
.gallery-nav-btn {
    top: 50%;
    transform: translateY(-50%);
}

.gallery-prev {
    left: 1rem;
}

.gallery-next {
    right: 1rem;
}

.gallery-arrows-hidden .gallery-prev,
.gallery-arrows-hidden .gallery-next {
    opacity: 0;
    pointer-events: none;
}

/* Tools Top Right specifics */
.gallery-fullscreen-btn {
    top: 1rem;
    right: 1rem;
    padding: 0.5rem;
}

.gallery-download-btn {
    top: 1rem;
    right: 4rem; /* offset to sit next to fullscreen */
    padding: 0.5rem;
}

.gallery-fullscreen-btn svg,
.gallery-download-btn svg {
    width: 1.5rem;
    height: 1.5rem;
}

/* Indicator Dots Legend */
.gallery-dots {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    width: 30%; /* Match static width of info bar */
    min-width: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    z-index: 10;
    background: var(--color-btn-bg);
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    backdrop-filter: blur(4px);
    box-shadow: var(--shadow-base);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.gallery-dot {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 9999px;
    background-color: var(--color-dot);
    border: none;
    padding: 0;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: grid;
    place-items: center;
    font-size: 0.8rem;
}

.gallery-dot.active {
    background-color: var(--color-dot-active);
}

.gallery-dot-text {
    color: var(--color-icon);
    font-weight: bold;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 1rem;
    user-select: none;
}

.gallery-dot-ellipsis {
    color: var(--color-icon);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    letter-spacing: 1px;
    user-select: none;
}

/* Utils */
.gallery-loader-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-primary);
    z-index: 20;
    text-align: center;
}

.gallery-loader-container > div {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    position: relative;
    padding-bottom: 3rem; /* space for compliment */
}

.gallery-progress-title {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--color-icon);
    margin-bottom: 1rem;
}

.gallery-progress-bar {
    width: var(--loader-bar-width, 300px);
    max-width: 75%;
    height: 8px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 9999px;
    overflow: hidden;
    margin-bottom: 0; /* removed margin since compliment is absolute */
}

.gallery-progress-fill {
    height: 100%;
    width: 0%;
    background-color: var(--color-primary);
    transition: width 0.2s ease-out;
}

.gallery-compliment {
    font-size: 1rem;
    color: var(--color-icon);
    opacity: 1;
    transition: opacity 0.5s ease-in-out;
    font-style: italic;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    text-align: center;
    overflow: visible;
}

/*.gallery-compliment small {
    font-size: 0.8rem;
    color: var(--color-dot);
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: -1rem;
    opacity: 0.75;
}*/

/* Info Banner */
.gallery-info {
    position: absolute;
    bottom: 4rem; /* clear dots */
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    min-width: 250px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    background: var(--color-btn-bg); /* match dots */
    padding: 0.5rem 1.5rem;
    border-radius: 9999px;
    backdrop-filter: blur(4px);
    box-shadow: var(--shadow-base);
    z-index: 10;
    pointer-events: none; /* so swipe isn't blocked by text */
    white-space: nowrap;
    opacity: 1; /* full visibility */
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.gallery-arrows-hidden .gallery-info,
.gallery-arrows-hidden .gallery-dots,
.gallery-arrows-hidden .gallery-fullscreen-btn,
.gallery-arrows-hidden .gallery-download-btn {
    box-shadow: none; /* removed shadow for subtle look */
    opacity: 0.7; /* muted overall */
}

.gallery-arrows-hidden .gallery-info {
    bottom: 2.65rem; /* Lower it slightly */
    padding: 0.35rem 0.5rem;
    max-width: 25%;
}

.gallery-arrows-hidden .gallery-dots {
    padding: 0.35rem 0.5rem;
    bottom: 0.25rem;
    gap: 0.25rem;
    max-width: 25%;
}

.gallery-info-item {
    display: flex;
    align-items: center;
    overflow: hidden;
    flex: 1;
    justify-content: flex-start;
    justify-items: center;
    max-width: 30%;
    position: relative;
    padding-left: 1.5rem; /* Space for absolute SVG */
    transition:
        max-width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        padding 0.4s ease;
}

.gallery-arrows-hidden .gallery-info-item {
    max-width: 1rem; /* Shrink to just the icon width */
    padding-left: 1rem; /* Compress the space */
    flex: 0 0 auto;
}

.gallery-info svg {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 1rem;
    height: 1rem;
    stroke: var(--color-icon);
    flex-shrink: 0;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.gallery-info h6 {
    margin: 0;
    color: var(--color-icon);
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 1;
    max-width: 200px;
    transition:
        opacity 0.3s ease,
        max-width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.gallery-arrows-hidden .gallery-info h6 {
    opacity: 0;
    max-width: 0;
}

/* Modal Checkbox */
.gallery-modal {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-modal.visible {
    opacity: 1;
}

.gallery-modal-content {
    background: var(--color-modal-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    width: 90%;
    height: 90%; /* Static 90% */
    border-radius: 12px;
    box-shadow: var(--shadow-large);
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Hide modal overflow entirely */
    transition:
        transform 0.5s cubic-bezier(0.36, 0, 0.2, 1),
        opacity 0.4s cubic-bezier(0.4, 0, 1, 1),
        border-radius 0.5s ease;
    transform-origin: center;
}

.gallery-modal-count {
    text-align: center;
    font-size: 0.9rem;
    color: var(--color-icon);
    padding: 0.5rem;
    opacity: 0.8;
    font-weight: 500;
}

.gallery-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    position: relative;
}

.gallery-modal-header::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 5%;
    width: 90%;
    height: 1px;
    background: rgba(0, 0, 0, 0.1);
}

.gallery-modal-header h3 {
    margin: 0;
    color: var(--color-icon);
    font-size: 1.25rem;
}

.gallery-modal-header button {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
}

.gallery-modal-header svg {
    width: 1.5rem;
    height: 1.5rem;
    stroke: var(--color-icon);
}

.gallery-modal-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.gallery-modal-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem;
    border-radius: 8px;
    transition: background-color 0.2s ease;
}

.gallery-modal-item:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.gallery-modal-item input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--color-primary-muted);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    background: transparent;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.gallery-modal-item input[type="checkbox"]:checked {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.gallery-modal-item input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    top: 1px;
    left: 5px;
    width: 4px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.gallery-modal-item button {
    flex: 1;
    background: transparent;
    border: none;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    color: var(--color-icon);
    font-size: 1rem;
    padding: 0;
    overflow: hidden;
}

.gallery-modal-tag {
    background: var(--color-btn-bg);
    color: var(--color-icon);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: bold;
    margin: 0 0.5rem;
}

.gallery-modal-item button span.date-span {
    font-size: 0.8rem;
    opacity: 0.7;
    margin-left: auto;
}

.gallery-modal-footer {
    padding: 1rem 1.5rem;
    position: relative;
    display: flex;
    justify-content: space-evenly;
    align-items: center;
}

.gallery-modal-footer::before {
    content: "";
    position: absolute;
    top: 0;
    left: 5%;
    width: 90%;
    height: 1px;
    background: rgba(0, 0, 0, 0.1);
}

.gallery-select-all-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-icon);
    font-weight: 600;
    cursor: pointer;
}

.gallery-select-all-wrap input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--color-primary-muted);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    background: transparent;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.gallery-select-all-wrap input[type="checkbox"]:checked {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.gallery-select-all-wrap input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    top: 1px;
    left: 5px;
    width: 4px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.gallery-modal-footer button {
    background-color: var(--color-btn-bg);
    color: var(--color-icon);
    font-weight: 600;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.gallery-modal-footer button:hover {
    background-color: var(--color-btn-hover);
}

.gallery-error {
    color: var(--color-error);
    width: 100%;
    text-align: center;
    padding: 1rem;
    font-weight: bold;
}
