[hidden] {
    display: none !important;
}

@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 100 1000;
    font-display: swap;
    src: url('/fonts/RobotoFlex-VariableFont.woff2') format('woff2');
}


:root {
    /* M3 Expressive Light Theme */
    --md-sys-color-primary: #3858e9;
    --md-sys-color-on-primary: #ffffff;
    --md-sys-color-primary-container: #dde1ff;
    --md-sys-color-on-primary-container: #001454;
    
    --md-sys-color-background: #faf8ff;
    --md-sys-color-on-background: #191b22;
    
    --md-sys-color-surface: #faf8ff;
    --md-sys-color-on-surface: #191b22;
    --md-sys-color-on-surface-variant: #444653;
    
    --md-sys-color-surface-container: #f1eff8;
    --md-sys-color-surface-container-high: #e5e3ec;
    
    --md-sys-color-outline: #767680;
    --md-sys-color-outline-variant: #c6c5d0;
    
    --md-sys-color-error: #ba1a1a;
    --md-sys-color-error-container: #ffdad6;
    --md-sys-color-on-error-container: #410002;
    
    --md-sys-shape-corner-extra-small: 4px;
    --md-sys-shape-corner-small: 8px;
    --md-sys-shape-corner-large: 16px;
    --md-sys-shape-corner-extra-large: 24px;
    --md-sys-shape-corner-full: 9999px;
    
    --md-sys-motion-easing-standard: cubic-bezier(0.2, 0, 0, 1);
    --md-sys-motion-duration-medium: 300ms;
    
    --target-h: 220px;
    --target-h-px: 220;
    --grid-w: 1200;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Roboto', system-ui, sans-serif;
}

body {
    background: var(--md-sys-color-background);
    color: var(--md-sys-color-on-background);
    min-height: 100vh;
}

/* --- Gallery Layout --- */
.gallery-body {
    padding: 0;
}

.gallery-container {
    padding: 2rem;
}

/* M3 Center-Aligned Top App Bar (Sticky) */
.md-top-app-bar {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 2rem;
    z-index: 900;
    transition: background-color 0.2s, box-shadow 0.2s;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

/* M3 Sticky App Bar Elevation shadow on scroll */
.md-top-app-bar.scrolled {
    background: var(--md-sys-color-surface-container);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.md-top-app-bar__title {
    font-size: 1.375rem; /* M3 Title Large (22sp) */
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
    text-align: center;
}

.md-top-app-bar__actions {
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* M3 Tonal Icon Button for Logout */
.md-header-logout-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--md-sys-shape-corner-full);
    border: none;
    background: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface-variant);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s var(--md-sys-motion-easing-standard), 
                color 0.2s var(--md-sys-motion-easing-standard),
                transform 0.2s var(--md-sys-motion-easing-standard);
}

.md-header-logout-icon-btn svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.md-header-logout-icon-btn:hover {
    background: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
    transform: scale(1.08);
}

.md-header-logout-icon-btn:active {
    transform: scale(0.95);
}

/* Decorative Scroll-Driven Progress Hairline on Sticky Top App Bar */
.scroll-progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    background: var(--md-sys-color-primary);
    transform-origin: 0 50%;
    transform: scaleX(0);
    pointer-events: none;
    opacity: 0;
}

@media (prefers-reduced-motion: no-preference) {
    @supports (animation-timeline: scroll()) {
        @keyframes gallery-scroll-progress {
            from { transform: scaleX(0); }
            to { transform: scaleX(1); }
        }

        .scroll-progress {
            opacity: 1;
            animation: gallery-scroll-progress auto linear;
            animation-timeline: scroll(root block);
        }
    }
}

/* Year Sections & Spatial-Time Geometric Slabs */
.year-section {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.year-delimiter {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
    margin: 1rem 0 0.5rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

/* Hydrated slabs dissolve seamlessly into .year-gallery so rows never break between slabs */
.slab.hydrated {
    display: contents;
}

/* Pure CSS geometric height for unhydrated slabs (exact scrollbar & random-access teleportation) */
.slab:not(.hydrated) {
    flex: 0 0 100%;
    width: 100%;
    min-height: calc(max(1, var(--ratio-sum, 10) * var(--target-h-px, 220) / var(--grid-w, 1200) + 0.5) * (var(--target-h) + 0.25rem));
    border-radius: var(--md-sys-shape-corner-small);
    background: repeating-linear-gradient(
        to bottom,
        var(--md-sys-color-surface-container) 0,
        var(--md-sys-color-surface-container) var(--target-h),
        transparent var(--target-h),
        transparent calc(var(--target-h) + 0.25rem)
    );
    opacity: 0.45;
}

.slab.loading:not(.hydrated) {
    animation: slab-pulse 1.2s ease-in-out infinite alternate;
}

@keyframes slab-pulse {
    from { opacity: 0.35; }
    to { opacity: 0.72; }
}

@media (prefers-reduced-motion: reduce) {
    .slab.loading:not(.hydrated) {
        animation: none;
        opacity: 0.55;
    }
}

/* Zero-API Time Warp Scrubber Rail */
.timeline-scrubber {
    position: fixed;
    top: 84px;
    right: 6px;
    bottom: 96px;
    width: 44px;
    z-index: 800;
    display: flex;
    justify-content: flex-end;
    align-items: stretch;
    touch-action: none;
    user-select: none;
}

.timeline-track {
    position: relative;
    width: 36px;
    height: 100%;
    cursor: ns-resize;
}

.timeline-track::before {
    content: "";
    position: absolute;
    top: 6px;
    bottom: 6px;
    right: 6px;
    width: 2px;
    border-radius: 2px;
    background: var(--md-sys-color-outline-variant);
    opacity: 0.55;
    transition: opacity 0.2s, background-color 0.2s;
}

.timeline-scrubber:hover .timeline-track::before {
    opacity: 1;
}

.timeline-tick {
    position: absolute;
    right: 0;
    transform: translateY(-50%);
    background: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface-variant);
    border: none;
    border-radius: 9999px;
    padding: 2px 6px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    opacity: 0.72;
    transition: opacity 0.15s, background-color 0.15s, color 0.15s, transform 0.15s;
}

.timeline-tick:hover,
.timeline-tick.active {
    opacity: 1;
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

.timeline-pill {
    position: absolute;
    right: 48px;
    transform: translateY(-50%);
    background: var(--md-sys-color-inverse-surface, #313033);
    color: var(--md-sys-color-inverse-on-surface, #f4eff4);
    padding: 6px 12px;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
}

.timeline-pill.visible {
    opacity: 1;
}

@media (max-width: 768px) {
    .timeline-scrubber {
        display: none;
    }
}

/* Justified gallery layout — automatic responsive rows at equal height */
.gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    width: 100%;
}

/* Spacer at the end of the flat flex list to prevent the last row from stretching */
.gallery-spacer {
    flex: 9999 1 0px;
    height: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    pointer-events: none;
}

/* M3 Elevated Card — fills its flex slot completely */
.card {
    background: var(--md-sys-color-surface-container);
    border-radius: var(--md-sys-shape-corner-extra-small);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: transform var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard), 
                box-shadow var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    min-width: 0;
    height: var(--target-h);
    /* flex is set via inline style per-card */
}

/* State Layer Overlay */
.card::after {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--md-sys-color-on-surface);
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.card:hover::after,
.card.menu-open::after {
    opacity: 0.08;
}

.card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4rem;
    background: linear-gradient(rgba(0, 0, 0, 0.65), transparent);
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.card:hover::before,
.card.menu-open::before {
    opacity: 1;
}

.card:active::after {
    opacity: 0.12;
}

.card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: var(--md-sys-shape-corner-extra-small);
}

.card video,
.card-hover-video,
.card-fallback-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: var(--md-sys-shape-corner-extra-small);
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}

/* Premium Google Photos Play Icon Overlay */
.card-video-play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.9;
    transition: opacity 0.25s var(--md-sys-motion-easing-standard), 
                transform 0.25s var(--md-sys-motion-easing-standard),
                background-color 0.25s var(--md-sys-motion-easing-standard);
    z-index: 2;
    pointer-events: none;
}

.card-video-play-overlay svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
    margin-left: 2px; /* Visual centering adjustment for triangle */
}

/* Fade out the play overlay when the looping video plays on hover */
.card:hover .card-video-play-overlay {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.85);
}

/* Filename gradient overlay — appears on hover */
.card p {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0;
    padding: 0.5rem 0.75rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.65));
    color: #ffffff;
    font-size: 0.8rem;
    font-weight: 500;
    word-break: break-all;
    text-align: left;
    opacity: 0;
    transition: opacity 0.2s;
}

.card:hover p,
.card.menu-open p {
    opacity: 1;
}

/* Native Modal Dialogs & Lightbox */
dialog:modal {
    overscroll-behavior: contain;
}

dialog::backdrop {
    overflow: hidden;
    overscroll-behavior: contain;
    background-color: rgba(17, 19, 24, 0.55);
}

.md-dialog {
    margin: auto;
    border: none;
    background: var(--md-sys-color-surface-container);
    color: var(--md-sys-color-on-surface);
    padding: 24px;
    border-radius: 28px;
    width: min(400px, calc(100vw - 32px));
    max-height: 90vh;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.md-dialog--narrow {
    width: min(350px, calc(100vw - 32px));
}

.md-dialog--wide {
    width: min(900px, calc(100vw - 32px));
}

.md-dialog--wide[open] {
    display: flex;
    flex-direction: column;
}

.md-dialog__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.md-dialog__title {
    margin: 0 0 16px 0;
    color: var(--md-sys-color-on-surface);
    font-size: 1.375rem;
    font-weight: 500;
}

.md-dialog__header .md-dialog__title {
    margin-bottom: 0;
}

.md-dialog__subtitle {
    margin: 4px 0 0 0;
    font-size: 0.875rem;
    color: var(--md-sys-color-on-surface-variant);
}

.md-dialog__close {
    background: transparent;
    border: none;
    color: var(--md-sys-color-on-surface-variant);
    padding: 8px;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.md-dialog__close:hover {
    background: var(--md-sys-color-surface-container-high);
}

.md-dialog__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 24px;
}

.md-field {
    margin-bottom: 16px;
}

.md-field label {
    display: block;
    font-weight: 500;
    margin-bottom: 4px;
    font-size: 0.9rem;
    color: var(--md-sys-color-on-surface);
}

.md-input {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--md-sys-color-outline);
    background: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    font-family: inherit;
    font-size: 1rem;
    box-sizing: border-box;
}

.md-btn-text {
    background: transparent;
    color: var(--md-sys-color-primary);
    border: none;
    padding: 10px 16px;
    border-radius: 20px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
}

.md-btn-text:hover {
    background: var(--md-sys-color-surface-container-high);
}

.md-btn-filled {
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border: none;
    padding: 10px 24px;
    border-radius: 20px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
}

.md-btn-filled:hover {
    opacity: 0.92;
}

.md-btn-filled:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.metadata-body {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    overflow-y: auto;
    flex: 1;
    padding-right: 4px;
}

.metadata-media {
    flex: 1 1 380px;
    display: flex;
    flex-direction: column;
    align-items: center;
    align-self: flex-start;
    position: sticky;
    top: 0;
}

.metadata-media img,
.metadata-media video {
    width: 100%;
    max-height: 60vh;
    object-fit: contain;
    border-radius: 12px;
    background: var(--md-sys-color-surface-container-high);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.metadata-list {
    flex: 1 1 300px;
    display: flex;
    flex-direction: column;
}

.metadata-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.metadata-table tr {
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.metadata-table th {
    width: 42%;
    text-align: left;
    font-weight: 500;
    color: var(--md-sys-color-on-surface-variant);
    padding: 8px 16px 8px 4px;
    vertical-align: top;
}

.metadata-table td {
    color: var(--md-sys-color-on-surface);
    word-break: break-word;
    padding: 8px 4px;
}

.metadata-status {
    text-align: center;
    padding: 32px 16px;
    color: var(--md-sys-color-on-surface-variant);
}

.metadata-error {
    color: var(--md-sys-color-error);
    padding: 16px;
    background: var(--md-sys-color-error-container);
    border-radius: 12px;
}

.album-list-container {
    overflow-y: auto;
    max-height: 300px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.album-list-empty {
    text-align: center;
    color: var(--md-sys-color-outline);
    padding: 16px 0;
}

.album-radio-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    background: var(--md-sys-color-surface-container-high);
    cursor: pointer;
    transition: background 0.15s;
}

.album-radio-option input[type="radio"] {
    accent-color: var(--md-sys-color-primary);
}

.album-radio-info {
    display: flex;
    flex-direction: column;
}

.album-radio-name {
    color: var(--md-sys-color-on-surface);
    font-weight: 500;
}

.album-radio-count {
    font-size: 0.8rem;
    color: var(--md-sys-color-outline);
}

/* Native <dialog> Lightbox */
.lightbox-dialog {
    border: none;
    background: transparent;
    padding: 0;
    margin: 0;
    max-width: none;
    max-height: none;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

.lightbox-dialog[open] {
    display: flex;
    justify-content: center;
    align-items: center;
}

.lightbox-dialog::backdrop {
    background-color: rgba(17, 19, 24, 0.92);
}

.lightbox-stage {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

.lightbox-stage img,
.lightbox-stage video {
    max-width: 100%;
    max-height: 100vh;
    object-fit: contain;
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 30px;
    background: transparent;
    border: none;
    color: white;
    font-size: 40px;
    line-height: 1;
    font-weight: bold;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    z-index: 1010;
}

.close-btn:hover {
    opacity: 1;
}

.toast-region {
    position: fixed;
    inset: auto;
    margin: 0;
    border: none;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--md-sys-color-inverse-surface, #313033);
    color: var(--md-sys-color-inverse-on-surface, #f4eff4);
    padding: 12px 24px;
    border-radius: 100px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

.toast-region.show {
    opacity: 1;
}

.loader {
    position: absolute;
    border: 4px solid var(--md-sys-color-surface-container-high);
    border-top: 4px solid var(--md-sys-color-primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    z-index: -1;
}

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* --- Login Layout --- */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 3rem 2.5rem;
    background: var(--md-sys-color-surface-container-high);
    border-radius: var(--md-sys-shape-corner-extra-large);
    box-shadow: 0 8px 12px -4px rgba(0, 0, 0, 0.2), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    animation: slideUp var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard) forwards;
    opacity: 0;
    transform: translateY(20px);
}

@keyframes slideUp {
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.login-container h2 {
    font-size: 2.25rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 2.5rem;
    color: var(--md-sys-color-primary);
}

/* M3 Outlined Text Field Specs */
.md-text-field {
    position: relative;
    margin-bottom: 1.5rem;
    height: 56px;
}

.md-text-field input {
    width: 100%;
    height: 100%;
    padding: 0 16px;
    background: transparent;
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--md-sys-shape-corner-extra-small);
    color: var(--md-sys-color-on-surface);
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s, border-width 0.2s, padding 0.2s;
}

.md-text-field input:hover:not(:focus) {
    border-color: var(--md-sys-color-on-surface);
}

.md-text-field label {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    color: var(--md-sys-color-on-surface-variant);
    pointer-events: none;
    transition: all 0.2s var(--md-sys-motion-easing-standard);
    background: var(--md-sys-color-surface-container-high);
    padding: 0 4px;
}

.md-text-field input:focus,
.md-text-field input:not(:placeholder-shown) {
    border-color: var(--md-sys-color-primary);
    border-width: 2px;
    padding: 0 15px; 
}

.md-text-field input:-webkit-autofill,
.md-text-field input:-webkit-autofill:hover, 
.md-text-field input:-webkit-autofill:focus, 
.md-text-field input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px var(--md-sys-color-surface-container-high) inset !important;
    -webkit-text-fill-color: var(--md-sys-color-on-surface) !important;
    caret-color: var(--md-sys-color-on-surface) !important;
    border-radius: var(--md-sys-shape-corner-extra-small);
}

.md-text-field input:not(:placeholder-shown) + label {
    top: 0;
    font-size: 12px;
    color: var(--md-sys-color-on-surface-variant);
}

.md-text-field input:focus + label {
    top: 0;
    font-size: 12px;
    color: var(--md-sys-color-primary);
}

/* M3 Filled Button */
.submit-btn {
    width: 100%;
    padding: 1rem;
    margin-top: 1rem;
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border: none;
    border-radius: var(--md-sys-shape-corner-full);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s var(--md-sys-motion-easing-standard);
}

.submit-btn::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--md-sys-color-on-primary);
    opacity: 0;
    transition: opacity 0.2s;
}

.submit-btn:hover {
    transform: scale(1.02);
}

.submit-btn:hover::before {
    opacity: 0.08;
}

.submit-btn:active::before {
    opacity: 0.12;
}

.error-message {
    color: var(--md-sys-color-error);
    font-size: 0.875rem;
    text-align: center;
    margin-top: 1rem;
    min-height: 20px;
}

/* --- Floating Action Button (FAB) --- */
.md-fab {
    position: fixed;
    bottom: 2.5rem;
    right: 2.5rem;
    width: 64px;
    height: 64px;
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    border-radius: var(--md-sys-shape-corner-extra-large);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    text-decoration: none;
    font-size: 2.5rem;
    font-weight: 300;
    transition: transform var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard),
                background-color var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard),
                box-shadow var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
    z-index: 100;
    border: none;
    cursor: pointer;
}

.md-fab:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}

.md-fab:active {
    transform: scale(0.98) translateY(0);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
}

/* --- M3 Expressive Overflow Button & Menu --- */
.card-overflow-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border-radius: var(--md-sys-shape-corner-full);
    border: none;
    background: rgba(0, 0, 0, 0.45);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0; /* Hover only */
    transition: opacity 0.25s var(--md-sys-motion-easing-standard), 
                background-color 0.2s var(--md-sys-motion-easing-standard), 
                transform 0.2s var(--md-sys-motion-easing-standard);
    z-index: 15;
}

.card-overflow-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Show overflow button on hover of the parent card */
.card:hover .card-overflow-btn,
.card.menu-open .card-overflow-btn {
    opacity: 1;
}

.card-overflow-btn:hover {
    background: rgba(0, 0, 0, 0.75);
    transform: scale(1.08);
}

.card-overflow-btn:active {
    transform: scale(0.92);
}

/* Floating Menu Container (Native Popover) */
.md-menu {
    position: fixed;
    inset: auto;
    margin: 0;
    border: none;
    z-index: 1100;
    background: var(--md-sys-color-surface-container-high);
    border-radius: var(--md-sys-shape-corner-small); /* 8px corner */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.16), 0 1px 3px rgba(0, 0, 0, 0.1);
    min-width: 180px;
    padding: 6px 0;
}

.md-menu:not([popover]) {
    display: none;
}

.md-menu.active {
    display: block;
}

.md-menu-item {
    width: 100%;
    border: none;
    background: transparent;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--md-sys-color-on-surface);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    position: relative;
    outline: none;
}

.md-menu-item::after {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--md-sys-color-on-surface);
    opacity: 0;
    transition: opacity 0.2s var(--md-sys-motion-easing-standard);
    pointer-events: none;
}

.md-menu-item:hover::after {
    opacity: 0.08;
}

.md-menu-item:focus-visible::after {
    opacity: 0.12;
}

.md-menu-item:active::after {
    opacity: 0.16;
}

.md-menu-item svg {
    width: 18px;
    height: 18px;
    fill: var(--md-sys-color-on-surface-variant);
}

.md-menu-item span {
    position: relative;
    z-index: 2;
}

/* Danger variant for Delete */
.md-menu-item--danger {
    color: var(--md-sys-color-error);
}

.md-menu-item--danger svg {
    fill: var(--md-sys-color-error);
}

.md-menu-item--danger::after {
    background: var(--md-sys-color-error);
}

/* --- Select Checkbox --- */
.card-select-checkbox {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 32px;
    height: 32px;
    border-radius: var(--md-sys-shape-corner-full);
    background: rgba(0, 0, 0, 0.45);
    border: 2px solid rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0; /* Hidden by default, shown on hover */
    transition: opacity 0.2s var(--md-sys-motion-easing-standard),
                background-color 0.2s var(--md-sys-motion-easing-standard),
                border-color 0.2s var(--md-sys-motion-easing-standard),
                transform 0.2s var(--md-sys-motion-easing-standard);
    z-index: 15;
}

.card-select-checkbox svg {
    width: 20px;
    height: 20px;
    fill: #ffffff;
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.2s var(--md-sys-motion-easing-standard),
                transform 0.2s var(--md-sys-motion-easing-standard);
}

/* Show checkbox on card hover */
.card:hover .card-select-checkbox {
    opacity: 1;
}

/* In selection mode, keep all checkboxes visible */
body.selection-mode .card-select-checkbox {
    opacity: 1;
    border-color: rgba(255, 255, 255, 0.6);
    background: rgba(0, 0, 0, 0.25);
}

/* Checked state */
.card.selected .card-select-checkbox {
    opacity: 1;
    background: var(--md-sys-color-primary);
    border-color: var(--md-sys-color-primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.card.selected .card-select-checkbox svg {
    opacity: 1;
    transform: scale(1);
}

/* Highlight card when selected */
.card.selected {
    box-shadow: 0 0 0 3px var(--md-sys-color-primary), 0 8px 16px rgba(0, 0, 0, 0.2);
}

/* Hover feedback for the checkbox */
.card-select-checkbox:hover {
    transform: scale(1.08);
    background: rgba(0, 0, 0, 0.7);
}

.card.selected .card-select-checkbox:hover {
    background: var(--md-sys-color-primary);
}

/* Pure-CSS Selection Mode & Header Controls */
.header-user-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.selection-actions-container {
    display: inline-flex;
    align-items: center;
}

body:not(.selection-mode) .when-selecting {
    display: none;
}

body.selection-mode .when-normal {
    display: none;
}

.md-top-app-bar__left .md-selection-icon-btn {
    margin-left: 0;
}

/* App bar selection mode transitions */
body.selection-mode .md-top-app-bar,
.md-top-app-bar.selection-mode {
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    border-bottom-color: var(--md-sys-color-primary);
}

body.selection-mode .md-top-app-bar .md-top-app-bar__title,
.md-top-app-bar.selection-mode .md-top-app-bar__title {
    color: var(--md-sys-color-on-primary-container);
    font-weight: 700;
}

/* M3 Icon Button for Selection Actions */
.md-selection-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--md-sys-shape-corner-full);
    border: none;
    background: transparent;
    color: var(--md-sys-color-on-primary-container);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-left: 8px;
    transition: background-color 0.2s var(--md-sys-motion-easing-standard), 
                transform 0.2s var(--md-sys-motion-easing-standard);
}

.md-selection-icon-btn svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.md-selection-icon-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    transform: scale(1.05);
}

.md-selection-icon-btn:active {
    transform: scale(0.95);
}

/* M3 Filter Select Styling */
.filter-select-container {
    position: relative;
    display: inline-block;
}

.md-filter-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface-variant);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-full);
    padding: 6px 32px 6px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='%23444653'><path d='M7 10l5 5 5-5z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 18px;
}

/* In selection-mode, hide selects so the selection bar is clean */
body.selection-mode .filter-select-container {
    display: none;
}

.md-filter-select:hover {
    background-color: var(--md-sys-color-surface-container);
    border-color: var(--md-sys-color-on-surface-variant);
    color: var(--md-sys-color-on-surface);
}

.md-filter-select:focus {
    border-color: var(--md-sys-color-primary);
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    box-shadow: 0 0 0 2px var(--md-sys-color-primary-container);
}

/* --- Album Cards Styling --- */
.album-card {
    transition: transform var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard),
                box-shadow var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard) !important;
}

.album-card:hover {
    transform: scale(1.03) translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15) !important;
}

.album-card:active {
    transform: scale(0.98) translateY(0);
}

/* Lightbox Arrows */
.lightbox-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.3);
    color: white;
    border: none;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, transform 0.2s, opacity 0.2s;
    z-index: 1010;
    opacity: 0.7;
    user-select: none;
}

.lightbox-arrow svg {
    width: 28px;
    height: 28px;
    display: block;
}

.lightbox-arrow:hover {
    background: rgba(0, 0, 0, 0.6);
    opacity: 1;
    transform: translateY(-50%) scale(1.1);
}

.lightbox-arrow:active {
    transform: translateY(-50%) scale(0.95);
}

.lightbox-arrow.left {
    left: 20px;
}

.lightbox-arrow.right {
    right: 20px;
}

/* Hide arrows on mobile screens or adjust size */
@media (max-width: 768px) {
    .lightbox-arrow {
        width: 44px;
        height: 44px;
    }
    .lightbox-arrow svg {
        width: 20px;
        height: 20px;
    }
    .lightbox-arrow.left {
        left: 10px;
    }
    .lightbox-arrow.right {
        right: 10px;
    }
}



