:root {
    --bg: #141414;
    --bg-elev: #1f1f1f;
    --bg-elev-2: #2a2a2a;
    --text: #f5f5f5;
    --muted: #a0a0a0;
    --accent: #e50914;
    --accent-hover: #f6121d;
    --border: #303030;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    --radius: 6px;
}

/* ========== THEMES (Wave 4) ========== */
/* Default Netflix red is in :root above. Other themes override variables here. */

body.theme-amoled-black {
    --bg: #000000;
    --bg-elev: #0a0a0a;
    --bg-elev-2: #141414;
    --text: #f5f5f5;
    --muted: #888;
    --accent: #4dd0e1;
    --accent-hover: #6df0ff;
    --border: #1a1a1a;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.95);
}

body.theme-cyberpunk {
    --bg: #0a0a1f;
    --bg-elev: #14143a;
    --bg-elev-2: #1c1c4a;
    --text: #e0f7fa;
    --muted: #7e7eb5;
    --accent: #ff00ff;
    --accent-hover: #ff66ff;
    --border: #3a3a6a;
    --shadow: 0 8px 24px rgba(255, 0, 255, 0.25), 0 0 40px rgba(0, 255, 255, 0.1);
}
body.theme-cyberpunk .brand-main { text-shadow: 0 0 12px rgba(255, 0, 255, 0.8), 0 0 24px rgba(0, 255, 255, 0.4); }

body.theme-minimal-glass {
    --bg: #0f1419;
    --bg-elev: rgba(40, 50, 60, 0.5);
    --bg-elev-2: rgba(60, 70, 80, 0.6);
    --text: #f5f5f5;
    --muted: #a0b0c0;
    --accent: #ffd700;
    --accent-hover: #ffe552;
    --border: rgba(255, 255, 255, 0.12);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}
body.theme-minimal-glass .topnav,
body.theme-minimal-glass .admin-section,
body.theme-minimal-glass .card,
body.theme-minimal-glass .hamburger-menu {
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

body.theme-color-shift {
    --bg: #0a0a0a;
    --bg-elev: #18141c;
    --bg-elev-2: #221a26;
    --text: #f5f5f5;
    --muted: #b0a0b8;
    --accent: #ff5e9c;
    --accent-hover: #ff8cb8;
    --border: #2a1a30;
    animation: colorShiftAccent 12s ease-in-out infinite;
}
@keyframes colorShiftAccent {
    0%   { --accent: #ff5e9c; --accent-hover: #ff8cb8; }
    20%  { --accent: #ff9a3c; --accent-hover: #ffba6c; }
    40%  { --accent: #ffd93d; --accent-hover: #ffe66d; }
    60%  { --accent: #6bcf7f; --accent-hover: #94e0a4; }
    80%  { --accent: #4d9de0; --accent-hover: #76b6e8; }
    100% { --accent: #ff5e9c; --accent-hover: #ff8cb8; }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font-family: inherit; }

/* ---------- Top nav (full-width header — sidebar sits BELOW it) ---------- */
.topnav {
    position: sticky;
    top: 0;
    z-index: 60;       /* above sidebar */
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 4vw;
    background: linear-gradient(to bottom, rgba(0,0,0,0.92), rgba(0,0,0,0.55));
    backdrop-filter: blur(6px);
    height: 70px;
    box-sizing: border-box;
}
.brand,
.brand *,
.profile-pill-btn,
.profile-pill-btn * {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;            /* iOS Safari: no link callout */
    -webkit-tap-highlight-color: transparent;
}
.brand {
    display: inline-flex;
    flex-direction: column;
    line-height: 1;
    cursor: pointer;
}
.brand-main {
    font-weight: 900;
    font-size: 1.7rem;
    color: var(--accent);
    letter-spacing: 0.05em;
    text-shadow: 0 2px 8px rgba(229, 9, 20, 0.35);
}
.brand-sub {
    margin-top: 4px;
    font-size: 0.78rem;
    color: var(--muted);
    letter-spacing: 0.06em;
    font-weight: 500;
}
.brand-heart {
    color: var(--accent);
    display: inline-block;
    animation: heartbeat 1.6s ease-in-out infinite;
}
@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    25%      { transform: scale(1.18); }
    50%      { transform: scale(1); }
    75%      { transform: scale(1.12); }
}

.nav-actions {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
}
.hamburger {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 0;
    transition: background 0.15s;
}
.hamburger:hover { background: rgba(255,255,255,0.1); }
.hamburger span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
}
.hamburger-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 180px;
    background: #181818;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.65);
    padding: 6px;
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity 0.15s, transform 0.15s;
    z-index: 60;
}
.hamburger-menu.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.hamburger-menu a,
.hamburger-menu button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 14px;
    background: none;
    border: none;
    color: var(--text);
    font-size: 0.95rem;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
}
.hamburger-menu a:hover,
.hamburger-menu button:hover {
    background: rgba(255,255,255,0.08);
}
.hamburger-menu form { margin: 0; }

.main { min-height: 70vh; }
@media (max-width: 720px) {
    .brand-main { font-size: 1.35rem; }
    .brand-sub { font-size: 0.7rem; }
}

/* ---------- Date view ---------- */
.date-shell {
    max-width: 1500px;
    margin: 0 auto;
    padding: 24px 4vw 60px;
}
.date-header h1 { margin: 6px 0; font-size: 2rem; }
.date-layout {
    display: grid;
    grid-template-columns: 1fr 220px;
    gap: 28px;
    margin-top: 24px;
}
@media (max-width: 900px) {
    .date-layout { grid-template-columns: 1fr; }
    .date-scrubber { display: none; }   /* hide on phones */
}
.date-section {
    margin-bottom: 36px;
    scroll-margin-top: 90px;   /* so anchor jumps don't hide under sticky topnav */
}
.date-section-title {
    margin: 0 0 12px;
    font-size: 1.25rem;
    font-weight: 600;
    border-left: 4px solid var(--accent);
    padding-left: 10px;
}
.date-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 6px;
}
.date-tile {
    position: relative;
    aspect-ratio: 1 / 1;
    background: var(--bg-elev);
    border-radius: 4px;
    overflow: hidden;
    transition: transform 0.15s, outline-color 0.15s;
    outline: 2px solid transparent;
}
.date-tile:hover { transform: scale(1.04); z-index: 2; outline-color: var(--accent); }
.date-tile img { width: 100%; height: 100%; object-fit: cover; }
.date-tile.estimated-date::before {
    /* Subtle indicator that this date is the upload-time fallback, not real EXIF */
    content: "~";
    position: absolute;
    top: 4px;
    left: 6px;
    color: rgba(255,255,255,0.55);
    font-size: 0.85rem;
    z-index: 2;
    text-shadow: 0 1px 4px rgba(0,0,0,0.7);
}
.date-tile-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(0,0,0,0.6);
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    pointer-events: none;
}

/* Year/month scrubber (right rail) */
.date-scrubber {
    position: sticky;
    top: 80px;
    align-self: start;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    background: rgba(20,20,20,0.5);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 12px;
    font-size: 0.92rem;
}
.scr-year { margin-bottom: 8px; }
.scr-year-toggle {
    background: none;
    border: none;
    color: var(--text);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    padding: 4px 8px;
    width: 100%;
    text-align: left;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}
.scr-year-toggle:hover { background: rgba(255,255,255,0.06); }
.scr-year-toggle.active { color: var(--accent); }
.scr-months {
    list-style: none;
    margin: 4px 0 0;
    padding-left: 14px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
    max-height: 1000px;
    transition: max-height 0.25s;
}
.scr-year.collapsed .scr-months { max-height: 0; }
.scr-months a {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
    padding: 4px 8px;
    border-radius: 4px;
    text-decoration: none;
    transition: color 0.15s, background 0.15s;
}
.scr-months a:hover { color: var(--text); background: rgba(255,255,255,0.06); }

/* ---------- Top navigation pills (Wave 6) ---------- */
.page-tabs {
    position: sticky;
    top: 70px;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 6px 4vw;
    background: linear-gradient(to bottom, rgba(0,0,0,0.85), rgba(0,0,0,0.45));
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    overflow-x: auto;
    scrollbar-width: none;     /* hide scrollbar on Firefox */
    white-space: nowrap;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.page-tabs::-webkit-scrollbar { display: none; }
.ptab {
    position: relative;
    color: var(--muted);
    text-decoration: none;
    padding: 8px 14px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.15s;
    border-radius: 6px;
    flex: 0 0 auto;
}
.ptab:hover { color: var(--text); }
.ptab.active {
    color: var(--text);
    font-weight: 600;
}
/* Subtle accent underline on the active tab — cleaner than a full pill background */
.ptab.active::after {
    content: '';
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 2px;
    height: 2px;
    background: var(--accent);
    border-radius: 2px;
}
.ptab-icon {
    margin-left: auto;        /* push search icon to the right end */
    padding: 8px 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    border-radius: 6px;
}
.ptab-icon:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.ptab-icon.active { color: var(--accent); background: rgba(229, 9, 20, 0.12); }
.ptab-icon::after { display: none; }
.ptab-icon svg { display: block; }

/* ---------- Lightbox toolbar (slideshow / like / views / download) ---------- */
.lightbox-toolbar {
    position: absolute;
    bottom: 18px;
    right: 18px;
    z-index: 11;
    display: flex;
    gap: 8px;
    background: rgba(0,0,0,0.65);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 6px 10px;
    border-radius: 28px;
    backdrop-filter: blur(8px);
}
.lb-tool {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 6px 10px;
    border-radius: 16px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: background 0.15s, color 0.15s;
    font-family: inherit;
}
.lb-tool:hover { background: rgba(255,255,255,0.15); }
.lb-tool.lb-like-btn.liked { color: var(--accent); }
.lb-stat {
    color: var(--muted);
    font-size: 0.88rem;
}
.lb-views-btn { cursor: pointer; }

/* Viewers popover (clicked from the 👁 view counter) */
.lb-viewers-popover,
.lb-info-popover {
    position: absolute;
    bottom: 70px;
    right: 18px;
    background: #181818;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    min-width: 260px;
    max-width: 360px;
    z-index: 12;
    box-shadow: 0 12px 32px rgba(0,0,0,0.7);
    animation: viewersPopIn 0.15s ease;
    max-height: 70vh;
    overflow-y: auto;
}
.lb-info-popover h3 {
    margin: 0 0 10px;
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.lb-info-popover dl {
    margin: 0;
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 6px 14px;
    font-size: 0.88rem;
}
.lb-info-popover dt {
    color: var(--muted);
    font-weight: 500;
    white-space: nowrap;
}
.lb-info-popover dd {
    margin: 0;
    color: var(--text, #fff);
    word-break: break-word;
}
.lb-info-popover dd a { color: #6cf; text-decoration: none; }
.lb-info-popover dd a:hover { text-decoration: underline; }
@keyframes viewersPopIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.lb-viewers-popover h3 {
    margin: 0 0 10px;
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.lb-viewers-popover ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.viewer-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.92rem;
    color: var(--text);
}
.viewer-row .va {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex: 0 0 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.95rem;
    background-size: cover;
    background-position: center;
}
.viewer-row .va.img { color: transparent; }
.viewer-row .vn { font-weight: 500; }
.viewer-row .vc { margin-left: auto; color: var(--muted); font-size: 0.82rem; }

/* ---------- Stats overlay on media tiles & cards ---------- */
.tile-stats {
    position: absolute;
    bottom: 6px;
    right: 6px;
    display: flex;
    gap: 6px;
    pointer-events: none;
    font-size: 0.78rem;
    z-index: 2;
}
.tile-stats span {
    background: rgba(0,0,0,0.65);
    color: white;
    padding: 2px 7px;
    border-radius: 10px;
    backdrop-filter: blur(4px);
    line-height: 1;
}
.tile-stats .ts-heart { color: var(--accent); }
.media-tile { position: relative; }
.date-tile { position: relative; }

/* ---------- Like button (album page) ---------- */
.album-title-row {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.album-title-row .album-title { margin: 0; }
.like-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 1.6rem;
    line-height: 1;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.12s;
    padding: 0;
}
.like-btn:hover { background: rgba(255,255,255,0.06); color: var(--text); transform: scale(1.05); }
.like-btn.liked {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(229,9,20,0.12);
}
.like-btn.liked:hover { background: rgba(229,9,20,0.2); }
.like-heart { display: inline-block; }
@keyframes likePulse {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.6); }
    70%  { transform: scale(0.95); }
    100% { transform: scale(1); }
}

/* ---------- Continue Watching ---------- */
.cw-card { position: relative; }
.cw-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 2.4rem;
    text-shadow: 0 2px 12px rgba(0,0,0,0.85);
    opacity: 0.8;
    pointer-events: none;
    transition: opacity 0.15s, transform 0.15s;
}
.cw-card:hover .cw-play-icon { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
.cw-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 4px;
    background: var(--accent);
    box-shadow: 0 0 8px rgba(229,9,20,0.7);
    pointer-events: none;
    transition: width 0.3s;
}

/* ---------- Memory Capsules (On This Day) ---------- */
.capsules-row {
    background: linear-gradient(180deg, rgba(229,9,20,0.08), transparent);
    border-top: 1px solid rgba(229,9,20,0.18);
    border-bottom: 1px solid rgba(229,9,20,0.18);
    padding-top: 20px !important;
}
.capsule-badge {
    display: inline-block;
    background: linear-gradient(135deg, #e50914, #b00610);
    color: white;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    box-shadow: 0 2px 10px rgba(229,9,20,0.4);
}
.capsule-group { margin-top: 14px; }
.capsule-label {
    margin: 0 0 6px;
    font-size: 0.95rem;
    font-weight: 500;
    color: #ddd;
}
.capsule-card {
    width: 200px;
    aspect-ratio: 1 / 1;
}
.capsule-play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 2rem;
    text-shadow: 0 2px 8px rgba(0,0,0,0.7);
    pointer-events: none;
}

/* ---------- Storage bar (settings page) ---------- */
.storage-bar {
    width: 100%;
    height: 14px;
    background: var(--bg-elev-2);
    border-radius: 7px;
    overflow: hidden;
}
.storage-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #00b34d, #e0c200 60%, var(--accent) 90%);
    transition: width 0.4s ease;
}

/* ---------- Buttons ---------- */
.btn-primary {
    display: inline-block;
    background: var(--accent);
    color: white;
    border: none;
    padding: 12px 26px;
    font-weight: 600;
    font-size: 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
    display: inline-block;
    background: rgba(255,255,255,0.1);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 10px 22px;
    font-weight: 500;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s;
}
.btn-secondary:hover { background: rgba(255,255,255,0.18); }

.btn-danger {
    background: #6e1014;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
}
.btn-danger:hover { background: #8a141a; }

/* ---------- Auth / login ---------- */
.auth-body {
    background:
        linear-gradient(rgba(0,0,0,0.55), rgba(0,0,0,0.85)),
        radial-gradient(circle at 30% 20%, #3a0a0e, #141414 65%);
    min-height: 100vh;
}
.auth-card {
    max-width: 360px;
    margin: 12vh auto;
    background: rgba(0, 0, 0, 0.75);
    padding: 40px 36px;
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.auth-title {
    margin: 0;
    color: var(--accent);
    font-size: 2rem;
    letter-spacing: 0.5px;
}
.auth-sub {
    margin: 6px 0 26px;
    color: var(--muted);
}
.auth-error {
    background: rgba(229, 9, 20, 0.15);
    border: 1px solid var(--accent);
    color: #ffb8bd;
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.9rem;
}
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; }
.auth-form label span { font-size: 0.85rem; color: var(--muted); }
.auth-form input {
    padding: 12px 14px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1rem;
}
.auth-form input:focus {
    outline: none;
    border-color: var(--accent);
}
.auth-form .btn-primary { margin-top: 8px; }

/* ---------- Hero ---------- */
.hero {
    position: relative;
    min-height: 70vh;
    display: flex;
    align-items: flex-end;
    padding: 0 4vw 60px;
    background-color: #000;
    overflow: hidden;
}
.hero-empty {
    background: linear-gradient(135deg, #2a0408 0%, #141414 70%);
}

/* ---------- Hero rotator (Wave 9: multiple stacked slides with crossfade) ---------- */
.hero-rotator { position: relative; }
.hero-slide {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    padding: 0 4vw 60px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 1.2s ease-in-out, visibility 0s linear 1.2s;
    pointer-events: none;
}
.hero-slide.active {
    opacity: 1;
    visibility: visible;
    transition: opacity 1.2s ease-in-out, visibility 0s;
    pointer-events: auto;
}
.hero-dots {
    position: absolute;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    display: flex;
    gap: 8px;
}
.hero-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.35);
    cursor: pointer;
    padding: 0;
    transition: background 0.2s, transform 0.15s;
}
.hero-dot:hover { background: rgba(255, 255, 255, 0.6); transform: scale(1.15); }
.hero-dot.active { background: var(--accent); transform: scale(1.2); }
.hero-bg-media {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
}
.hero-overlay {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(to top, #141414 5%, transparent 60%),
        linear-gradient(to right, rgba(20,20,20,0.85) 0%, transparent 60%);
    z-index: 1;
    pointer-events: none;
}
.hero-inner {
    position: relative;
    max-width: 600px;
    z-index: 2;
}
.hero-title {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 800;
    margin: 0 0 10px;
    text-shadow: 0 2px 12px rgba(0,0,0,0.7);
}
.hero-meta {
    color: var(--muted);
    margin: 0 0 12px;
    font-size: 0.9rem;
}
.hero-desc {
    font-size: 1.05rem;
    margin: 0 0 22px;
    text-shadow: 0 1px 6px rgba(0,0,0,0.7);
}
.hero-cta { padding: 14px 32px; }

/* ---------- Rows ---------- */
.row {
    padding: 26px 4vw 10px;
}
.row-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 12px;
}
.row { position: relative; }
.row-track {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;            /* Firefox — hide scrollbar */
    -ms-overflow-style: none;          /* IE/old Edge */
    padding: 6px 0 16px;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}
.row-track::-webkit-scrollbar { display: none; }   /* Chrome/Safari */

/* Hover-revealed left/right arrow buttons for desktop. Hidden on touch devices
   since fingers can swipe. JS adds .row-arrow elements to each .row at load. */
.row-arrow {
    display: none;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 42px;
    height: 88px;
    background: rgba(0, 0, 0, 0.62);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: white;
    font-size: 2.2rem;
    line-height: 1;
    cursor: pointer;
    border-radius: 6px;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.18s ease, background 0.18s ease;
    padding: 0;
}
@media (hover: hover) and (pointer: fine) {
    .row-arrow { display: flex; align-items: center; justify-content: center; }
    .row:hover .row-arrow { opacity: 0.95; }
}
.row-arrow:hover { background: rgba(0, 0, 0, 0.88); }
.row-arrow.hidden { opacity: 0 !important; pointer-events: none; }
.row-arrow-left  { left: 4px; }
.row-arrow-right { right: 4px; }

.card {
    flex: 0 0 auto;
    width: 260px;
    aspect-ratio: 16 / 9;
    background: var(--bg-elev);
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
    scroll-snap-align: start;
    transition: transform 0.18s ease;
    cursor: pointer;
}
.card:hover { transform: scale(1.04); z-index: 2; box-shadow: var(--shadow); }
.card img { width: 100%; height: 100%; object-fit: cover; }
.card-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #3a0a0e, #1f1f1f);
    font-size: 4rem;
    font-weight: 800;
    color: rgba(255,255,255,0.6);
}
.card-overlay {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 10px 12px;
    background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
}
.card-title {
    font-weight: 600;
    font-size: 0.95rem;
}

/* ---------- Admin shell ---------- */
.admin-shell {
    max-width: 1100px;
    margin: 0 auto;
    padding: 30px 4vw 60px;
}
.admin-header h1 {
    margin: 0;
    font-size: 2rem;
}
.admin-header .muted { color: var(--muted); margin-top: 4px; }
.muted { color: var(--muted); }

.admin-tiles {
    margin-top: 28px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}
.tile {
    background: var(--bg-elev);
    padding: 24px;
    border-radius: 10px;
    border: 1px solid var(--border);
    transition: transform 0.15s, border-color 0.15s;
}
.tile:hover { transform: translateY(-2px); border-color: var(--accent); }
.tile h2 { margin: 0 0 6px; font-size: 1.2rem; }
.tile p { margin: 0; color: var(--muted); font-size: 0.92rem; }

/* ---------- Admin tables ---------- */
.admin-section {
    margin-top: 32px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 22px;
}
.admin-section h2 {
    margin: 0 0 16px;
    font-size: 1.2rem;
}
.admin-table {
    width: 100%;
    border-collapse: collapse;
}
.admin-table th, .admin-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}
.admin-table th {
    color: var(--muted);
    font-weight: 500;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}
.admin-table tr:last-child td { border-bottom: none; }
.row-actions { display: flex; gap: 8px; }

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: end;
}
.form-row label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.85rem;
    color: var(--muted);
}
.form-row input, .form-row textarea, .form-row select {
    padding: 8px 12px;
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.95rem;
    min-width: 220px;
    font-family: inherit;
}
.form-row textarea { min-width: 320px; min-height: 60px; resize: vertical; }
.form-row input:focus, .form-row textarea:focus, .form-row select:focus {
    outline: none;
    border-color: var(--accent);
}

.crumbs {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 8px;
}
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--text); }

.flash {
    background: rgba(229, 9, 20, 0.15);
    border: 1px solid var(--accent);
    color: #ffb8bd;
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
}
.flash.ok {
    background: rgba(0, 160, 80, 0.15);
    border-color: #2a9d5f;
    color: #b8f0cd;
}

/* Sortable.js helpers */
.sortable-ghost { opacity: 0.4; }
.sortable-handle { cursor: grab; user-select: none; }
.sortable-handle:active { cursor: grabbing; }

/* ---------- Album page ---------- */
.album-header {
    padding: 30px 4vw 16px;
}
.album-title {
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    margin: 0 0 6px;
}
.album-meta {
    color: var(--muted);
    margin: 0 0 12px;
    font-size: 0.95rem;
}
.album-desc {
    max-width: 800px;
    margin: 0 0 14px;
    color: #d8d8d8;
}
.media-grid {
    padding: 10px 4vw 60px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px;
}
/* Grid size variants — driven by the toolbar above the grid and persisted to
   localStorage so the user's preferred density survives navigation. */
.media-grid.size-sm { grid-template-columns: repeat(auto-fill, minmax(75px, 1fr)); gap: 4px; }
.media-grid.size-md { grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: 6px; }
/* size-lg uses the default rule above. */

.grid-size-toolbar {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 4vw 0;
    color: var(--text-muted, #999);
    font-size: 0.85rem;
    flex-wrap: wrap;
}
.grid-size-toolbar button {
    background: transparent;
    border: 1px solid var(--border, #333);
    color: inherit;
    padding: 4px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}
.grid-size-toolbar button:hover { border-color: #777; }
.grid-size-toolbar button.active {
    background: var(--accent, #e50914);
    color: white;
    border-color: var(--accent, #e50914);
}
.media-tile {
    aspect-ratio: 1 / 1;
    background: var(--bg-elev);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    position: relative;
    transition: transform 0.15s;
}
.media-tile:hover { transform: scale(1.02); }
.media-tile img { width: 100%; height: 100%; object-fit: cover; }
.media-tile.video::after {
    content: "▶";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 2.4rem;
    text-shadow: 0 2px 8px rgba(0,0,0,0.7);
    pointer-events: none;
}

/* ---------- Lightbox ---------- */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.96);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    overflow: hidden;
}
.lightbox.open { display: flex; }
.lightbox-track {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    /* Use viewport units so transforms are unambiguous (% would refer to the
       track's own width, which is 3x viewport — caused all slides to be off-screen). */
    transform: translateX(-100vw);
    will-change: transform;
}
.lightbox-slide {
    flex: 0 0 100vw;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Let the browser handle two-finger pinch-zoom; JS owns single-finger
       gestures (swipe, double-tap, drag-to-pan). Without `pinch-zoom`, pinch
       does nothing. Without disabling pan, the browser would claim horizontal
       drags as scrolling and break our swipe-to-next gesture. */
    touch-action: pinch-zoom;
    -webkit-touch-callout: none;
    padding: 4vh 2vw;
}
.lightbox-slide img,
.lightbox-slide video {
    max-width: 96vw;
    max-height: 92vh;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}
.lightbox-close, .lightbox-prev, .lightbox-next {
    position: absolute;
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;   /* above the slide track, which now fills the viewport */
}
.lightbox-close:hover, .lightbox-prev:hover, .lightbox-next:hover { background: rgba(0,0,0,0.85); }
.lightbox-close { top: 20px; right: 20px; }
.lightbox-prev { left: 20px; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 20px; top: 50%; transform: translateY(-50%); }
/* On touch devices the swipe gesture already handles next/prev — the on-screen
   arrows just clutter the photo. Hide them when there's no fine pointer. */
@media (hover: none) and (pointer: coarse) {
    .lightbox-prev, .lightbox-next { display: none; }
}
.lightbox-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--muted);
    font-size: 0.85rem;
    background: rgba(0,0,0,0.5);
    padding: 4px 12px;
    border-radius: 12px;
    z-index: 10;
}

/* ---------- Quick screen lock ---------- */
.lock-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px 4vw;
    background:
        linear-gradient(rgba(0,0,0,0.6), rgba(0,0,0,0.85)),
        radial-gradient(circle at 30% 20%, #2a0a0e, #141414 70%);
}
.lock-card {
    width: 100%;
    max-width: 360px;
    background: rgba(0,0,0,0.7);
    padding: 36px 32px;
    border-radius: 14px;
    box-shadow: var(--shadow);
    text-align: center;
}
.lock-avatar {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    margin: 0 auto 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 3rem;
    font-weight: 700;
    background-size: cover;
    background-position: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.6);
}
.lock-name {
    margin: 0 0 4px;
    font-size: 1.1rem;
    color: var(--text);
}
.lock-icon-big { font-size: 4rem; margin-bottom: 14px; }
.lock-title {
    margin: 14px 0 4px;
    color: var(--accent);
    font-size: 1.6rem;
}
.lock-sub { color: var(--muted); margin: 0 0 22px; }
.lock-card .auth-form { margin-top: 0; }

/* ---------- Login intro (full-screen video) ---------- */
.intro-overlay {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.intro-overlay[hidden] { display: none; }

.intro-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.intro-skip {
    position: absolute;
    bottom: 26px;
    right: 26px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.25);
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
    z-index: 10;
    opacity: 0.7;
    transition: opacity 0.15s, background 0.15s;
}
.intro-skip:hover { opacity: 1; background: rgba(255,255,255,0.18); }

/* ---------- Upload form ---------- */
/* ---------- Upload summary panel (errors + duplicates) ---------- */
.upload-summary { margin-top: 14px; display: flex; flex-direction: column; gap: 14px; }
.us-section {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border, #333);
    border-radius: 8px;
    padding: 12px 14px;
}
.us-section h3 { margin: 0 0 6px; font-size: 1rem; }
.us-dupes { border-color: #b67c1e; background: rgba(180,120,30,0.10); }
.us-errors { border-color: #913232; background: rgba(140,40,40,0.10); }
.us-list { list-style: none; padding: 0; margin: 4px 0; max-height: 240px; overflow-y: auto; font-size: 0.9rem; }
.us-list li { padding: 4px 0; }
.us-list label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.us-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.us-section details summary { cursor: pointer; padding: 4px 0; font-size: 0.9rem; color: var(--muted); }
.us-section details[open] summary { margin-bottom: 6px; }

.uploader {
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 30px;
    text-align: center;
    background: var(--bg-elev-2);
    transition: border-color 0.15s, background 0.15s;
    cursor: pointer;
}
.uploader:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.uploader.dragover { border-color: var(--accent); background: rgba(229,9,20,0.08); }
/* Push the input completely off-screen so it can't render any visual artifacts.
   The `<label class="uploader">` still triggers it on click. !important so no
   other rule can override. */
.uploader input[type=file],
.uploader input[type="file"],
#file-input {
    position: absolute !important;
    left: -10000px !important;
    top: auto !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
}
.upload-progress {
    margin-top: 14px;
    height: 6px;
    background: var(--bg-elev);
    border-radius: 3px;
    overflow: hidden;
    display: none;
}
.upload-progress.active { display: block; }
.upload-progress > div {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.2s;
}

/* ========== Wave 4: profiles, hamburger submenus, notes banner ========== */

/* Profile pill in topnav */
.profile-pill { margin: 0; }
.profile-pill-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.14);
    color: var(--text);
    padding: 4px 12px 4px 4px;
    border-radius: 30px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
}
.profile-pill-btn:hover { background: rgba(255,255,255,0.12); }
.profile-pill-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1rem;
}
.profile-pill-name {
    font-size: 0.9rem;
    font-weight: 500;
}
@media (max-width: 600px) {
    .profile-pill-name { display: none; }
    .profile-pill-btn { padding: 4px; }
}

/* "Who's watching?" picker page */
.picker-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 4vw;
    background: linear-gradient(rgba(0,0,0,0.6), rgba(0,0,0,0.85)),
                radial-gradient(circle at 30% 20%, #3a0a0e, #141414 65%);
}
.picker-title {
    font-size: clamp(1.6rem, 4vw, 2.6rem);
    font-weight: 400;
    color: var(--text);
    margin-bottom: 36px;
}
.picker-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: 32px;
    max-width: 100%;
}
.picker-card {
    margin: 0;
    flex: 0 0 auto;
    width: 160px;
}
.picker-btn,
.picker-add {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 0;
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    text-decoration: none;
    transition: color 0.15s;
}
.picker-btn:hover, .picker-add:hover { color: var(--text); }
.picker-avatar {
    width: 130px;
    height: 130px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 3.5rem;
    font-weight: 700;
    transition: outline 0.15s, transform 0.15s;
    outline: 0px solid var(--text);
}
.picker-btn:hover .picker-avatar,
.picker-add:hover .picker-avatar {
    outline-width: 4px;
    transform: scale(1.04);
}
.picker-avatar-add {
    background: transparent;
    border: 2px dashed var(--border);
    color: var(--muted);
}
.picker-avatar-img {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    color: transparent;   /* hide any text fallback */
}
.picker-name { font-size: 1.05rem; }
.picker-foot {
    margin-top: 60px;
    text-align: center;
}

/* Manage profiles */
.profile-edit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}
.profile-edit-card {
    background: var(--bg-elev-2);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.profile-edit-card label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.85rem;
    color: var(--muted);
}
.profile-edit-card input[type=text],
.profile-edit-card input[type=color] {
    padding: 8px 12px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: inherit;
}
.profile-edit-card input[type=color] {
    padding: 4px;
    height: 40px;
    cursor: pointer;
}
.profile-edit-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}
.profile-edit-actions .btn-primary,
.profile-edit-actions .btn-danger {
    flex: 1;
    padding: 8px;
    font-size: 0.9rem;
}

/* Hamburger submenus (theme picker, send-note compose) */
.hm-section-btn {
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    color: var(--text);
    padding: 10px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
}
.hm-section-btn:hover { background: rgba(255,255,255,0.08); }

.hm-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease, padding 0.25s ease;
    padding: 0 6px;
}
.hm-submenu.open {
    max-height: 600px;
    padding: 6px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    margin: 4px 0;
}

.theme-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    background: none;
    border: none;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text);
    font-family: inherit;
    font-size: 0.92rem;
    text-align: left;
}
.theme-option:hover { background: rgba(255,255,255,0.06); }
.theme-option.active { background: rgba(229,9,20,0.18); }
.theme-swatch {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    flex: 0 0 22px;
    border: 1px solid rgba(255,255,255,0.12);
}
.theme-swatch-netflix-red    { background: linear-gradient(135deg, #141414 0%, #141414 50%, #e50914 50%, #e50914 100%); }
.theme-swatch-amoled-black   { background: linear-gradient(135deg, #000 0%, #000 50%, #4dd0e1 50%, #4dd0e1 100%); }
.theme-swatch-cyberpunk      { background: linear-gradient(135deg, #0a0a1f 0%, #0a0a1f 50%, #ff00ff 50%, #00ffff 100%); }
.theme-swatch-minimal-glass  { background: linear-gradient(135deg, #1a1a2e 0%, #1a1a2e 50%, #ffd700 50%, #ffd700 100%); }
.theme-swatch-color-shift    { background: linear-gradient(135deg, #ff5e9c, #ff9a3c, #ffd93d, #6bcf7f, #4d9de0); }

/* Note compose form */
.note-form { display: flex; flex-direction: column; gap: 8px; padding: 4px; }
.note-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.82rem; color: var(--muted); }
.note-form select,
.note-form textarea {
    padding: 8px 10px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.92rem;
    width: 100%;
    resize: vertical;
}

/* Notes banner (top of page when there are unread notes for this profile) */
.notes-banner-stack {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 4vw 0;
    position: relative;
    z-index: 40;
}
.notes-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(90deg, rgba(229,9,20,0.18), rgba(229,9,20,0.08));
    border: 1px solid rgba(229,9,20,0.4);
    border-radius: 10px;
    padding: 10px 14px;
    box-shadow: 0 4px 14px rgba(229,9,20,0.18);
    animation: noteSlideIn 0.4s ease;
}
@keyframes noteSlideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.notes-banner-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex: 0 0 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
}
.notes-banner-from {
    color: var(--muted);
    font-size: 0.85rem;
    flex: 0 0 auto;
}
.notes-banner-content {
    flex: 1;
    color: var(--text);
    font-size: 0.95rem;
}
.notes-banner-close {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 1.4rem;
    padding: 0 6px;
    line-height: 1;
    transition: color 0.15s;
}
.notes-banner-close:hover { color: var(--text); }
@media (max-width: 600px) {
    .notes-banner-from { display: none; }
}
