:root {
    --feed-bg: #060606;
    --feed-overlay: linear-gradient(to top, rgba(0,0,0,.72), rgba(0,0,0,.16) 32%, rgba(0,0,0,.04) 56%, rgba(0,0,0,.38));
    --feed-text: #ffffff;
    --feed-muted: rgba(255,255,255,.72);
    --accent: #0d6efd;
}

html, body {
    height: 100%;
    margin: 0;
    background: var(--feed-bg);
}

body.feed-body {
    color: var(--feed-text);
    overflow: hidden;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.feed-topbar {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 40;
    background: linear-gradient(to bottom, rgba(0,0,0,.55), rgba(0,0,0,0));
    min-height: 60px;
}

.feed-wrapper {
    height: 100dvh;
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    scrollbar-width: none;
}
.feed-wrapper::-webkit-scrollbar { display: none; }

.feed-slide,
.empty-state {
    position: relative;
    height: 100dvh;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    background: #000;
}

.video-shell,
.video-poster {
    position: absolute;
    inset: 0;
}

.video-shell {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* IMPORTANT:
   The YouTube Iframe API replaces the .video-player div with an iframe that keeps the same id/class.
   So sizing must be applied directly to .video-player itself (the iframe), not to .video-player iframe.
*/
.video-player {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: block;
    width: min(100vw, calc(100dvh * 9 / 16));
    height: 100dvh;
    max-width: 100vw;
    max-height: 100dvh;
    border: 0;
    background: #000;
    z-index: 1;
}

.video-poster {
    background-size: cover;
    background-position: center;
    filter: blur(10px);
    transform: scale(1.08);
    opacity: .32;
    transition: opacity .25s ease;
    z-index: 0;
}

.feed-slide.is-ready .video-poster {
    opacity: .08;
}

.video-shell::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--feed-overlay);
    z-index: 2;
    pointer-events: none;
}

.video-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 4;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    background: rgba(0,0,0,.35);
    border-radius: 999px;
    backdrop-filter: blur(6px);
}

.feed-slide.is-ready .video-loader {
    opacity: 0;
    pointer-events: none;
}

.video-progress {
    position: absolute;
    top: 60px;
    left: 14px;
    right: 14px;
    z-index: 4;
    height: 3px;
    background: rgba(255,255,255,.2);
    border-radius: 999px;
    overflow: hidden;
    pointer-events: none;
}
.video-progress span {
    display: block;
    width: 0;
    height: 100%;
    background: #fff;
}

.video-overlay {
    position: absolute;
    inset: 0;
    z-index: 5;
    padding-top: 82px;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    pointer-events: none;
}

.video-meta {
    max-width: 760px;
    padding-bottom: 12px;
}

.video-title {
    text-shadow: 0 2px 8px rgba(0,0,0,.45);
}

.video-desc {
    color: var(--feed-muted);
    font-size: .95rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.engagement-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
    padding-bottom: 8px;
    pointer-events: auto;
}

.engagement-btn {
    min-width: 70px;
    border: 0;
    border-radius: 999px;
    padding: 10px 12px;
    color: #fff;
    background: rgba(0,0,0,.38);
    backdrop-filter: blur(8px);
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: transform .2s ease, background .2s ease;
}

.engagement-btn:hover,
.engagement-btn:focus-visible {
    color: #fff;
    background: rgba(0,0,0,.55);
    transform: translateY(-1px);
}

.engagement-btn .icon {
    font-size: 1.1rem;
    line-height: 1;
}
.engagement-btn .count {
    margin-top: 3px;
    font-size: .8rem;
}

.like-btn.is-liked {
    background: rgba(220, 53, 69, .85);
}

.comment-drawer {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 60;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
}
.comment-drawer.is-open {
    opacity: 1;
    pointer-events: auto;
}

.comment-panel {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: min(100%, 420px);
    background: #111;
    padding: 18px;
    overflow-y: auto;
    box-shadow: -10px 0 30px rgba(0,0,0,.35);
}

.comment-item {
    padding: 12px 0;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.comment-item:last-child {
    border-bottom: 0;
}
.comment-name {
    font-weight: 600;
}
.comment-date {
    color: rgba(255,255,255,.45);
    font-size: .8rem;
}
.comment-body {
    color: rgba(255,255,255,.82);
    white-space: pre-wrap;
}

@media (max-width: 767.98px) {
    .feed-topbar .navbar-brand {
        font-size: 1.25rem;
    }

    .video-overlay {
        padding-inline: 16px;
        padding-top: 76px;
        padding-bottom: calc(22px + env(safe-area-inset-bottom));
    }

    .video-progress {
        top: 56px;
        left: 10px;
        right: 10px;
    }

    .engagement-btn {
        min-width: 56px;
        padding: 9px 10px;
    }
}
