
:root {
    --bg: #050507;
    --white: #ffffff;
    --muted: #bdbdc5;
    --green: #13b887;
    --gold: #e6bd62;
    --border: rgba(255,255,255,.16);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    background: var(--bg);
    color: var(--white);
    font-family: Inter, -apple-system, BlinkMacSystemFont,
        "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}

button,
a {
    font: inherit;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
}

button {
    border: 0;
    cursor: pointer;
}

.reels-page {
    position: relative;
    width: 100%;
    height: 100dvh;
    overflow: hidden;
    background: #000;
}

/* =====================================================
   FEED
===================================================== */

.reels-feed {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-snap-type: y mandatory;
    scrollbar-width: none;
    background: #000;
    z-index: 1;
}

.reels-feed::-webkit-scrollbar {
    display: none;
}

.reel-card {
    position: relative;
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    background: #000;
    scroll-snap-align: start;
    scroll-snap-stop: always;
}

.reel-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
    display: block;
    z-index: 1;
}

.bunny-player {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    background: #000;
    display: none;
    z-index: 2;
}

.reel-card.bunny-fallback .bunny-player {
    display: block;
}

.reel-card.bunny-fallback .reel-video {
    visibility: hidden;
}

/* =====================================================
   VIDEO SHADE
===================================================== */

.video-shade {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    background:
        linear-gradient(
            to bottom,
            rgba(0,0,0,.30) 0%,
            transparent 22%,
            transparent 55%,
            rgba(0,0,0,.20) 72%,
            rgba(0,0,0,.78) 100%
        );
}

/* =====================================================
   TOP NAVIGATION
===================================================== */

.reels-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 76px;
    z-index: 50;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding:
        env(safe-area-inset-top, 0px)
        22px
        0;

    background:
        linear-gradient(
            to bottom,
            rgba(0,0,0,.35),
            transparent
        );
}

.reels-tabs {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 28px;
}

.reels-tab {
    background: transparent;
    color: rgba(255,255,255,.68);
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -.4px;
    padding: 10px 0;
    text-shadow: 0 2px 8px rgba(0,0,0,.4);
}

.reels-tab.active {
    color: #fff;
}

.top-icon-btn {
    width: 38px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: #fff;
    position: relative;
    z-index: 2;
}

.top-icon-btn svg {
    width: 29px;
    height: 29px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.notification-btn svg {
    width: 30px;
    height: 30px;
}

/* =====================================================
   REEL INFORMATION
===================================================== */

.reel-info {
    position: absolute;
    left: 18px;
    right: 92px;
    bottom: calc(105px + env(safe-area-inset-bottom));
    z-index: 10;
}

.reel-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    min-width: 0;
}

.reel-avatar {
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--gold);
    padding: 2px;
    background: #111;
}

.reel-user-details {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.reel-user-name {
    font-size: 16px;
    font-weight: 800;
    color: #fff;
    max-width: 145px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    text-shadow: 0 2px 6px #000;
}

.follow-btn {
    min-height: 34px;
    padding: 0 15px;
    border: 1.5px solid rgba(255,255,255,.85);
    border-radius: 9px;
    background: transparent;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
}

.follow-btn.following {
    border-color: var(--green);
    color: var(--green);
    background: rgba(19,184,135,.12);
}

.reel-caption {
    max-width: 100%;
    color: #fff;
    font-size: 14px;
    line-height: 1.45;
    white-space: pre-wrap;
    text-shadow: 0 2px 7px rgba(0,0,0,.9);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* =====================================================
   REEL ACTION COLUMN
===================================================== */

.reel-actions {
    position: absolute;
    right: 12px;
    bottom: calc(105px + env(safe-area-inset-bottom));
    z-index: 15;

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 17px;
}

.action-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.reel-action {
    width: 48px;
    height: 43px;
    display: flex;
    align-items: center;
    justify-content: center;

    color: #fff;
    background: transparent;
    border: 0;
    border-radius: 0;

    transition: transform .15s ease, color .15s ease;
}

.reel-action:active {
    transform: scale(.84);
}

.reel-action svg {
    width: 32px;
    height: 32px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.reel-action.active {
    color: #ff365f;
}

.reel-action.active svg {
    fill: currentColor;
    stroke: currentColor;
}

.action-count {
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    text-shadow: 0 2px 5px #000;
}

/* =====================================================
   SOUND HINT
===================================================== */

.sound-hint {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;

    padding: 10px 16px;
    border-radius: 30px;
    background: rgba(0,0,0,.6);
    color: #fff;
    font-size: 13px;
    font-weight: 700;

    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
}

.sound-hint.visible {
    opacity: 1;
}

/* =====================================================
   PROCESSING STATE
===================================================== */

.processing-state {
    position: absolute;
    inset: 0;
    z-index: 8;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 14px;
    text-align: center;
    pointer-events: none;
}

.processing-state.visible {
    display: flex;
}

.processing-icon {
    width: 68px;
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 22px;
    background: rgba(0,0,0,.35);
    border: 1px solid var(--border);
}

.processing-icon svg {
    width: 34px;
    height: 34px;
    fill: none;
    stroke: #fff;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.processing-state span {
    color: #fff;
    font-size: 15px;
    text-shadow: 0 2px 8px #000;
}

/* =====================================================
   VIDEO ERROR
===================================================== */

.video-error-state {
    position: absolute;
    inset: 0;
    z-index: 9;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    text-align: center;
    padding: 30px;
}

.video-error-state.visible {
    display: flex;
}

.video-error-state strong {
    font-size: 17px;
}

.video-error-state span {
    max-width: 280px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

/* =====================================================
   EMPTY / LOADING STATE
===================================================== */

.state {
    min-height: 100dvh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    text-align: center;
    padding: 30px;
    background: #050507;
}

.state-icon {
    width: 92px;
    height: 92px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 27px;
    background: rgba(19,184,135,.10);
    border: 1px solid rgba(19,184,135,.22);
    margin-bottom: 24px;
}

.state-icon svg {
    width: 43px;
    height: 43px;
    fill: none;
    stroke: var(--green);
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.state h2 {
    font-size: 25px;
    margin-bottom: 10px;
}

.state p {
    color: var(--muted);
    line-height: 1.5;
    max-width: 320px;
}

/* =====================================================
   MOBILE
===================================================== */

@media (max-width: 500px) {

    .reels-topbar {
        height: 72px;
        padding-left: 17px;
        padding-right: 17px;
    }

    .reels-tabs {
        gap: 25px;
    }

    .reels-tab {
        font-size: 19px;
    }

    .top-icon-btn svg {
        width: 28px;
        height: 28px;
    }

    .reel-info {
        left: 15px;
        right: 78px;
        bottom: calc(105px + env(safe-area-inset-bottom));
    }

    .reel-actions {
        right: 9px;
        bottom: calc(105px + env(safe-area-inset-bottom));
        gap: 15px;
    }

    .reel-action {
        width: 43px;
        height: 40px;
    }

    .reel-action svg {
        width: 30px;
        height: 30px;
    }

    .reel-avatar {
        width: 44px;
        height: 44px;
        flex-basis: 44px;
    }

    .reel-user-name {
        font-size: 15px;
        max-width: 125px;
    }

    .follow-btn {
        min-height: 32px;
        padding: 0 12px;
        font-size: 13px;
    }
}

/* =====================================================
   SHORT SCREENS
===================================================== */

@media (max-height: 700px) {

    .reel-actions {
        gap: 10px;
        bottom: calc(95px + env(safe-area-inset-bottom));
    }

    .reel-info {
        bottom: calc(95px + env(safe-area-inset-bottom));
    }

    .reel-action {
        height: 36px;
    }

    .reel-action svg {
        width: 27px;
        height: 27px;
    }
}
