/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* === TEMA SOFT PASTEL (default) === */
:root, .theme-soft {
    --primary: #9c7cba;
    --primary-light: #d4c4e8;
    --primary-dark: #7b5ea7;
    --accent: #e8b4d4;
    --bg: #f7f0fa;
    --bg-card: #ffffff;
    --text: #2c2c2c;
    --text-muted: #8a7a9a;
    --border: #e8ddf0;
    --success: #4caf50;
    --danger: #f44336;
    --pending: #ff9800;
    --shadow: 0 2px 12px rgba(124, 94, 186, 0.1);
    --radius: 16px;
    --radius-sm: 8px;
}

.theme-nature {
    --primary: #6b8f5e;
    --primary-light: #c4dbb6;
    --primary-dark: #4a6b3e;
    --accent: #d4a373;
    --bg: #f4f7f2;
    --bg-card: #ffffff;
    --text: #2c2c2c;
    --text-muted: #7a8a72;
    --border: #dce8d5;
    --success: #4caf50;
    --danger: #f44336;
    --pending: #ff9800;
    --shadow: 0 2px 12px rgba(107, 143, 94, 0.12);
}

.theme-elegant {
    --primary: #b8956a;
    --primary-light: #e8d5bc;
    --primary-dark: #8a6e4a;
    --accent: #2c2c2c;
    --bg: #faf8f5;
    --bg-card: #ffffff;
    --text: #1a1a1a;
    --text-muted: #8a8a8a;
    --border: #e8e0d5;
    --success: #4caf50;
    --danger: #f44336;
    --pending: #ff9800;
    --shadow: 0 2px 12px rgba(184, 149, 106, 0.12);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* === LANDING (minimale) === */
.landing {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    background: linear-gradient(135deg, var(--primary-light), var(--bg));
}

.landing-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 3rem 2.5rem;
    max-width: 480px;
    width: 100%;
    box-shadow: var(--shadow);
    text-align: center;
}

.landing-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.landing-title {
    font-size: 1.8rem;
    color: var(--primary-dark);
    margin-bottom: 0.4rem;
    font-weight: 700;
}

.landing-subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
    line-height: 1.5;
}

.landing-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.landing-btn {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.landing-btn-primary {
    background: var(--primary);
    color: white;
}

.landing-btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(124, 94, 186, 0.3);
}

.landing-btn-secondary {
    background: var(--bg);
    color: var(--text);
    border-color: var(--border);
}

.landing-btn-secondary:hover {
    border-color: var(--primary);
    background: var(--bg-card);
    transform: translateY(-1px);
}

.landing-btn-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    width: 2rem;
    text-align: center;
}

.landing-btn-text {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.landing-btn-text strong {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.3;
}

.landing-btn-text small {
    font-size: 0.75rem;
    opacity: 0.8;
    line-height: 1.3;
}

.landing-btn-secondary .landing-btn-text small {
    opacity: 0.65;
}

.landing-footer {
    margin-top: 1.5rem;
    font-size: 0.8rem;
}

.landing-footer a {
    color: var(--text-muted);
    text-decoration: none;
}

.landing-footer a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* === TEMA OVERLAY COERENTI === */
:root, .theme-soft {
    --overlay-gradient: linear-gradient(0deg, rgba(156,124,186,0.88) 0%, rgba(156,124,186,0.15) 60%, transparent 100%);
    --overlay-header: linear-gradient(180deg, rgba(156,124,186,0.80) 0%, transparent 100%);
    --overlay-text: #fff;
    --overlay-text-secondary: rgba(255,255,255,0.85);
    --reels-card-bg: linear-gradient(180deg, #dcc9ec 0%, #ece1f6 55%, #f7f0fa 100%);
    --reels-media-bg: #efe8f6;
    --stage-chip-bg: rgba(255,255,255,0.92);
    --stage-chip-text: #7b5ea7;
}

.theme-nature {
    --overlay-gradient: linear-gradient(0deg, rgba(107,143,94,0.88) 0%, rgba(107,143,94,0.15) 60%, transparent 100%);
    --overlay-header: linear-gradient(180deg, rgba(107,143,94,0.80) 0%, transparent 100%);
    --reels-card-bg: linear-gradient(180deg, #c4dbb6 0%, #dde9d2 55%, #f4f7f2 100%);
    --reels-media-bg: #e6efe1;
    --stage-chip-bg: rgba(255,255,255,0.92);
    --stage-chip-text: #4a6b3e;
}

.theme-elegant {
    --overlay-gradient: linear-gradient(0deg, rgba(184,149,106,0.88) 0%, rgba(184,149,106,0.15) 60%, transparent 100%);
    --overlay-header: linear-gradient(180deg, rgba(184,149,106,0.80) 0%, transparent 100%);
    --reels-card-bg: linear-gradient(180deg, #e8d5bc 0%, #f1e6d7 55%, #faf8f5 100%);
    --reels-media-bg: #f4ecdf;
    --stage-chip-bg: rgba(255,255,255,0.92);
    --stage-chip-text: #8a6e4a;
}

/* === REELS (TikTok-style timeline) - MOBILE ONLY === */
.reels-view {
    display: block;
}

.reels-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 4.2rem 1rem 0.75rem;
    background: var(--overlay-header);
    color: var(--overlay-text);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.reels-header-visible {
    opacity: 1;
}

.reels-header h1 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.1rem;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.reels-subtitle {
    font-size: 0.85rem;
    opacity: 0.9;
}

.reels-container {
    height: 100dvh;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    overscroll-behavior-y: contain;
}

.reels-container::-webkit-scrollbar {
    display: none;
}

.reels-card {
    height: 100dvh;
    scroll-snap-align: start;
    position: relative;
    background: var(--reels-card-bg, #000);
    overflow: hidden;
}

.reels-card.hidden {
    display: none;
}

/* Schermata home in apertura della timeline */
.reels-card.reels-intro {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    background: var(--reels-card-bg, #000);
}

.reels-intro-content {
    max-width: 30rem;
    animation: introFade 0.8s ease both;
}

@keyframes introFade {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.reels-intro-icon {
    font-size: 4rem;
    margin-bottom: 0.75rem;
}

.reels-intro-title {
    font-size: 1.7rem;
    line-height: 1.3;
    color: var(--primary-dark);
    font-weight: 700;
}

.reels-intro-title span {
    display: block;
    font-size: 2.2rem;
    font-weight: 800;
}

.reels-intro-subtitle {
    margin-top: 1rem;
    font-size: 1.05rem;
    color: var(--text);
    opacity: 0.85;
    line-height: 1.5;
}

.reels-intro-link {
    display: inline-block;
    margin-top: 1.5rem;
    padding: 0.65rem 1.4rem;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    box-shadow: var(--shadow);
    transition: background 0.2s, transform 0.2s;
}

.reels-intro-link:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

/* Pagina contributors */
.contributors-page {
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem 1rem;
}

.contributors-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    max-width: 560px;
    width: 100%;
    margin-top: 2rem;
}

.contributors-card h1 {
    color: var(--primary-dark);
    font-size: 1.4rem;
    margin-bottom: 0.25rem;
    text-align: center;
}

.contributors-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

.contributors-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.contributor-item {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
}

.contributor-avatar {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.05rem;
}

.contributor-info {
    flex: 1;
    min-width: 0;
}

.contributor-info strong {
    display: block;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contributor-info small {
    color: var(--text-muted);
}

.contributor-back {
    display: block;
    margin-top: 1.5rem;
    text-align: center;
    color: var(--primary-dark);
    text-decoration: none;
    font-weight: 600;
}

.contributor-back:hover {
    text-decoration: underline;
}

.reels-media {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--reels-media-bg, #111);
}

.reels-photo img,
.reels-video video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Overlay fisso sul bordo viewport (non scrolla con le card) */
.reels-overlay-fixed {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    padding: 4rem 1rem calc(1.5rem + env(safe-area-inset-bottom, 0.5rem));
    background: var(--overlay-gradient);
    color: var(--overlay-text);
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.reels-overlay-author {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.15rem;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.reels-overlay-caption {
    font-size: 0.85rem;
    font-weight: 400;
    margin-bottom: 0.2rem;
    opacity: 0.9;
    line-height: 1.3;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
    font-style: italic;
}

.reels-overlay-message {
    font-size: 0.9rem;
    line-height: 1.4;
    margin-bottom: 0.25rem;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
    opacity: 0.95;
}

.reels-overlay-meta {
    font-size: 0.8rem;
    opacity: 0.75;
    display: flex;
    gap: 0.5rem;
}

/* Play button for videos */
.reels-play-btn {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: white;
    cursor: pointer;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
    z-index: 10;
    pointer-events: auto;
    background: radial-gradient(circle, rgba(0,0,0,0.45) 0%, rgba(0,0,0,0.12) 42%, transparent 70%);
    transition: background 0.2s;
}

.reels-play-btn:hover {
    background: rgba(0,0,0,0.25);
}

/* Counter in alto a destra (sopra il fixed overlay) */
.reels-counter {
    position: fixed;
    top: calc(3.4rem + env(safe-area-inset-top, 0rem));
    right: 1rem;
    z-index: 100;
    background: rgba(0,0,0,0.5);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    backdrop-filter: blur(4px);
}

/* === COMPRESS STATUS SPINNER === */
.compress-status {
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #e3f2fd;
    border-radius: var(--radius-sm);
    color: #1565c0;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid #90caf9;
    border-top-color: #1565c0;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    flex-shrink: 0;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === UPLOAD === */
.upload-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, var(--primary-light), var(--bg));
}

.upload-container {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 600px;
    width: 100%;
    box-shadow: var(--shadow);
}

.upload-header { text-align: center; margin-bottom: 2rem; }
.upload-header h1 { color: var(--primary-dark); }
.upload-header .subtitle { color: var(--text-muted); }

.upload-success {
    text-align: center;
    padding: 2rem;
}

.success-icon { font-size: 4rem; margin-bottom: 1rem; }

/* === FORMS === */
.form-group { margin-bottom: 1.25rem; }

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: border-color 0.2s;
    background: white;
}

.form-control:focus { outline: none; border-color: var(--primary); }

.form-hint {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
    font-style: italic;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.file-dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.file-dropzone:hover,
.file-dropzone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.dropzone-icon { font-size: 3rem; display: block; margin-bottom: 0.5rem; }
.dropzone-hint { font-size: 0.85rem; color: var(--text-muted); }
.upload-tips {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    background: #fff8e1;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    line-height: 1.4;
}
.file-input { display: none; }

.preview-area {
    margin-top: 1rem;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.preview-area img, .preview-area video {
    max-width: 100%;
    max-height: 300px;
    display: block;
}

.progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    margin-top: 1rem;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s;
}

/* === BUTTONS === */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    text-align: center;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }

.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline { background: transparent; border: 2px solid var(--border); }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }
.btn-lg { padding: 1rem 2rem; }
.w-100 { width: 100%; }

/* === ALERTS === */
.alert {
    padding: 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
}

.alert-error { background: #ffebee; color: var(--danger); border: 1px solid #ffcdd2; }

/* === EMPTY STATE === */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.empty-state h2 { color: var(--text); margin-bottom: 0.5rem; }

/* === ADMIN LAYOUT === */
.admin-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

.admin-nav {
    background: white;
    padding: 2rem;
    border-right: 1px solid var(--border);
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.admin-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.admin-nav h2 { color: var(--primary-dark); }

.admin-nav ul { list-style: none; margin-top: 2rem; }

.admin-nav li { margin-bottom: 0.5rem; }

.admin-nav a {
    display: block;
    padding: 0.5rem 1rem;
    text-decoration: none;
    color: var(--text);
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.admin-nav a:hover { background: var(--primary-light); }
.admin-nav a.active { background: var(--primary); color: white; }

.admin-content {
    padding: 2rem;
    max-width: 1000px;
}

/* Hamburger toggle button */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.6rem;
    cursor: pointer;
    color: var(--primary-dark);
    padding: 0.25rem;
    line-height: 1;
    user-select: none;
}

/* Mobile: hamburger visibile, nav collassabile */
@media (max-width: 768px) {
    .admin-layout {
        grid-template-columns: 1fr;
    }

    .admin-nav {
        height: auto;
        padding: 0.75rem 1rem;
        position: sticky;
        top: 0;
        z-index: 100;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .admin-nav-header {
        width: 100%;
    }

    .admin-nav h2 {
        margin-bottom: 0;
        font-size: 1rem;
    }

    .nav-toggle {
        display: block;
    }

    .admin-nav ul {
        display: none;
        margin-top: 0.75rem;
        padding-top: 0.75rem;
        border-top: 1px solid var(--border);
    }

    .admin-nav ul.open {
        display: block;
    }

    .admin-content {
        padding: 1rem;
    }
}

.admin-content h1 { color: var(--primary-dark); margin-bottom: 0.5rem; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-value { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.85rem; color: var(--text-muted); }

.stat-card.pending .stat-value { color: var(--pending); }
.stat-card.approved .stat-value { color: var(--success); }
.stat-card.rejected .stat-value { color: var(--danger); }

/* === MEMORIES LIST === */
.memories-list { margin-top: 1rem; }

.memory-row {
    background: white;
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    transition: background 0.3s;
}

.memory-row.highlight { background: #fff3e0; }

.memory-info { flex: 1; }
.memory-info strong { display: block; margin-bottom: 0.25rem; }
.memory-info p { color: var(--text-muted); font-size: 0.9rem; }
.memory-info small { display: block; color: var(--text-muted); font-size: 0.8rem; margin-top: 0.25rem; }

.memory-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

/* === BADGES === */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge.pending { background: #fff3e0; color: var(--pending); }
.badge.approved { background: #e8f5e9; color: var(--success); }
.badge.rejected { background: #ffebee; color: var(--danger); }

/* === ADMIN LOGIN === */
.admin-login {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}

.login-card {
    background: white;
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 400px;
    width: 100%;
    box-shadow: var(--shadow);
}

.login-card h1 { text-align: center; margin-bottom: 2rem; color: var(--primary-dark); }

/* === FILTER BAR === */
.filter-bar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* === DESKTOP VIEW (≥769px) — griglia per categorie + carosello === */
.desktop-view {
    display: none;
}

.desktop-header {
    text-align: center;
    padding: 2.5rem 2rem 0.5rem;
    position: relative;
}

.desktop-header h1 {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--primary-dark);
    margin-bottom: 0.25rem;
}

.desktop-header p {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

/* Life stage filter tabs on desktop */
.desktop-nav {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.desktop-nav .stage-btn {
    padding: 0.5rem 1rem;
    border-radius: 24px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.desktop-nav .stage-btn:hover {
    border-color: var(--primary);
    color: var(--primary-dark);
}

.desktop-nav .stage-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Category rows */
.desktop-categories {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 2rem 3rem;
}

.category-row {
    margin-bottom: 2.5rem;
}

.category-row:last-child {
    margin-bottom: 0;
}

.category-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.category-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
}

.category-count {
    font-size: 0.85rem;
    color: var(--text-muted);
    background: var(--border);
    padding: 0.15rem 0.6rem;
    border-radius: 12px;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

.grid-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    background: var(--bg-card);
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.grid-item:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.grid-item .grid-video-badge {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 0.15rem 0.4rem;
    border-radius: 6px;
    font-size: 0.7rem;
    backdrop-filter: blur(4px);
}

.grid-more-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
    border: none;
    background: none;
}

.grid-more-btn:hover {
    background: var(--primary-light);
}

.category-empty {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-style: italic;
}
/* === CAROUSEL MODAL (desktop) === */
.carousel-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0,0,0,0.92);
    backdrop-filter: blur(12px);
    align-items: center;
    justify-content: center;
}

.carousel-overlay.open {
    display: flex;
}

.carousel-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 3rem 4rem;
}

.carousel-slide {
    position: relative;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}

.carousel-slide img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    display: block;
    border-radius: var(--radius);
}

.carousel-slide video {
    max-width: 100%;
    max-height: 80vh;
    display: block;
    border-radius: var(--radius);
}

/* Bottom info in carousel */
.carousel-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2.5rem 1rem 1rem;
    background: linear-gradient(0deg, rgba(0,0,0,0.7) 0%, transparent 100%);
    color: white;
    text-align: center;
}

.carousel-author {
    font-size: 1rem;
    font-weight: 700;
    display: block;
    margin-bottom: 0.15rem;
}

.carousel-caption {
    font-size: 0.85rem;
    opacity: 0.85;
    display: block;
    font-style: italic;
}

/* Navigation buttons */
.carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.15);
    color: white;
    font-size: 2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 10;
    backdrop-filter: blur(8px);
}

.carousel-nav:hover {
    background: rgba(255,255,255,0.3);
}

.carousel-prev { left: 1rem; }
.carousel-next { right: 1rem; }

.carousel-close {
    position: fixed;
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.15);
    color: white;
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    transition: background 0.2s;
    backdrop-filter: blur(8px);
}

.carousel-close:hover {
    background: rgba(255,255,255,0.3);
}

.carousel-counter {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.5);
    color: white;
    padding: 0.35rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    backdrop-filter: blur(8px);
    z-index: 1001;
}

.carousel-hint {
    position: fixed;
    bottom: 3.5rem;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.4);
    font-size: 0.75rem;
    z-index: 1001;
    pointer-events: none;
}

/* Desktop min-width breakpoint to hide reels, show grid */
@media (min-width: 769px) {
    .reels-view { display: none; }
    .desktop-view { display: block; }
}

/* Mobile responsive overrides */
@media (max-width: 768px) {
    .form-row { grid-template-columns: 1fr; }
    .landing-title { font-size: 1.8rem; }
    .timeline-header h1 { font-size: 1.5rem; }
    .age-memories { padding-left: 1.5rem; }
    .memory-row { flex-direction: column; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* === DEBUG ERROR DISPLAY === */
.debug-error-container {
    background: #1a1a2e;
    color: #f0f0f0;
    font-family: 'Consolas', 'Courier New', monospace;
    padding: 2rem;
    margin: 1rem;
    border-radius: var(--radius);
    border: 2px solid #ff4444;
    max-width: 100%;
    overflow-x: auto;
}

.debug-error-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #ff4444;
}

.debug-error-header h1,
.debug-error-header h2 {
    color: #ff6b6b;
    font-size: 1.5rem;
    margin: 0 0 0.5rem 0;
}

.debug-error-header p {
    color: #aaa;
    font-size: 0.9rem;
}

.debug-error-section {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #16213e;
    border-radius: var(--radius-sm);
}

.debug-error-section h3 {
    color: #ffa500;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

.debug-error-section pre {
    color: #e0e0e0;
    font-size: 0.8rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
    overflow-x: auto;
    max-height: 300px;
    overflow-y: auto;
    background: #0f3460;
    padding: 0.75rem;
    border-radius: 4px;
    border-left: 3px solid #ff4444;
}

.debug-error-section hr {
    border: none;
    border-top: 1px solid #333;
    margin: 1rem 0;
}

/* === ADMIN CREATE EVENT & SHARE LINKS === */
.event-details-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    margin: 1rem 0;
}

.event-details-card h3 {
    color: var(--primary-dark);
    margin-bottom: 1rem;
}

.event-details-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
}

.event-details-table th {
    text-align: left;
    padding: 0.5rem 1rem 0.5rem 0;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.9rem;
    width: 120px;
}

.event-details-table td {
    padding: 0.5rem 0;
}

.event-details-table code {
    background: #f5f5f5;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
}

.share-links {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 1rem 0;
}

.share-link-card {
    background: #f8f9fa;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
}

.share-link-card h4 {
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.share-link-card .link-description {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.link-copy {
    display: flex;
    gap: 0.5rem;
}

.link-copy .form-control {
    flex: 1;
    font-size: 0.85rem;
    padding: 0.4rem 0.75rem;
    background: white;
}

/* Create event form */
.create-event-form {
    max-width: 500px;
    margin-top: 1.5rem;
}

.create-event-form .form-group {
    margin-bottom: 1.25rem;
}

.create-event-form .form-group small {
    display: block;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

.create-event-form label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--text);
}

/* Dashboard upload link */
.dashboard-upload-link {
    margin: 1rem 0;
}

/* === ALERTS === */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.alert-success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.alert-error {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

.alert h2 {
    font-size: 1.2rem;
    margin: 0;
}
/* === MASTER DASHBOARD === */
.master-layout {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

.master-header {
    text-align: center;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    color: white;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

.master-header h1 { font-size: 1.8rem; margin-bottom: 0.5rem; }
.master-header p { opacity: 0.8; font-size: 0.95rem; margin-bottom: 1rem; }

.master-nav {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.master-nav a {
    color: white;
    text-decoration: none;
    padding: 0.4rem 1rem;
    border-radius: 20px;
    background: rgba(255,255,255,0.1);
    font-size: 0.9rem;
    transition: background 0.2s;
}

.master-nav a:hover, .master-nav a.active { background: rgba(255,255,255,0.25); }
.master-nav a.active { font-weight: 600; }

.master-content {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.master-table-wrapper { overflow-x: auto; }

.master-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.master-table th {
    text-align: left;
    padding: 0.75rem 0.5rem;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.master-table td {
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.master-row:hover { background: #f8f9fa; }
.master-table .text-muted { font-size: 0.75rem; }

.link-group-small {
    display: flex;
    gap: 2px;
    margin-bottom: 2px;
}

.link-group-small input {
    flex: 1;
    min-width: 120px;
    max-width: 180px;
    font-size: 0.7rem;
    padding: 0.2rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #fafafa;
    cursor: pointer;
}

.link-group-small .btn {
    font-size: 0.7rem;
    padding: 0.2rem 0.4rem;
    min-width: 28px;
}

.action-cell {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
    align-items: center;
}

.action-cell .btn { font-size: 0.8rem; padding: 0.25rem 0.5rem; }

.pw-details {
    display: inline-block;
    position: relative;
}

.pw-details summary {
    cursor: pointer;
    list-style: none;
    display: inline-block;
}

.pw-details summary::-webkit-details-marker { display: none; }

.pw-details[open] .pw-form {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    position: absolute;
    right: 0;
    top: 100%;
    background: white;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    z-index: 10;
    white-space: nowrap;
}

.pw-form { display: none; }
.pw-form .form-control { width: 140px; font-size: 0.8rem; padding: 0.3rem 0.5rem; }
.pw-form .btn { font-size: 0.8rem; padding: 0.3rem 0.6rem; }

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state h2 { font-size: 1.3rem; margin-bottom: 0.5rem; color: var(--text); }

/* Theme badge in master table */
.theme-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    white-space: nowrap;
}

.theme-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.dot-soft { background: linear-gradient(135deg, #9c7cba, #d4c4e8); }
.dot-nature { background: linear-gradient(135deg, #6b8f5e, #c4dbb6); }
.dot-elegant { background: linear-gradient(135deg, #b8956a, #e8d5bc); }

.theme-details {
    display: inline-block;
    position: relative;
}

.theme-details summary {
    cursor: pointer;
    list-style: none;
    display: inline-block;
}

.theme-details summary::-webkit-details-marker { display: none; }

.theme-details[open] .theme-form {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    position: absolute;
    right: 0;
    top: 100%;
    background: white;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    z-index: 10;
    white-space: nowrap;
}

.theme-form { display: none; }
.theme-form select { width: 140px; font-size: 0.8rem; padding: 0.3rem 0.5rem; }
.theme-form .btn { font-size: 0.8rem; padding: 0.3rem 0.6rem; }

/* === PASSWORD REQUIREMENTS === */
.pw-requirements {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 1rem;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.pw-req {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    transition: color 0.2s, opacity 0.2s;
    opacity: 0.5;
}

.pw-req.valid {
    color: var(--success);
    opacity: 1;
}

.pw-req.invalid {
    color: var(--danger);
    opacity: 1;
}

/* === PREVIEW TIMELINE === */
.theme-preview {
    position: relative;
    width: 100%;
    max-width: 360px;
    height: 420px;
    margin: 0.5rem auto;
    border-radius: var(--radius);
    overflow: hidden;
    border: 2px solid var(--border);
    background: #111;
    /* Default soft pastel overlay */
    --preview-primary: #9c7cba;
    --preview-primary-dark: #7b5ea7;
}

.theme-preview.preview-theme-nature {
    --preview-primary: #6b8f5e;
    --preview-primary-dark: #4a6b3e;
}

.theme-preview.preview-theme-elegant {
    --preview-primary: #b8956a;
    --preview-primary-dark: #8a6e4a;
}

.preview-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    padding: 1rem 0.75rem 0.5rem;
    background: linear-gradient(180deg, rgba(0,0,0,0.8) 0%, transparent 100%);
    color: white;
    pointer-events: none;
}

.preview-header h3 {
    font-size: 1rem;
    margin: 0;
    line-height: 1.2;
}

.preview-header p {
    font-size: 0.75rem;
    margin: 0.15rem 0 0;
    opacity: 0.85;
    font-weight: 300;
}

.preview-reels-container {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    height: 100%;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.preview-reels-container::-webkit-scrollbar { display: none; }

.preview-card {
    flex: 0 0 100%;
    scroll-snap-align: start;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-media {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background: #222;
}

.preview-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.preview-play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #111;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.preview-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2rem 0.75rem 0.75rem;
    background: linear-gradient(0deg, rgba(0,0,0,0.75) 0%, transparent 100%);
    color: white;
}

.preview-author {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.preview-message {
    font-size: 0.8rem;
    opacity: 0.9;
    margin-bottom: 0.3rem;
    line-height: 1.3;
    font-style: italic;
}

.preview-meta {
    font-size: 0.7rem;
    opacity: 0.7;
}

/* === LIFE STAGES === */
.life-stage-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 120;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: calc(0.55rem + env(safe-area-inset-top, 0rem)) 0.75rem 0.55rem;
    background: linear-gradient(180deg, color-mix(in srgb, var(--primary-dark) 70%, transparent) 0%, transparent 100%);
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    white-space: nowrap;
}

.life-stage-nav::-webkit-scrollbar { display: none; }

.stage-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.35);
    background: rgba(255,255,255,0.18);
    color: #fff;
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    backdrop-filter: blur(6px);
}

.stage-btn:hover {
    background: rgba(255,255,255,0.3);
    color: #fff;
}

.stage-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.stage-count {
    display: inline-block;
    min-width: 1.25rem;
    text-align: center;
    padding: 0.05rem 0.35rem;
    border-radius: 10px;
    background: rgba(0,0,0,0.28);
    font-size: 0.65rem;
    font-weight: 600;
}

.stage-btn.active .stage-count {
    background: rgba(255,255,255,0.3);
}

.reels-stage {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    background: rgba(255,255,255,0.15);
    font-size: 0.7rem;
    margin-right: 0.3rem;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.1);
}

.reels-stage-indicator {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    background: rgba(0,0,0,0.6);
    color: white;
    font-size: 0.75rem;
    z-index: 100;
    backdrop-filter: blur(8px);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

/* Life stage preview on upload */
.life-stage-preview {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.life-stage-preview .badge {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    background: var(--primary-light);
    color: var(--primary-dark);
}

@media (max-width: 768px) {
    .master-table { font-size: 0.75rem; }
    .master-table td, .master-table th { padding: 0.5rem 0.3rem; }
    .link-group-small input { min-width: 80px; max-width: 120px; }
}