[x-cloak] {
    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;
}

* {
    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);
}

/* Year Delimiter styling */
.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);
}

/* 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 {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: var(--md-sys-shape-corner-extra-small);
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

/* 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;
}

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    z-index: 1000;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(17, 19, 24, 0.9);
    opacity: 0;
    transition: opacity var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
    justify-content: center;
    align-items: center;
}

.lightbox.active {
    display: flex;
    opacity: 1;
}

.lightbox img {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
    box-shadow: none;
    transform: scale(0.95);
    transition: transform var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
    object-fit: contain;
}

.lightbox.active img {
    transform: scale(1);
}

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

.close-btn:hover {
    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 */
.md-menu {
    position: fixed;
    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: 140px;
    padding: 6px 0;
    opacity: 0;
    transform: scale(0.92);
    transform-origin: top right;
    transition: opacity 150ms var(--md-sys-motion-easing-standard), 
                transform 150ms var(--md-sys-motion-easing-standard);
    pointer-events: none;
    display: none;
}

.md-menu.active {
    display: block;
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.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);
}

/* App bar selection mode transitions */
.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);
}

.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;
    }
}



