:root {
    --bg-color: var(--card-bg);
    --sidebar-bg: #000000;
    --main-bg: #000000;
    --text-primary: #ffffff;
    --text-secondary: #a1a1a6;
    --accent-color: #0a84ff;
    --border-color: #38383a;
    --scrim-color: rgba(0, 0, 0, 0.4);
    --glass-border: 1px solid var(--overlay-light-10);

    --overlay-light-2: rgba(255, 255, 255, 0.02);
    --overlay-light-3: rgba(255, 255, 255, 0.03);
    --overlay-light-5: rgba(255, 255, 255, 0.05);
    --overlay-light-7: rgba(255, 255, 255, 0.07);
    --overlay-light-8: rgba(255, 255, 255, 0.08);
    --overlay-light-10: rgba(255, 255, 255, 0.1);
    --overlay-light-12: rgba(255, 255, 255, 0.12);
    --overlay-light-14: rgba(255, 255, 255, 0.14);
    --overlay-light-15: rgba(255, 255, 255, 0.15);
    --overlay-light-20: rgba(255, 255, 255, 0.2);
    --overlay-light-25: rgba(255, 255, 255, 0.25);
    --overlay-light-30: rgba(255, 255, 255, 0.3);
    --overlay-light-35: rgba(255, 255, 255, 0.35);
    --overlay-light-40: rgba(255, 255, 255, 0.4);
    --overlay-light-45: rgba(255, 255, 255, 0.45);
    --overlay-light-50: rgba(255, 255, 255, 0.5);
    --overlay-light-60: rgba(255, 255, 255, 0.6);
    --overlay-light-70: rgba(255, 255, 255, 0.7);
    --overlay-light-75: rgba(255, 255, 255, 0.75);
    --overlay-light-80: rgba(255, 255, 255, 0.8);
    --overlay-light-85: rgba(255, 255, 255, 0.85);
    --overlay-light-90: rgba(255, 255, 255, 0.9);
    --overlay-light-95: rgba(255, 255, 255, 0.95);
}

[data-theme="light"] {
    --bg-color: #f1f3f4;
    --sidebar-bg: #ffffff;
    --main-bg: #ffffff;
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --border-color: rgba(0, 0, 0, 0.1);
    --glass-border: 1px solid rgba(0, 0, 0, 0.05);
    --overlay-light-2: rgba(0, 0, 0, 0.02);
    --overlay-light-3: rgba(0, 0, 0, 0.03);
    --overlay-light-5: rgba(0, 0, 0, 0.05);
    --overlay-light-7: rgba(0, 0, 0, 0.07);
    --overlay-light-8: rgba(0, 0, 0, 0.08);
    --overlay-light-10: rgba(0, 0, 0, 0.1);
    --overlay-light-12: rgba(0, 0, 0, 0.12);
    --overlay-light-14: rgba(0, 0, 0, 0.14);
    --overlay-light-15: rgba(0, 0, 0, 0.15);
    --overlay-light-20: rgba(0, 0, 0, 0.2);
    --overlay-light-25: rgba(0, 0, 0, 0.25);
    --overlay-light-30: rgba(0, 0, 0, 0.3);
    --overlay-light-35: rgba(0, 0, 0, 0.35);
    --overlay-light-40: rgba(0, 0, 0, 0.4);
    --overlay-light-45: rgba(0, 0, 0, 0.45);
    --overlay-light-50: rgba(0, 0, 0, 0.5);
    --overlay-light-60: rgba(0, 0, 0, 0.6);
    --overlay-light-70: rgba(0, 0, 0, 0.7);
    --overlay-light-75: rgba(0, 0, 0, 0.75);
    --overlay-light-80: rgba(0, 0, 0, 0.8);
    --overlay-light-85: rgba(0, 0, 0, 0.85);
    --overlay-light-90: rgba(0, 0, 0, 0.9);
    --overlay-light-95: rgba(0, 0, 0, 0.95);
}


* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--main-bg);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    font-size: 14px;
}

/* Login Screen */
.login-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: radial-gradient(circle at center, #2d2d2d 0%, var(--main-bg) 100%);
}

.login-box {
    background: rgba(40, 40, 40, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 40px;
    border-radius: 18px;
    border: var(--glass-border);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    width: 340px;
    text-align: center;
    transition: transform 0.3s ease;
}

.login-box h1 {
    margin-bottom: 24px;
    font-weight: 500;
    font-size: 24px;
}

.input-group {
    margin-bottom: 16px;
    position: relative;
}

.input-group input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid transparent;
    border-radius: 10px;
    color: white;
    font-size: 15px;
    outline: none;
    transition: all 0.2s;
}

.input-group input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.3);
}

.login-btn {
    width: 100%;
    padding: 12px;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.login-btn:hover {
    background-color: #0077ed;
}

/* Main App Layout */
.app-layout {
    display: flex;
    height: 100vh;
}

/* ===== SIDEBAR — Google Photos-inspired ===== */
.sidebar {
    width: 240px;
    min-width: 240px;
    height: 100%;
    background: #000000;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
}

.sidebar::-webkit-scrollbar {
    display: none;
}

/* Branding header */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 20px 16px 16px;
}

.sidebar-logo i {
    font-size: 22px;
    color: #1a73e8;
}

.sidebar-logo-text {
    display: flex;
    align-items: baseline;
    gap: 5px;
}

.sidebar-logo-brand {
    font-size: 14px;
    font-weight: 400;
    color: var(--overlay-light-45);
    letter-spacing: 0;
}

.sidebar-logo-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--overlay-light-90);
}

/* Navigation items */
.nav-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    margin: 1px 8px;
    border-radius: 24px;
    cursor: pointer;
    color: var(--overlay-light-75);
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
}

.nav-item:hover {
    background: var(--overlay-light-8);
    color: var(--overlay-light-95);
}

.nav-item.active {
    background: #1a73e8;
    color: var(--text-primary);
    font-weight: 600;
}

.nav-item i {
    width: 20px;
    font-size: 16px;
    margin-right: 14px;
    flex-shrink: 0;
    text-align: center;
    color: inherit;
    opacity: 0.8;
}

.nav-item.active i {
    opacity: 1;
}

/* Section group header */
.sidebar-section-header {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--overlay-light-35);
    padding: 16px 24px 6px;
}

.sidebar-divider {
    height: 1px;
    background: var(--overlay-light-7);
    margin: 8px 16px;
}

/* Bottom section — user card + storage */
.sidebar-user-card {
    margin-top: auto;
    padding: 8px 0 12px;
    border-top: 1px solid var(--overlay-light-7);
}

.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-radius: 0;
    cursor: default;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1a73e8, #8ab4f8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    letter-spacing: -0.5px;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.user-role {
    font-size: 11px;
    color: var(--overlay-light-40);
    margin-top: 1px;
    text-transform: capitalize;
}

/* Storage bar */
.storage-bar-wrap {
    padding: 8px 16px 4px;
}

.storage-bar-label {
    font-size: 11px;
    color: var(--overlay-light-40);
    margin-bottom: 6px;
}

.storage-bar-track {
    width: 100%;
    height: 3px;
    background: var(--overlay-light-10);
    border-radius: 4px;
    overflow: hidden;
}

.storage-bar-fill {
    height: 100%;
    background: #1a73e8;
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* Logout */
.logout-btn {
    color: var(--overlay-light-50);
    font-size: 14px;
}

.logout-btn:hover {
    color: var(--overlay-light-85);
    background: var(--overlay-light-7);
}

.logout-btn:hover i {
    opacity: 1;
}


/* Content Area */
.content-area {
    flex: 1;
    overflow-y: auto;
    background-color: var(--main-bg);
    padding: 24px;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.content-title {
    font-size: 28px;
    font-weight: 700;
}

.refresh-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.refresh-btn:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
}

/* Photo Grid */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.photo-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    background: var(--bg-color);
    transition: transform 0.22s cubic-bezier(.34, 1.56, .64, 1), box-shadow 0.22s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.photo-item:hover {
    transform: scale(1.04);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
    z-index: 2;
}

/* Selection state */
.photo-item.selected {
    outline: 3px solid var(--accent-color);
    outline-offset: -3px;
}

/* Hover overlay — fades in on hover */
.photo-item-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.5) 0%, transparent 45%, transparent 55%, rgba(0, 0, 0, 0.6) 100%);
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 3;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 8px;
}

.photo-item:hover .photo-item-overlay {
    opacity: 1;
}

/* Selection checkbox in top-left */
.photo-select-check {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2.5px solid var(--overlay-light-85);
    background: rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    font-size: 11px;
    font-weight: 700;
    transition: all 0.15s ease;
    flex-shrink: 0;
    pointer-events: all;
    cursor: pointer;
}

.photo-item.selected .photo-select-check,
.photo-item:hover .photo-select-check {
    border-color: white;
}

.photo-item.selected .photo-select-check {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
}

/* Date label in bottom of overlay */
.photo-item-date {
    font-size: 11px;
    color: var(--overlay-light-90);
    font-weight: 500;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    align-self: flex-end;
    line-height: 1.3;
}

.play-icon-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 24px;
    background: rgba(0, 0, 0, 0.5);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    pointer-events: none;
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0;
    transition: opacity 0.35s ease;
}

.photo-item img.loaded {
    opacity: 1;
}

/* Bulk selection toolbar */
.selection-toolbar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(28, 28, 30, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--overlay-light-12);
    border-radius: 18px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 500;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s cubic-bezier(.34, 1.56, .64, 1), opacity 0.25s ease;
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
}

.selection-toolbar.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: all;
}

.selection-toolbar-count {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 80px;
}

.selection-toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--overlay-light-15);
}

.sel-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.15s ease, transform 0.1s;
    color: white;
}

.sel-btn:active {
    transform: scale(0.96);
}

.sel-btn-album {
    background: rgba(10, 132, 255, 0.25);
    color: #4facfe;
}

.sel-btn-album:hover {
    background: rgba(10, 132, 255, 0.4);
}

.sel-btn-cancel {
    background: var(--overlay-light-8);
    color: var(--text-secondary);
}

.sel-btn-cancel:hover {
    background: var(--overlay-light-14);
}


/* Lightbox / Fullscreen Viewer */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.lightbox.active {
    opacity: 1;
    pointer-events: all;
}

.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: var(--overlay-light-10);
    color: white;
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10;
    opacity: 0;
}

.lightbox-media:hover .nav-arrow {
    opacity: 1;
}

.nav-arrow:hover {
    background: var(--overlay-light-20);
    transform: translateY(-50%) scale(1.1);
}

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

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

.lightbox img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    cursor: grab;
    transform-origin: center;
}

.lightbox video {
    cursor: grab;
    transform-origin: center;
}

.lightbox img:active,
.lightbox video:active {
    cursor: grabbing;
}

.lightbox-content {
    display: flex;
    width: 95%;
    height: 95%;
    gap: 20px;
}

.lightbox-media {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-width: 0;
    /* Fix flex overflow */
}

.lightbox-sidebar {
    width: 300px;
    background: rgba(30, 30, 30, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid var(--overlay-light-10);
    border-radius: 12px;
    padding: 20px;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.meta-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    word-break: break-word;
}

.meta-row {
    margin-bottom: 16px;
}

.meta-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.meta-value {
    font-size: 14px;
    color: var(--text-primary);
    word-break: break-word;
}

.lightbox-mobile-btn {
    display: none;
    /* Only visible on mobile */
    position: absolute;
    top: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: 1px solid var(--overlay-light-20);
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    z-index: 2000;
    backdrop-filter: blur(4px);
    transition: background 0.2s;
}

.lightbox-mobile-btn:hover {
    background: rgba(0, 0, 0, 0.7);
}

.lightbox-btn-close {
    left: 16px;
}

.lightbox-btn-info {
    right: 16px;
}

.close-help {
    position: absolute;
    top: 20px;
    right: 20px;
    color: var(--text-secondary);
    background: var(--overlay-light-10);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
}

/* File Explorer (List View) */
.file-explorer {
    display: flex;
    flex-direction: column;
}

.fe-header {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
}

.fe-breadcrumbs {
    flex: 1;
    display: flex;
    align-items: center;
    overflow: hidden;
}

.fe-back-btn {
    background: transparent;
    border: none;
    color: var(--accent-color);
    font-size: 16px;
    margin-right: 16px;
    cursor: pointer;
    font-weight: 500;
}

.fe-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fe-toolbar {
    display: flex;
    gap: 10px;
}

.fe-tool-btn {
    background: var(--overlay-light-10);
    border: none;
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.fe-tool-btn:hover {
    background: var(--overlay-light-15);
}

.fe-tool-btn.danger {
    background: rgba(255, 59, 48, 0.2);
    color: #ff3b30;
}

.fe-tool-btn.danger:hover {
    background: rgba(255, 59, 48, 0.3);
}

.fe-sort-select {
    background: var(--overlay-light-10);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    outline: none;
    transition: background 0.2s;
}

.fe-sort-select:hover {
    background: var(--overlay-light-15);
}

.fe-sort-select option {
    background: var(--bg-color);
    color: var(--text-primary);
}


.fe-list {
    display: flex;
    flex-direction: column;
    border-top: 1px solid var(--border-color);
}

.fe-grid {
    display: grid;
    /* Increase min width for bigger thumbnails */
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 32px;
    /* Increase gap for more breathing room */
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.fe-row {
    display: flex;
    align-items: center;
    padding: 12px 10px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.1s;
}

.fe-row:hover {
    background: var(--overlay-light-5);
}

.fe-row.selected {
    background: rgba(10, 132, 255, 0.15);
}

.fe-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid var(--text-secondary);
    border-radius: 50%;
    margin-right: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    cursor: pointer;
}

.fe-checkbox.checked {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
    font-size: 12px;
}

.fe-icon {
    width: 30px;
    font-size: 20px;
    margin-right: 14px;
    display: flex;
    justify-content: center;
}

.fe-name {
    flex: 1;
    font-size: 15px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fe-size {
    font-size: 13px;
    color: var(--text-secondary);
    width: 80px;
    text-align: right;
}

/* Grid Card */
.fe-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    /* give more padding */
    border-radius: 12px;
    /* slightly rounder corners */
    cursor: pointer;
    position: relative;
    background: var(--overlay-light-2);
    /* slightly fainter background */
    border: 1px solid transparent;
    /* Prepare for hover border */
    transition: all 0.2s ease;
    /* Smooth hover transitions */
    overflow: hidden;
    /* Ensure contents don't bleed out */
}

.fe-card:hover {
    background: var(--overlay-light-5);
    border: 1px solid var(--overlay-light-10);
    transform: translateY(-2px);
    /* Slight lift effect */
}

.fe-card.selected {
    background: rgba(10, 132, 255, 0.1);
    box-shadow: 0 0 0 2px var(--accent-color) inset;
    border-color: transparent;
}

.fe-card-icon {
    width: 90px;
    /* Increase icon/thumbnail container size */
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    /* More space between icon and text */
}

.fe-card-icon img {
    /* Optional: Ensure image fits nicely within larger area if it's a thumbnail */
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.fe-card-name {
    font-size: 14px;
    /* slightly larger text */
    font-weight: 500;
    text-align: center;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    /* allow names to wrap up to 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    white-space: normal;
    line-height: 1.3;
    color: var(--text-primary);
    /* brighter text */
}

.fe-checkbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.5) 0%, transparent 50px);
    border-radius: 12px;
    opacity: 0;
    transition: opacity 0.2s;
    display: flex;
    justify-content: flex-end;
    align-items: flex-start;
    padding: 8px;
    pointer-events: none;
}

.fe-card:hover .fe-checkbox-overlay,
.fe-card.selected .fe-checkbox-overlay {
    opacity: 1;
}

.fe-card .fe-checkbox {
    pointer-events: auto;
    margin: 0;
    background: rgba(0, 0, 0, 0.4);
    border-color: var(--overlay-light-70);
    color: transparent;
}

.fe-card .fe-checkbox:hover {
    background: rgba(0, 0, 0, 0.6);
    border-color: white;
}

.fe-card .fe-checkbox.checked {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
}

.fe-empty {
    padding: 30px;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
}

/* Loading State */
.spinner {
    border: 3px solid var(--overlay-light-10);
    border-top: 3px solid var(--accent-color);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

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

    100% {
        transform: rotate(360deg);
    }
}

/* People Grid — Google Photos Style */
.people-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.person-card {
    position: relative;
    aspect-ratio: 3 / 4;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    background: #222;
    transition: transform 0.2s, box-shadow 0.2s;
}

.person-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

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

.person-card-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
}

.person-card-placeholder i {
    font-size: 56px;
    color: var(--text-secondary);
}

.person-card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 40px 12px 12px 12px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.person-card-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.person-card-count {
    font-size: 12px;
    color: var(--overlay-light-70);
}

.person-delete-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 59, 48, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    opacity: 0;
    z-index: 20;
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: auto;
}

.person-delete-btn:hover {
    transform: scale(1.1);
    background: #d70015;
}

.person-card:hover .person-delete-btn {
    opacity: 1;
}

/* Person Detail View */
.person-detail-view {
    display: flex;
    flex-direction: column;
}

.person-detail-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.person-detail-name {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    padding: 4px 8px;
    border-radius: 6px;
    outline: none;
    transition: background 0.2s;
    cursor: text;
}

.person-detail-name:focus {
    background: var(--overlay-light-10);
}

.person-detail-count {
    font-size: 14px;
    color: var(--text-secondary);
    margin-left: auto;
}

.person-detail-delete {
    background: rgba(255, 59, 48, 0.15);
    color: #ff3b30;
    border: 1px solid rgba(255, 59, 48, 0.3);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.person-detail-delete:hover {
    background: rgba(255, 59, 48, 0.25);
    border-color: #ff3b30;
}

/* Search Interface */
.search-interface {
    display: flex;
    flex-direction: column;
}

.search-controls {
    margin-bottom: 32px;
    padding: 0;
}

/* Large Search Pill */
.search-box-large {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    /* Dark subtle glass */
    border-radius: 30px;
    padding: 6px 6px 6px 20px;
    margin-bottom: 32px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.2s, box-shadow 0.2s;
}

.search-box-large:focus-within {
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.search-icon-large {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.4);
    margin-right: 12px;
}

.search-box-large input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 16px;
}

.search-box-large input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.search-btn-large {
    padding: 10px 24px;
    border-radius: 24px;
    border: none;
    background: var(--accent-color);
    color: white;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.search-btn-large:hover {
    background: #0070e0;
}

/* People Section */
.search-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 16px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.people-chips-scrollable {
    display: flex;
    overflow-x: auto;
    padding-bottom: 12px;
    gap: 12px;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
}

.people-chips-scrollable::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

/* Person Chip with Avatar */
.person-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px 6px 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 30px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    white-space: nowrap;
    flex-shrink: 0;
}

.person-chip-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1a73e8, #8ab4f8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 13px;
}

.person-chip.unknown-chip .person-chip-avatar {
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.6);
}

.person-chip:hover {
    background: rgba(255, 255, 255, 0.1);
}

.person-chip.selected {
    background: rgba(26, 115, 232, 0.15);
    border-color: #1a73e8;
    color: #1a73e8;
}

.person-chip.selected .person-chip-avatar {
    background: #1a73e8;
}

/* Timeline View */
/* Photo Search Bar */
.photo-search-bar {
    display: flex;
    align-items: center;
    background: #2a2a2e;
    border-radius: 24px;
    padding: 0 16px;
    margin-bottom: 20px;
    transition: background 0.2s, box-shadow 0.2s;
    position: relative;
}

.photo-search-bar:focus-within {
    background: #333338;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.photo-search-icon {
    color: var(--text-secondary);
    font-size: 15px;
    flex-shrink: 0;
}

.photo-search-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 15px;
    padding: 12px;
    font-family: inherit;
}

.photo-search-input::placeholder {
    color: var(--text-secondary);
}

.photo-search-clear {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background 0.2s;
}

.photo-search-clear:hover {
    color: var(--text-primary);
    background: var(--overlay-light-10);
}

.timeline-view {
    display: flex;
    flex-direction: column;
}

.timeline-section {
    margin-bottom: 40px;
}

.timeline-date-header {
    position: sticky;
    top: 0;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    padding: 16px 0;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.timeline-date-header h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.timeline-date-header span {
    font-size: 14px;
    color: var(--text-secondary);
}

.timeline-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

/* Discover View */
.discover-view {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.memory-card {
    background: var(--overlay-light-3);
    border-radius: 12px;
    padding: 24px;
    border: 1px solid var(--border-color);
}

.memory-header h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.memory-header p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.memory-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    margin-top: 4px;
}

.header-action-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.header-action-btn:hover {
    background: var(--overlay-light-10);
    color: var(--text-primary);
    border-color: var(--text-primary);
}

/* Album Button Overlay */
.album-btn {
    display: flex;
    flex-direction: column;
}

/* Albums View */
.albums-view {
    display: flex;
    flex-direction: column;
}

.albums-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.albums-header h2 {
    font-size: 28px;
    font-weight: 700;
    margin: 0;
}

.create-album-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.create-album-btn:hover {
    background: #0077ed;
}

.albums-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.album-card {
    background: var(--overlay-light-5);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    position: relative;
}

.album-card:hover {
    transform: translateY(-4px);
    background: var(--overlay-light-8);
}

.album-cover {
    aspect-ratio: 1;
    background: var(--bg-color);
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: var(--text-secondary);
}

.album-info {
    padding: 16px;
}

.album-info h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 4px 0;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.album-info p {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

.album-badge {
    display: inline-block;
    background: rgba(10, 132, 255, 0.2);
    color: var(--accent-color);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-top: 8px;
}

.album-delete-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 59, 48, 0.9);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 5;
}

.album-card:hover .album-delete-btn {
    opacity: 1;
}

.album-delete-btn:hover {
    transform: scale(1.1);
    background: #d70015;
}

.album-detail-view {
    display: flex;
    flex-direction: column;
}

.album-detail-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.back-btn {
    background: var(--overlay-light-10);
    color: var(--text-primary);
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.back-btn:hover {
    background: var(--overlay-light-20);
}

.album-detail-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {

    /* Login Screen */
    .login-box {
        width: 90%;
        max-width: 340px;
        padding: 30px 20px;
    }

    /* Main Layout */
    .app-layout {
        flex-direction: column;
    }

    /* Sidebar -> Bottom Navigation */
    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: auto;
        flex-direction: row;
        border-right: none;
        border-top: 1px solid var(--border-color);
        padding: 8px 10px;
        justify-content: flex-start;
        /* Instead of space-around, allow scrolling */
        overflow-x: auto;
        /* Enable horizontal scrolling */
        overflow-y: hidden;
        white-space: nowrap;
        z-index: 100;
        background-color: rgba(17, 17, 19, 0.98);
        padding-bottom: env(safe-area-inset-bottom, 12px);
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .sidebar::-webkit-scrollbar {
        display: none;
    }

    /* Hide the new Google-style sidebar elements on mobile */
    .sidebar-logo,
    .sidebar-section-header,
    .sidebar-divider,
    .sidebar-user-card {
        display: none !important;
    }

    /* Clean up the nav items for horizontal scrolling */
    .nav-item {
        flex-direction: column;
        margin: 0 4px 0 0;
        padding: 8px 10px;
        font-size: 11px;
        font-weight: 500;
        text-align: center;
        background: transparent !important;
        flex: 0 0 auto;
        min-width: 65px;
        border-radius: 12px;
        color: var(--overlay-light-60);
    }

    /* Override the solid blue pill on mobile — use a subtle background instead */
    .nav-item.active {
        color: var(--accent-color);
        background: rgba(26, 115, 232, 0.15) !important;
    }

    .nav-item.active::before {
        display: none;
    }

    /* Remove left border pill if any */

    .nav-item i {
        margin: 0 0 4px 0;
        font-size: 18px;
        display: block;
        opacity: 0.8;
    }

    .nav-item.active i {
        opacity: 1;
        color: var(--accent-color);
    }

    /* Content Area */
    .content-area {
        padding: 16px;
        padding-bottom: 90px;
        /* Space for bottom nav */
    }

    .content-header {
        margin-bottom: 16px;
    }

    .content-title {
        font-size: 24px;
    }

    /* Photo Grid & Timeline Grid */
    .photo-grid,
    .timeline-grid,
    .memory-preview {
        /* Even smaller thumbnails on mobile to allow 4-5 per row */
        grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
        gap: 4px;
        /* Slightly more gap as requested */
    }

    .photo-item {
        border-radius: 4px;
    }

    /* On mobile, hide the clutter — album button not usable on small tiles */
    .photo-item .album-btn {
        display: none !important;
    }

    /* Hide the hover overlay entirely on mobile by default — only show the select
       circle when selection mode is active (JS adds .selection-active to body) */
    .photo-item-overlay {
        opacity: 0 !important;
        pointer-events: none;
    }

    /* Show the overlay (just the select circle) when in selection mode */
    body.selection-active .photo-item-overlay {
        opacity: 1 !important;
        pointer-events: all;
    }

    /* Selected items always show their check */
    .photo-item.selected .photo-item-overlay {
        opacity: 1 !important;
        pointer-events: all;
    }

    /* Suppress date label on tiny tiles — not enough room */
    .photo-item-date {
        display: none;
    }

    /* File Explorer Grid */
    .fe-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 12px;
        padding-top: 12px;
    }

    .fe-card {
        padding: 8px;
    }

    .fe-card-icon {
        width: 70px;
        height: 70px;
        margin-bottom: 6px;
    }

    /* Lightbox */
    .lightbox img {
        max-width: 100%;
        max-height: 100%;
        /* Let it fill the screen on mobile */
    }

    .lightbox-mobile-btn {
        display: flex;
    }

    .lightbox-content {
        flex-direction: column;
        width: 100%;
        height: 100%;
        gap: 0;
    }

    .lightbox-sidebar {
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 60%;
        max-height: 60%;
        border-radius: 20px 20px 0 0;
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1500;
        padding-bottom: env(safe-area-inset-bottom, 20px);
    }

    .lightbox-sidebar.active-mobile {
        transform: translateY(0);
    }

    .hide-on-mobile {
        display: none !important;
    }
}

/* Album Management */
.album-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: 1px solid var(--overlay-light-40);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
    z-index: 5;
}

.photo-item:hover .album-btn {
    opacity: 1;
}

.album-btn:hover {
    background: var(--accent-color);
    border-color: var(--accent-color);
    transform: scale(1.1);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: #2c2c2e;
    width: 400px;
    max-width: 90%;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.modal-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--overlay-light-5);
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
}

.modal-body {
    padding: 16px;
    max-height: 60vh;
    overflow-y: auto;
}

.album-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.album-list-item {
    display: flex;
    align-items: center;
    padding: 10px;
    border-radius: 8px;
    background: var(--overlay-light-5);
    cursor: pointer;
    transition: background 0.2s;
}

.album-list-item:hover {
    background: var(--overlay-light-10);
}

.album-list-thumb {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    object-fit: cover;
    margin-right: 12px;
    background: #444;
}

.album-list-info {
    flex: 1;
}

.album-list-name {
    font-size: 14px;
    font-weight: 500;
}

.album-list-count {
    font-size: 12px;
    color: var(--text-secondary);
}

.create-album-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.create-album-input-group {
    display: flex;
    gap: 10px;
}

.create-album-input-group input {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.3);
    color: white;
    outline: none;
}

.create-album-btn {
    padding: 0 16px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

.create-album-btn:hover {
    background: #0077ed;
}

/* Video Overlay */
.play-icon-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 24px;
    background: rgba(0, 0, 0, 0.5);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    pointer-events: none;
    z-index: 2;
}



/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: #555;
    border-radius: 24px;
    transition: 0.3s;
}

.toggle-slider:before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-switch input:checked+.toggle-slider {
    background: #34c759;
}

.toggle-switch input:checked+.toggle-slider:before {
    transform: translateX(20px);
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--card-bg, #1e1e2e);
    border-radius: 12px;
    width: 500px;
    max-width: 90vw;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-weight: 600;
    color: white;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    border-radius: 6px;
}

.modal-close:hover {
    background: var(--overlay-light-10);
    color: white;
}

.modal-body {
    padding: 20px;
}