/* ===== SGD FOTO - STYLE ===== */
:root {
    --bg: #0d0718;
    --bg2: #130a24;
    --bg3: #1c1035;
    --surface: #1e1040;
    --surface2: #261450;
    --border: rgba(180, 80, 255, 0.2);
    --purple-deep: #1a0a2e;
    --purple: #6b21d6;
    --purple-bright: #8b3df5;
    --purple-light: #a855f7;
    --pink: #e91e8c;
    --pink-hot: #ff0f7b;
    --pink-light: #f472b6;
    --violet: #7c3aed;
    --glow-purple: rgba(139, 61, 245, 0.4);
    --glow-pink: rgba(233, 30, 140, 0.4);
    --text: #f0e8ff;
    --text-muted: #8b7aaa;
    --text-dim: #4a3a6a;
    --radius: 16px;
    --radius-sm: 10px;
    --radius-lg: 24px;
    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Space Grotesk', sans-serif;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --header-h: 60px;
    --nav-h: calc(64px + var(--safe-bottom));
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-font-smoothing: antialiased;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--purple); border-radius: 2px; }

/* ===== SCREENS ===== */
.screen {
    position: fixed;
    inset: 0;
    transition: opacity 0.4s ease, transform 0.4s ease;
}
.hidden { display: none !important; }
.fade-out { opacity: 0; pointer-events: none; }

/* ===== INSTALL BANNER ===== */
.install-banner {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 9999;
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    background: linear-gradient(135deg, rgba(107, 33, 214, 0.95), rgba(233, 30, 140, 0.95));
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    animation: slideDown 0.4s ease;
}
@keyframes slideDown { from { transform: translateY(-100%); } to { transform: translateY(0); } }
.install-banner-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 480px;
    margin: 0 auto;
}
.install-icon { width: 44px; height: 44px; border-radius: 10px; flex-shrink: 0; }
.install-text { flex: 1; }
.install-text strong { display: block; font-family: var(--font-display); font-size: 14px; color: #fff; }
.install-text span { font-size: 12px; color: rgba(255,255,255,0.8); }
.install-accept {
    background: #fff;
    color: var(--purple);
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}
.install-dismiss {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    flex-shrink: 0;
}

/* ===== LOGIN SCREEN ===== */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    overflow: hidden;
}
.login-bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    pointer-events: none;
}
.orb1 { width: 400px; height: 400px; background: rgba(107, 33, 214, 0.35); top: -100px; left: -100px; }
.orb2 { width: 350px; height: 350px; background: rgba(233, 30, 140, 0.25); bottom: -80px; right: -80px; }
.orb3 { width: 200px; height: 200px; background: rgba(139, 61, 245, 0.2); top: 50%; left: 50%; transform: translate(-50%,-50%); }
.login-container {
    width: 100%;
    max-width: 380px;
    padding: 32px 24px;
    position: relative;
    z-index: 1;
}
.login-logo {
    text-align: center;
    margin-bottom: 48px;
}
.login-logo img {
    width: 90px;
    height: 90px;
    border-radius: 22px;
    margin-bottom: 16px;
    box-shadow: 0 8px 32px rgba(139, 61, 245, 0.5), 0 0 60px rgba(233, 30, 140, 0.2);
    animation: logoPulse 3s ease-in-out infinite;
}
@keyframes logoPulse {
    0%, 100% { box-shadow: 0 8px 32px rgba(139, 61, 245, 0.5), 0 0 60px rgba(233, 30, 140, 0.2); }
    50% { box-shadow: 0 8px 48px rgba(139, 61, 245, 0.8), 0 0 80px rgba(233, 30, 140, 0.4); }
}
.login-logo h1 {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.5px;
}
.login-logo h1 span {
    background: linear-gradient(135deg, var(--purple-light), var(--pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.login-logo p {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 6px;
}
.login-form { display: flex; flex-direction: column; gap: 16px; }
.input-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}
.input-group input {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.input-group input:focus {
    border-color: var(--purple-bright);
    box-shadow: 0 0 0 3px rgba(139, 61, 245, 0.2);
}
.input-group input::placeholder { color: var(--text-dim); }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 50px; }
.pw-toggle {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    opacity: 0.6;
}
.login-error {
    background: rgba(255, 50, 100, 0.15);
    border: 1px solid rgba(255, 50, 100, 0.3);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 13px;
    color: #ff6b9d;
    text-align: center;
}
.btn-login {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--purple), var(--pink));
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 8px;
    transition: opacity 0.2s, transform 0.1s, box-shadow 0.2s;
    box-shadow: 0 4px 24px rgba(139, 61, 245, 0.4);
}
.btn-login:hover { box-shadow: 0 4px 32px rgba(139, 61, 245, 0.6); }
.btn-login:active { transform: scale(0.98); }
.btn-login svg { width: 18px; height: 18px; }

/* ===== APP SCREEN ===== */
.app-screen {
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

/* ===== HEADER ===== */
.app-header {
    height: var(--header-h);
    padding: 0 20px;
    padding-top: env(safe-area-inset-top, 0px);
    background: rgba(13, 7, 24, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    z-index: 100;
}
.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}
.header-logo img {
    width: 32px;
    height: 32px;
    border-radius: 8px;
}
.header-logo span {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}
.header-logo span b {
    background: linear-gradient(135deg, var(--purple-light), var(--pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.header-actions { display: flex; gap: 8px; }
.header-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s, background 0.2s;
}
.header-btn:hover { color: var(--text); background: var(--surface2); }
.header-btn svg { width: 18px; height: 18px; }

/* ===== MAIN ===== */
.app-main {
    flex: 1;
    overflow: hidden;
    position: relative;
}
.tab-content {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.tab-content.active { display: block; }

/* ===== CAMERA ===== */
.camera-container {
    height: 100%;
    background: #000;
    position: relative;
    overflow: hidden;
}
.camera-preview-wrap {
    position: absolute;
    inset: 0;
    background: #000;
}
#cameraFeed {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.camera-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
}
.camera-corners { position: absolute; inset: 20px; }
.corner {
    position: absolute;
    width: 24px;
    height: 24px;
    border-color: rgba(255,255,255,0.6);
    border-style: solid;
}
.corner.tl { top: 0; left: 0; border-width: 2px 0 0 2px; border-radius: 4px 0 0 0; }
.corner.tr { top: 0; right: 0; border-width: 2px 2px 0 0; border-radius: 0 4px 0 0; }
.corner.bl { bottom: 0; left: 0; border-width: 0 0 2px 2px; border-radius: 0 0 0 4px; }
.corner.br { bottom: 0; right: 0; border-width: 0 2px 2px 0; border-radius: 0 0 4px 0; }
.camera-flash {
    position: absolute;
    inset: 0;
    background: white;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.1s;
}
.camera-flash.flash { opacity: 1; }
.rec-indicator {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.7);
    border: 1px solid rgba(255,50,50,0.5);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 13px;
    font-family: var(--font-display);
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 6px;
    backdrop-filter: blur(10px);
}
.rec-dot {
    width: 8px; height: 8px;
    background: #ff3333;
    border-radius: 50%;
    animation: recPulse 1s ease-in-out infinite;
}
@keyframes recPulse { 0%,100%{opacity:1} 50%{opacity:0.3} }

.camera-controls {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    z-index: 10;
    padding: 16px 20px;
    padding-bottom: calc(16px + var(--safe-bottom));
    background: linear-gradient(to top, rgba(10,5,20,0.85) 0%, rgba(10,5,20,0.5) 70%, transparent 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.cam-ctrl-btn {
    width: 48px; height: 48px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s, background 0.2s;
    flex-shrink: 0;
}
.cam-ctrl-btn:hover { color: var(--text); background: var(--surface2); }
.cam-ctrl-btn svg { width: 20px; height: 20px; }
.cam-center-controls { display: flex; align-items: center; justify-content: center; flex: 1; }
.cam-shoot-btn {
    width: 72px; height: 72px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    padding: 4px;
    background: conic-gradient(var(--purple), var(--pink), var(--purple));
    box-shadow: 0 0 24px rgba(139, 61, 245, 0.5), 0 0 48px rgba(233, 30, 140, 0.3);
    transition: transform 0.1s, box-shadow 0.2s;
}
.cam-shoot-btn:active { transform: scale(0.92); }
.shoot-inner {
    display: block;
    width: 100%;
    height: 100%;
    background: #fff;
    border-radius: 50%;
}
.video-inner { background: #ff3333 !important; }
.cam-shoot-btn.recording {
    background: conic-gradient(#ff3333, #ff6666, #ff3333);
    box-shadow: 0 0 24px rgba(255, 51, 51, 0.6);
}
.cam-mode-toggle {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}
.mode-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.mode-btn.active {
    background: linear-gradient(135deg, var(--purple), var(--pink));
    border-color: transparent;
    color: #fff;
    font-weight: 600;
}
/* upload row removed — upload is now in the bottom nav */
.upload-label {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 20px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.upload-label:hover {
    background: var(--surface2);
    color: var(--text);
    border-color: var(--purple-bright);
}
.upload-label svg { width: 18px; height: 18px; }

/* ===== GALLERY ===== */
.gallery-header {
    padding: 20px 16px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: rgba(13, 7, 24, 0.95);
    backdrop-filter: blur(16px);
    z-index: 10;
    border-bottom: 1px solid var(--border);
}
.gallery-header h2 {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--purple-light), var(--pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.gallery-count {
    font-size: 13px;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 12px;
}
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    padding: 2px;
    padding-bottom: calc(var(--nav-h) + 8px);
}
.gallery-item {
    aspect-ratio: 1;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    background: var(--surface);
}
.gallery-item:hover .gallery-item-overlay { opacity: 1; }
.gallery-item img, .gallery-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s;
}
.gallery-item:hover img, .gallery-item:hover video { transform: scale(1.05); }
.gallery-item-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.3);
    opacity: 0;
    transition: opacity 0.2s;
}
.gallery-item-badge {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(0,0,0,0.7);
    border-radius: 6px;
    padding: 3px 6px;
    font-size: 10px;
    color: #fff;
    font-weight: 600;
}
.gallery-item-date {
    position: absolute;
    bottom: 6px;
    left: 6px;
    font-size: 9px;
    color: rgba(255,255,255,0.7);
    font-weight: 500;
}
.gallery-loader {
    display: flex;
    justify-content: center;
    padding: 24px;
}
.gallery-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    color: var(--text-dim);
    gap: 16px;
    text-align: center;
}
.gallery-empty svg { width: 56px; height: 56px; opacity: 0.4; }
.gallery-empty p { font-size: 15px; line-height: 1.6; }
.spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--surface2);
    border-top-color: var(--purple-bright);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== BOTTOM NAV ===== */
.bottom-nav {
    height: var(--nav-h);
    display: flex;
    background: rgba(13, 7, 24, 0.97);
    backdrop-filter: blur(24px);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    padding-bottom: var(--safe-bottom);
}
.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-dim);
    font-size: 11px;
    font-family: var(--font-body);
    font-weight: 500;
    transition: color 0.2s;
    padding: 8px 0;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}
.nav-btn svg { width: 22px; height: 22px; }
.nav-btn.active { color: var(--purple-light); }
.nav-btn.active svg { filter: drop-shadow(0 0 8px rgba(168, 85, 247, 0.6)); }

/* ===== LIGHTBOX ===== */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.95);
}
.lightbox-content {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 900px;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}
#lightboxMedia {
    max-width: 100%;
    max-height: calc(100vh - 100px);
    display: flex;
    align-items: center;
    justify-content: center;
}
#lightboxMedia img {
    max-width: 100vw;
    max-height: calc(100vh - 100px);
    object-fit: contain;
    border-radius: 4px;
}
#lightboxMedia video {
    max-width: 100vw;
    max-height: calc(100vh - 100px);
    border-radius: 4px;
}
.lightbox-close {
    position: absolute;
    top: 16px; right: 16px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    border-radius: 50%;
    width: 40px; height: 40px;
    font-size: 18px;
    cursor: pointer;
    z-index: 10;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(10px);
}
.lightbox-prev, .lightbox-next {
    position: absolute;
    top: 50%; transform: translateY(-50%);
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    border-radius: 50%;
    width: 44px; height: 44px;
    font-size: 24px;
    cursor: pointer;
    backdrop-filter: blur(10px);
    display: flex; align-items: center; justify-content: center;
    z-index: 10;
}
.lightbox-prev { left: 12px; }
.lightbox-next { right: 12px; }
.lightbox-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px 20px;
    padding-bottom: calc(12px + var(--safe-bottom));
}
#lightboxDate { font-size: 13px; color: rgba(255,255,255,0.5); }
.lightbox-delete {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,50,80,0.15);
    border: 1px solid rgba(255,50,80,0.3);
    color: #ff6b7a;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}
.lightbox-delete:hover { background: rgba(255,50,80,0.3); }
.lightbox-delete svg { width: 16px; height: 16px; }

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: calc(var(--nav-h) + 12px);
    left: 50%;
    transform: translateX(-50%) translateY(0);
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px 20px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    z-index: 2000;
    white-space: nowrap;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    backdrop-filter: blur(20px);
    animation: toastIn 0.3s ease;
    max-width: 80vw;
    text-align: center;
}
@keyframes toastIn { from { opacity:0; transform:translateX(-50%) translateY(10px); } to { opacity:1; transform:translateX(-50%) translateY(0); } }

/* ===== UPLOAD PROGRESS ===== */
.upload-progress {
    position: fixed;
    bottom: calc(var(--nav-h) + 56px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 16px;
    z-index: 2001;
    width: 240px;
    text-align: center;
    backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.upload-progress-bar {
    height: 4px;
    background: var(--surface);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}
.upload-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--purple), var(--pink));
    border-radius: 2px;
    transition: width 0.3s;
    width: 0%;
}
#uploadProgressText { font-size: 12px; color: var(--text-muted); }

/* ===== RESPONSIVE ===== */
@media (min-width: 600px) {
    .gallery-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 900px) {
    .gallery-grid { grid-template-columns: repeat(5, 1fr); }
    .camera-container { max-width: 600px; margin: 0 auto; }
}
