/* ============================================================
   ROOT VARIABLES – Zividax dark theme
   ============================================================ */
:root {
    --bg: #0a0a0a;
    --surface: #121212;
    --surface-2: #1a1a1a;
    --surface-3: #262626;
    --text: #f5f5f5;
    --text-dim: rgba(255,255,255,0.7);
    --text-dim2: rgba(255,255,255,0.45);
    --accent: #fe2c55;
    --accent-2: #25f4ee;
    --accent-gradient: linear-gradient(135deg, #fe2c55, #f7a83e);
    --nav-h: 56px;
    --top-h: 50px;
    --stage-w: 440px;
    --sidebar-w: 76px;
    --radius-card: 18px;
    --radius-btn: 28px;
    --shadow-card: 0 8px 40px rgba(0,0,0,0.7);
    --transition-smooth: cubic-bezier(0.25, 0.9, 0.35, 1);
}

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

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    user-select: none;
}
::-webkit-scrollbar { display: none; }

/* ---------- Top Bar ---------- */
.top-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--top-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    z-index: 60;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(12px) saturate(1.2);
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.logo {
    font-weight: 800;
    font-size: 20px;
    letter-spacing: -0.3px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.top-right { display: flex; align-items: center; gap: 12px; }
.signin-btn {
    color: var(--text);
    border: 1.5px solid rgba(255,255,255,0.25);
    border-radius: var(--radius-btn);
    padding: 6px 18px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    background: rgba(255,255,255,0.04);
}
.signin-btn:active { transform: scale(0.94); background: rgba(255,255,255,0.1); }
.avatar-link { text-decoration: none; }
.avatar-circle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--accent-gradient);
    color: #fff; font-weight: 700; font-size: 14px;
    box-shadow: 0 2px 12px rgba(254,44,85,0.35);
    transition: transform 0.2s ease;
}
.avatar-circle:active { transform: scale(0.92); }

/* ---------- Feed Container ---------- */
.feed {
    position: fixed;
    top: var(--top-h);
    left: 0; right: 0;
    bottom: var(--nav-h);
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    scrollbar-width: none;
    background: var(--bg);
}
.feed::-webkit-scrollbar { display: none; }

/* Locked while an unskippable ad's countdown is running: no swipe/scroll,
   no wheel, no keyboard scroll until the countdown finishes. */
.feed.scroll-locked {
    overflow: hidden !important;
    touch-action: none;
}

/* ---------- Loader ---------- */
.feed-loader {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    color: var(--text-dim);
    font-size: 14px;
    padding: 0 32px;
    text-align: center;
}
.feed-spinner {
    width: 40px; height: 40px;
    border-radius: 50%;
    border: 3.5px solid rgba(255,255,255,0.08);
    border-top-color: var(--accent);
    animation: spin 0.85s cubic-bezier(0.6,0,0.4,1) infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Reel / Ad Slide ---------- */
.reel {
    position: relative;
    width: 100%;
    height: 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    overflow: hidden;
}
.reel video, .reel img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}
.reel video { animation: reel-fade-in 0.4s ease; }
@keyframes reel-fade-in {
    from { opacity: 0.4; transform: scale(1.02); }
    to   { opacity: 1; transform: scale(1); }
}

.reel::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0.25) 0%, transparent 22%, transparent 55%, rgba(0,0,0,0.55) 100%);
    pointer-events: none;
    z-index: 4;
}

.reel .tap-catcher {
    position: absolute;
    inset: 0;
    z-index: 5;
    cursor: pointer;
}

.reel .play-indicator {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0.7);
    width: 64px; height: 64px;
    border-radius: 50%;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 6;
}
.reel.paused .play-indicator {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}
.reel.paused .play-indicator svg { margin-left: 4px; }

.mute-indicator {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0.7);
    width: 60px; height: 60px;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
    opacity: 0;
    pointer-events: none;
    z-index: 7;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.mute-indicator.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.heart-burst {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0.3);
    opacity: 0;
    pointer-events: none;
    z-index: 20;
    filter: drop-shadow(0 4px 16px rgba(0,0,0,0.4));
    color: var(--accent);
}
.heart-burst.animate {
    animation: heart-pop 0.9s cubic-bezier(0.2,1.4,0.4,1) forwards;
}
@keyframes heart-pop {
    0%   { transform: translate(-50%, -50%) scale(0.2); opacity: 0; }
    30%  { transform: translate(-50%, -50%) scale(1.25); opacity: 1; }
    50%  { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

/* ---------- Reel Info ---------- */
.reel-info {
    position: absolute;
    left: 16px;
    right: 88px;
    bottom: 28px;
    z-index: 10;
    text-shadow: 0 2px 8px rgba(0,0,0,0.7);
}
.reel-info .username {
    font-weight: 700;
    font-size: 15px;
    margin: 0 0 4px;
    letter-spacing: 0.1px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.reel-info .username .badge {
    font-size: 11px;
    background: var(--accent);
    color: #fff;
    padding: 1px 8px;
    border-radius: 12px;
    font-weight: 600;
}
.reel-info .caption {
    font-size: 14px;
    margin: 0;
    color: rgba(255,255,255,0.92);
    word-break: break-word;
    line-height: 1.4;
    max-height: 3.2em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.reel-tags {
    font-size: 12.5px;
    color: var(--accent-2);
    margin: 4px 0 0;
    font-weight: 500;
}

/* ---------- Right Action Buttons (per reel) ---------- */
.reel-actions {
    position: absolute;
    right: 12px;
    bottom: 32px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}
.action-btn {
    background: none;
    border: none;
    color: var(--text);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    padding: 0;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
    transition: transform 0.15s ease;
}
.action-btn svg {
    display: block;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.4));
    transition: transform 0.3s cubic-bezier(0.2,1.4,0.4,1);
}
.action-btn:active { transform: scale(0.86); }
.action-btn.liked svg {
    color: var(--accent);
    animation: like-pop 0.4s ease;
}
@keyframes like-pop {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.35); }
    100% { transform: scale(1); }
}

/* ---------- Bottom Navigation (mobile) ---------- */
.bottom-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: var(--nav-h);
    display: flex;
    background: rgba(0,0,0,0.92);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255,255,255,0.06);
    z-index: 50;
}
.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-dim2);
    text-decoration: none;
    font-size: 11px;
    font-weight: 600;
    transition: color 0.2s ease, transform 0.15s ease;
}
.nav-btn.active, .nav-btn:hover { color: var(--text); }
.nav-btn:active { transform: scale(0.9); }
.nav-create svg { color: var(--text); }

/* ============================================================
   LEFT SIDEBAR (desktop only)
   ============================================================ */
.sidebar {
    display: none;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    z-index: 70;
    flex-direction: column;
    align-items: center;
    padding: 22px 0 16px;
    background: var(--bg);
    border-right: 1px solid rgba(255,255,255,0.06);
}
.side-logo {
    font-weight: 800;
    font-size: 22px;
    margin-bottom: 28px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-decoration: none;
}
.side-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
    flex: 1;
}
.side-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px; height: 44px;
    border-radius: 12px;
    color: var(--text-dim);
    background: none;
    border: none;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}
.side-btn:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.side-btn:active { transform: scale(0.9); }
.side-btn.active { color: var(--text); }
.side-btn.side-profile .avatar-circle { width: 28px; height: 28px; font-size: 12px; }
.side-badge {
    position: absolute;
    top: 2px; right: 2px;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 15px;
    height: 15px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    box-shadow: 0 0 0 2px var(--bg);
}
.side-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

/* ============================================================
   RIGHT-SIDE FLOATING CONTROLS (desktop only)
   ============================================================ */
.side-floaters {
    display: none;
    position: fixed;
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
    flex-direction: column;
    gap: 14px;
    z-index: 65;
}
.floater-btn {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--surface-2);
    border: 1px solid rgba(255,255,255,0.08);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,0,0,0.4);
    transition: background 0.2s ease, transform 0.15s ease;
}
.floater-btn:hover { background: var(--surface-3); }
.floater-btn:active { transform: scale(0.9); }

.messages-pill {
    display: none;
    position: fixed;
    right: 24px;
    bottom: 22px;
    z-index: 65;
    align-items: center;
    gap: 10px;
    background: var(--surface-2);
    border: 1px solid rgba(255,255,255,0.08);
    color: var(--text);
    font-weight: 600;
    font-size: 13.5px;
    padding: 9px 16px 9px 12px;
    border-radius: 24px;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(0,0,0,0.45);
}
.messages-pill:hover { background: var(--surface-3); }
.messages-pill-icon { position: relative; display: flex; }
.messages-pill-badge {
    position: absolute;
    top: -6px; right: -7px;
    background: var(--accent);
    color: #fff;
    font-size: 9.5px;
    font-weight: 700;
    min-width: 14px;
    height: 14px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.messages-pill-avatar {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 11px; font-weight: 700;
}

/* ---------- Comments Panel ---------- */
.comments-panel {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    max-height: 65vh;
    background: var(--surface);
    border-radius: 18px 18px 0 0;
    transform: translateY(100%);
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.35s var(--transition-smooth), visibility 0s linear 0.35s;
    z-index: 100;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -8px 40px rgba(0,0,0,0.6);
}
.comments-panel.open {
    transform: translateY(0);
    visibility: visible;
    pointer-events: auto;
    transition: transform 0.35s var(--transition-smooth), visibility 0s linear 0s;
}
.comments-panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 18px 12px;
    font-weight: 700;
    font-size: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    position: relative;
}
.comments-panel-header::before {
    content: '';
    position: absolute;
    top: -8px; left: 50%;
    transform: translateX(-50%);
    width: 36px; height: 4px;
    border-radius: 4px;
    background: rgba(255,255,255,0.2);
}
.comments-panel-header button {
    background: rgba(255,255,255,0.08);
    border: none;
    color: var(--text);
    width: 28px; height: 28px;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
}
.comments-list {
    overflow-y: auto;
    padding: 10px 18px;
    flex: 1;
}
.comment-row {
    padding: 9px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-size: 14px;
}
.comment-row .c-user { font-weight: 700; margin-right: 6px; }
.comment-empty {
    color: var(--text-dim);
    text-align: center;
    padding: 28px 0;
    font-size: 13px;
}
.comment-form {
    display: flex;
    gap: 8px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(255,255,255,0.06);
}
.comment-form input {
    flex: 1;
    background: var(--surface-2);
    border: none;
    border-radius: 22px;
    padding: 11px 16px;
    color: var(--text);
    font-size: 14px;
}
.comment-form input:focus { outline: 2px solid var(--accent); }
.comment-form button {
    background: var(--accent);
    border: none;
    color: #fff;
    font-weight: 700;
    border-radius: 22px;
    padding: 0 20px;
    cursor: pointer;
    transition: transform 0.12s ease;
}
.comment-form button:active { transform: scale(0.93); }

/* ---------- Ad Specific Styles ---------- */
.ad-slide { background: #000; }
.ad-slide video, .ad-slide img { object-fit: cover; }

.ad-mute-btn {
    position: absolute;
    top: calc(var(--top-h) + 12px);
    right: 14px;
    z-index: 10;
    width: 34px; height: 34px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
}
.ad-mute-btn svg { width: 16px; height: 16px; }

.ad-info {
    position: absolute;
    left: 16px;
    right: 88px;
    bottom: 88px;
    z-index: 10;
    text-shadow: 0 2px 8px rgba(0,0,0,0.7);
}
.ad-profile-row {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 8px;
}
.ad-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px;
    color: #fff;
    flex-shrink: 0;
    text-transform: uppercase;
}
.ad-username { font-weight: 700; font-size: 14.5px; }
.ad-follow-btn {
    border: 1.4px solid #fff;
    background: rgba(0,0,0,0.2);
    color: #fff;
    font-weight: 700;
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 6px;
    cursor: pointer;
    margin-left: 2px;
}
.ad-follow-btn:active { background: rgba(255,255,255,0.2); }
.ad-caption {
    font-size: 13.5px;
    line-height: 1.4;
    color: rgba(255,255,255,0.92);
    margin: 0 0 4px;
}
.ad-label {
    display: inline-block;
    font-size: 12px;
    color: var(--text-dim2);
    font-weight: 600;
}
.ad-cta-pill {
    position: absolute;
    left: 16px;
    bottom: 32px;
    z-index: 10;
    background: rgba(255,255,255,0.95);
    color: #000;
    font-weight: 700;
    font-size: 13.5px;
    padding: 10px 16px 10px 18px;
    border-radius: 24px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.35);
    transition: transform 0.12s ease;
}
.ad-cta-pill:active { transform: scale(0.96); }
.ad-cta-pill svg { width: 14px; height: 14px; }

.ad-countdown {
    position: absolute;
    top: calc(var(--top-h) + 12px);
    left: 16px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 11.5px;
    font-weight: 700;
    padding: 5px 12px;
    border-radius: 20px;
    z-index: 10;
    min-width: 22px;
    text-align: center;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.ad-countdown::before {
    /* small lock glyph while unskippable, removed once countdown finishes */
    content: '🔒';
    font-size: 10px;
    line-height: 1;
}
.ad-countdown.done { background: rgba(255,255,255,0.1); }
.ad-countdown.done::before { content: ''; }

/* ---------- Toast ---------- */
.zvx-toast {
    position: fixed;
    left: 50%; bottom: calc(var(--nav-h) + 20px);
    transform: translateX(-50%);
    background: rgba(20,20,20,0.95);
    color: #fff;
    padding: 10px 20px;
    border-radius: 24px;
    font-size: 13px;
    font-weight: 600;
    z-index: 200;
    box-shadow: 0 6px 20px rgba(0,0,0,0.5);
    backdrop-filter: blur(6px);
    max-width: 82vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    animation: toast-in 0.3s ease;
}
@keyframes toast-in {
    from { opacity: 0; transform: translateX(-50%) translateY(12px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ============================================================
   DESKTOP: sidebar + centered player card + floating controls
   ============================================================ */
@media (min-width: 860px) {
    body { background: #000; overflow: hidden; }

    .sidebar { display: flex; }
    .side-floaters { display: flex; }
    .messages-pill { display: inline-flex; }

    .top-bar {
        background: rgba(0,0,0,0.85);
        backdrop-filter: blur(10px);
        border-bottom: 1px solid rgba(255,255,255,0.06);
        max-width: var(--stage-w);
        left: 50%;
        transform: translateX(-50%);
        border-radius: 0 0 12px 12px;
        border-left: 1px solid rgba(255,255,255,0.05);
        border-right: 1px solid rgba(255,255,255,0.05);
    }
    .feed {
        max-width: var(--stage-w);
        left: 50%;
        transform: translateX(-50%);
        top: calc(var(--top-h) + 16px);
        bottom: calc(var(--nav-h) + 16px);
        border-radius: var(--radius-card);
        box-shadow: var(--shadow-card), 0 0 0 1px rgba(255,255,255,0.04);
    }
    .reel, .reel video, .reel img { border-radius: var(--radius-card); }
    .reel::after { border-radius: var(--radius-card); }
    .bottom-nav {
        max-width: var(--stage-w);
        left: 50%;
        transform: translateX(-50%);
        right: auto;
        bottom: 16px;
        border-radius: 14px;
        border: 1px solid rgba(255,255,255,0.06);
        box-shadow: 0 4px 24px rgba(0,0,0,0.6);
    }
    .comments-panel {
        max-width: var(--stage-w);
        left: 50%;
        transform: translate(-50%, 100%);
        border-radius: var(--radius-card);
        bottom: calc(var(--nav-h) + 24px);
        max-height: 60vh;
    }
    .comments-panel.open { transform: translate(-50%, 0); }
}

/* Small-desktop safety: keep floaters/messages from overlapping a narrow stage */
@media (min-width: 860px) and (max-width: 1150px) {
    .side-floaters { right: 24px; }
    .messages-pill { right: 16px; }
}