:root {
    --feed-bg: #000;
    --feed-accent: #68d391;
}

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

html, body {
    height: 100%; overflow: hidden; background: var(--feed-bg);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

.feed-container {
    height: 100vh; height: 100dvh;
    overflow-y: scroll; scroll-snap-type: y mandatory;
    -webkit-overflow-scrolling: touch; overscroll-behavior: none; background: #0d0d0d;
    position: relative;
}

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

/* Tab switch animations */
.feed-slide-out {
    animation: feedSlideOut 0.25s ease forwards;
}
.feed-slide-in {
    animation: feedSlideIn 0.35s ease forwards;
}
@keyframes feedSlideOut {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-30px); }
}
@keyframes feedSlideIn {
    0% { opacity: 0; transform: translateY(30px); }
    100% { opacity: 1; transform: translateY(0); }
}

.feed-item {
    position: relative; scroll-snap-align: start; background: #000;
    height: 100vh; height: 100dvh;
    overflow: hidden;
}

.feed-item video {
    position: absolute; inset: 0; width: 100%; height: 100%;
    object-fit: cover; cursor: pointer; display: block; background: #000;
}

/* Horizontal media scroll */
.media-scroll {
    position: absolute; inset: 0;
    display: flex; gap: 0; overflow-x: auto; overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.media-scroll::-webkit-scrollbar { display: none; }

.media-item {
    flex: 0 0 100%; height: 100%;
    scroll-snap-align: start;
    position: relative;
    overflow: hidden;
}
.media-item img {
    position: absolute; inset: 0; width: 100%; height: 100%;
    object-fit: contain; background: #000;
}
.media-item video {
    position: absolute; inset: 0; width: 100%; height: 100%;
    object-fit: cover; background: #000;
}

/* Dots indicator */
.media-dots {
    position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
    z-index: 7; display: flex; gap: 8px;
    pointer-events: none; margin-bottom: 6px;
}
.media-dots-guide {
    display: flex; flex-direction: column; align-items: center;
    position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
    margin-bottom: 20px;
    animation: swipeGuideFade 1.8s ease-in-out 3;
}
.media-dots-guide .guide-arrow {
    width: 30px; height: 30px;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 5V19M12 19L7 14M12 19L17 14' stroke='rgba(255,255,255,0.55)' stroke-width='2.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center;
    background-size: contain;
    animation: swipeBounce 1.8s ease-in-out infinite;
}
.media-dots-guide .guide-text {
    font-size: 0.75rem; color: rgba(255,255,255,0.4);
    white-space: nowrap; margin-top: 3px; max-width: 80vw;
    overflow: hidden; text-overflow: ellipsis;
}
@keyframes swipeBounce {
    0%, 100% { transform: translateY(0); opacity: 0.6; }
    50% { transform: translateY(6px); opacity: 1; }
}
@keyframes swipeGuideFade {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}
.media-dots.animated .media-dots-guide {
    opacity: 0 !important; animation: none !important;
}
.media-dots .dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: rgba(255,255,255,0.3);
    transition: background 0.2s, transform 0.2s, width 0.2s, border-radius 0.2s;
    flex-shrink: 0;
}
.media-dots .dot.active {
    background: #fff; width: 20px; border-radius: 4px; transform: scale(1.1);
}
@keyframes dotsGuide {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; transform: translateX(-50%) scale(0.95); }
}
.media-dots:not(.animated) {
    animation: none;
}

/* Loading state */
.feed-loading {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 16px; background: #0d0d0d;
    z-index: 5;
}
.feed-spinner {
    width: 32px; height: 32px;
    border: 3px solid rgba(255,255,255,0.08);
    border-top-color: #68d391;
    border-radius: 50%;
    animation: feedSpin 0.8s linear infinite;
}
@keyframes feedSpin { to { transform: rotate(360deg); } }
.feed-loading p { color: rgba(255,255,255,0.3); font-size: 0.85rem; }

.feed-overlay {
    position: absolute; bottom: 0; left: 0; right: 0;
    z-index: 2;
    background: none;
    padding: 40px 16px calc(24px + env(safe-area-inset-bottom, 0px));
    pointer-events: none;
}

.feed-right-bar {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    pointer-events: auto;
    z-index: 3;
}

.feed-avatar {
    width: 48px; height: 48px; border-radius: 50%;
    background: #2AABEE;
    border: 2px solid rgba(255,255,255,0.25);
    color: #fff; font-size: 1.1rem;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: 0.2s; flex-shrink: 0; position: relative;
}
.feed-avatar i {
    font-size: 1.2rem; position: absolute;
    animation: avatarBlink 1.5s ease infinite;
}
.feed-avatar-text {
    font-size: 0.65rem; font-weight: 900; position: absolute;
    animation: avatarBlink 1.5s ease infinite reverse;
}
@keyframes avatarBlink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}
.feed-avatar:active { transform: scale(0.9); }

.feed-item.expanded .feed-overlay {
    background: rgba(0,0,0,0.75);
    padding: 16px 16px calc(24px + env(safe-area-inset-bottom, 0px));
    max-height: 50%;
    overflow: visible;
}

.feed-overlay > * { pointer-events: auto; }

.feed-name {
    font-size: 1rem; font-weight: 700; color: #fff;
    margin-bottom: 6px;
    text-shadow: 0 1px 6px rgba(0,0,0,0.6);
}

.feed-desc {
    font-size: 0.9rem; color: rgba(255,255,255,0.85);
    line-height: 1.5;
    display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: pre-line;
    word-break: break-word;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.feed-item.expanded .feed-desc {
    -webkit-line-clamp: unset;
    display: block;
    text-shadow: none;
    max-height: 200px;
    overflow-y: auto;
}

.feed-item.expanded .feed-name {
    text-shadow: none;
}

.feed-more-btn {
    background: none; border: none; color: rgba(255,255,255,0.45);
    font-size: 0.85rem; cursor: pointer; padding: 4px 0; margin-top: 2px;
}

/* Play icon overlay (shown when paused) */
.feed-play-icon {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
    z-index: 4; pointer-events: none;
    font-size: 3.5rem; color: rgba(255,255,255,0.65);
    opacity: 0; transition: opacity 0.2s ease;
    text-shadow: 0 2px 16px rgba(0,0,0,0.5);
}
.feed-play-icon.show { opacity: 1; }

/* Top bar */
.feed-topbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 50;
    display: flex; align-items: center;
    padding: 4px 10px; padding-top: calc(4px + env(safe-area-inset-top, 0));
    background: linear-gradient(to bottom, rgba(0,0,0,0.6), transparent);
    pointer-events: none;
    gap: 6px;
}

.feed-topbar > * { pointer-events: auto; }

.feed-topbar-logo {
    height: 112px;
    flex-shrink: 0;
}

.feed-topbar-btn {
    width: 36px; height: 36px; border-radius: 50%;
    background: rgba(255,255,255,0.12);
    border: none; color: #fff; font-size: 1rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    text-decoration: none; transition: 0.2s;
    flex-shrink: 0;
}

.feed-topbar-btn:active { transform: scale(0.9); }

/* Tabs scroll inside topbar */
.feed-tabs-scroll {
    display: flex; overflow-x: auto; white-space: nowrap;
    scrollbar-width: none; position: relative;
    -webkit-overflow-scrolling: touch;
    flex: 1; align-self: stretch;
    align-items: stretch;
    justify-content: center;
}
.feed-tabs-scroll::-webkit-scrollbar { display: none; }

.ftab {
    flex-shrink: 0; background: none; border: none;
    color: rgba(255,255,255,0.5); font-size: 0.72rem; font-weight: 500;
    padding: 4px 8px; cursor: pointer;
    transition: color 0.2s, font-weight 0.2s;
    position: relative;
    white-space: nowrap;
    display: flex; align-items: center; gap: 3px;
}
.ftab.active { color: #fff; font-weight: 700; }
.ftab i { font-size: 0.65rem; }

/* ── Pull-to-refresh ── */
.feed-pull-indicator {
    height: 0; overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    transition: height 0.3s ease, opacity 0.3s ease;
    background: transparent;
}
.feed-pull-spinner {
    width: 24px; height: 24px;
    border: 2.5px solid rgba(255,255,255,0.15);
    border-top-color: #68d391;
    border-radius: 50%;
    animation: feedSpin 0.7s linear infinite;
}
.feed-pull-indicator.refreshing .feed-pull-spinner {
    width: 28px; height: 28px;
}

/* Location dropdown */
.location-dropdown-item:hover {
    background: rgba(255,255,255,0.08);
    color: #fff !important;
}



/* Chat list in feed */
.feed-chat-list {
    padding: 140px 16px 16px;
}
@media (max-width: 480px) {
    .feed-chat-list { padding: 90px 12px 12px; }
}
@media (max-width: 360px) {
    .feed-chat-list { padding: 70px 10px 10px; }
}
.feed-chat-item {
    display: flex; gap: 14px; padding: 14px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    cursor: pointer; transition: background 0.2s;
    border-radius: 10px;
}
.feed-chat-item:hover { background: rgba(255,255,255,0.04); }
.feed-chat-item:active { background: rgba(255,255,255,0.08); }
.feed-chat-item .chat-item-avatar { flex-shrink: 0; }
.feed-chat-item .avatar-placeholder {
    width: 48px; height: 48px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700;
}
.feed-chat-item .chat-item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.feed-chat-item .chat-item-name { display: flex; justify-content: space-between; align-items: center; }
.feed-chat-item .chat-item-name h4 { font-size: 0.95rem; font-weight: 600; color: #fff; margin: 0; }
.feed-chat-item .chat-item-time { font-size: 0.72rem; color: rgba(255,255,255,0.35); flex-shrink: 0; }
.feed-chat-item .chat-item-preview { display: flex; align-items: center; gap: 8px; }
.feed-chat-item .chat-item-preview p { font-size: 0.82rem; color: rgba(255,255,255,0.5); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-badge {
    background: #FF3B30; color: #fff; font-size: 0.65rem; font-weight: 700;
    padding: 1px 7px; border-radius: 99px; flex-shrink: 0; line-height: 1.4;
}

/* Chat app embedded in feed page */
.page-feed #chat-app {
    height: calc(100vh - 130px);
    margin-top: 130px;
}
@media (max-width: 600px) {
    .page-feed #chat-app {
        height: calc(100vh - 90px);
        margin-top: 90px;
    }
}
.page-feed #chat-app .chat-folder-tabs {
    display: none;
}

/* Mobile chat-window in feed page */
@media (max-width: 600px) {
    .page-feed #chat-app .chat-list-panel {
        top: 130px !important;
    }
    .page-feed #chat-app .chat-window {
        top: 130px !important;
    }
    .page-feed #chat-app .chat-window-header {
        padding-top: 14px !important;
    }
}

@media (max-width: 480px) {
    .feed-avatar { width: 40px; height: 40px; font-size: 0.8rem; }
    .feed-right-bar { right: 6px; }
    .feed-name {
        font-size: 0.9rem;
    }
    .feed-desc {
        font-size: 0.82rem;
    }
    .feed-more-btn {
        font-size: 0.78rem;
    }
    .feed-topbar-logo {
        height: 60px;
    }
    .feed-topbar-btn {
        width: 34px; height: 34px; font-size: 0.9rem;
    }
    .ftab { font-size: 0.7rem; padding: 3px 6px; }
    .page-feed #chat-app .chat-list-panel { top: 90px !important; }
    .page-feed #chat-app .chat-window { top: 90px !important; }
    .page-feed #chat-app .chat-window-header { padding-top: 10px !important; }
}

@media (max-width: 360px) {
    .feed-avatar { width: 36px; height: 36px; font-size: 0.7rem; }
    .feed-name {
        font-size: 0.82rem;
    }
    .feed-desc {
        font-size: 0.76rem; -webkit-line-clamp: 1;
    }
    .feed-topbar-logo {
        height: 48px;
    }
    .feed-topbar-btn {
        width: 30px; height: 30px; font-size: 0.85rem;
    }

}
.cookie-consent {
    position: fixed; bottom: 16px; left: 16px; right: 16px; z-index: 999;
    background: rgba(26,26,46,0.95); backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    color: #ccc; padding: 14px 18px; border-radius: 14px;
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    font-size: 0.8rem; flex-wrap: wrap;
    border: 1px solid rgba(255,255,255,0.06);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    max-width: 500px; margin: 0 auto;
    animation: cookieSlideUp 0.4s cubic-bezier(0.16,1,0.3,1);
}
@keyframes cookieSlideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.cookie-consent::before {
    content: '🍪'; font-size: 1.3rem; flex-shrink: 0;
}
.cookie-consent span { flex: 1; line-height: 1.4; }
.cookie-consent-actions { display: flex; gap: 8px; flex-shrink: 0; }
.cookie-btn {
    border: none; padding: 8px 16px; border-radius: 8px;
    font-size: 0.78rem; cursor: pointer; font-weight: 600;
    transition: all 0.2s;
}
.cookie-btn-accept {
    background: linear-gradient(135deg,#68d391,#4FC3F7); color: #000;
}
.cookie-btn-accept:hover { transform: scale(1.04); }
.cookie-btn-decline {
    background: rgba(255,255,255,0.08); color: #888;
}
.cookie-btn-decline:hover { background: rgba(255,255,255,0.14); color: #ccc; }
