html,
body {
    height: auto !important;
    min-height: 0;
    margin: 0 !important;
    padding: 0 !important;
    overflow-x: hidden;
    position: relative;
}

body {
    display: flex;
    flex-direction: column;
}

/* Ensure fixed position elements don't affect body height */
.sidebar,
.post-dropdown-portal,
.emoji-picker-portal,
.profile-hover-card,
.profile-popup,
.profile-popup-overlay,
.image-lightbox,
.gif-picker-overlay,
.report-modal-overlay,
.notifications-dropdown,
.profile-dropdown,
.navbar-desktop,
.navbar-mobile-top,
.navbar-mobile-bottom {
    position: fixed !important;
}

.posts-wrapper {
    min-height: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
    display: block;
}

.posts-wrapper:not(:has(.post-input-container)):not(:has(.guest-banner)) .posts-container {
    padding-top: 100px;
}

.posts-wrapper:has(.guest-banner) .posts-container {
    padding-top: 10px;
}

.posts-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 15px;
    padding-top: 10px;
    padding-bottom: 40px;
    position: relative;
    z-index: 5;
    margin-bottom: 0;
}

.posts-header {
    text-align: center;
    margin-bottom: 30px;
}

.posts-title {
    font-size: 2rem;
    font-weight: 700;
    color: white;
    margin: 0 0 8px 0;
}

.posts-subtitle {
    color: rgba(255, 255, 255, 0.7);
    font-size: 1rem;
    margin: 0;
}

.posts-feed {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 0;
    padding-bottom: 0;
}

.post-card {
    background: #1e2433;
    border: 1px solid rgba(74, 158, 255, 0.1);
    border-radius: 12px;
    padding: 20px;
    position: relative;
    z-index: 5;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.post-card:first-child {
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.post-card:last-child {
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

.post-card:hover {
    background: #252d3f;
    border-color: rgba(74, 158, 255, 0.2);
}

.post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.post-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.post-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
}

.post-avatar:hover {
    transform: scale(1.05);
    border-color: rgba(255, 255, 255, 0.3);
}

.post-user-info h3 {
    color: white;
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 2px 0;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.post-user-info h3 a:hover {
    text-decoration: underline;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.post-time {
    color: rgba(255, 255, 255, 0.4);
    font-weight: 400;
    font-size: 0.85rem;
}

.post-meta {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.875rem;
    margin: 0;
}

.post-menu {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.post-menu:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.post-content {
    margin-bottom: 15px;
}

.post-text {
    color: white;
    font-size: 1rem;
    line-height: 1.5;
    margin: 0 0 15px 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 180px;
    overflow: hidden;
    position: relative;
}

.post-text.expanded {
    max-height: none;
}

.post-show-more {
    color: rgba(245, 158, 11, 0.9);
    font-size: 0.9rem;
    cursor: pointer;
    margin-top: 8px;
    display: inline-block;
}

.post-show-more:hover {
    text-decoration: underline;
}

.post-media {
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(74, 158, 255, 0.1);
    height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0f1419;
    cursor: pointer;
    transition: all 0.3s ease;
}

.post-media:hover {
    transform: scale(1.02);
    border: 2px dotted #4a9eff;
}

.post-media .media-previews {
    height: 100%;
    min-height: 180px;
    max-height: 280px;
}

.post-media:has(.media-previews) {
    height: auto;
    min-height: 180px;
    max-height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.post-img,
.post-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.post-img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.media-previews {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 8px;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-items: center;
}

.media-preview {
    position: relative;
    background: #0f1419;
    border: 2px solid rgba(74, 158, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 16/9;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-preview:hover {
    transform: scale(1.02);
    border: 2px dotted #4a9eff;
}

.media-preview img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    min-width: 80px;
    min-height: 60px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.media-preview:hover img {
    transform: scale(1.05);
}


.post-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    justify-content: space-between;
    padding: 0 0;
}

.post-actions-right {
    display: flex;
    gap: 4px;
}

.post-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03));
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 16px;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    font-size: 0.75rem;
    font-weight: 500;
    position: relative;
    backdrop-filter: blur(8px);
    text-align: center;
}

.post-action:hover {
    color: white;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.08));
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.post-comment {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(217, 119, 6, 0.1));
    border-color: rgba(245, 158, 11, 0.25);
    color: rgba(251, 191, 36, 0.9);
    padding: 7px 14px;
    font-size: 0.8rem;
    min-width: 75px;
    font-weight: 600;
}

.post-comment:hover {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.25), rgba(217, 119, 6, 0.2));
    border-color: rgba(245, 158, 11, 0.35);
    color: white;
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 25px rgba(245, 158, 11, 0.3);
}

.post-share {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), rgba(22, 163, 74, 0.1));
    border-color: rgba(34, 197, 94, 0.25);
    color: rgba(134, 239, 172, 0.9);
}

.post-share:hover {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.25), rgba(22, 163, 74, 0.2));
    border-color: rgba(34, 197, 94, 0.35);
    color: rgba(134, 239, 172, 1);
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 25px rgba(34, 197, 94, 0.3);
}

.post-repost {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.15), rgba(147, 51, 234, 0.1));
    border-color: rgba(168, 85, 247, 0.25);
    color: rgba(196, 181, 253, 0.9);
}

.post-repost:hover {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.25), rgba(147, 51, 234, 0.2));
    border-color: rgba(168, 85, 247, 0.35);
    color: rgba(196, 181, 253, 1);
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 25px rgba(168, 85, 247, 0.3);
}

.post-action.liked {
    color: #10b981;
}

.post-action.liked:hover {
    color: #059669;
    background: rgba(16, 185, 129, 0.1);
}

.action-text {
    font-size: 0.8rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}

.post-count {
    font-weight: 600;
    font-size: 0.75rem;
    margin-left: 4px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    justify-content: center;
}

.post-reactions {
    display: flex;
    gap: 6px;
    margin-top: 12px;
    margin-bottom: 8px;
    align-items: center;
    position: relative;
}

.reaction-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    padding: 4px 8px;
    cursor: pointer;
    transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    position: relative;
}

.reaction-btn.adding {
    animation: reactionSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.reaction-btn.removing {
    animation: reactionSlideOut 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes reactionSlideIn {
    0% {
        opacity: 0;
        transform: scale(0.3) translateY(15px);
        max-width: 0;
        padding-left: 0;
        padding-right: 0;
        margin-left: 0;
        margin-right: 0;
    }

    60% {
        opacity: 1;
        transform: scale(1.1) translateY(-2px);
    }

    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
        max-width: 100px;
        padding-left: 8px;
        padding-right: 8px;
    }
}

@keyframes reactionSlideOut {
    0% {
        opacity: 1;
        transform: scale(1) translateY(0);
        max-width: 100px;
        padding-left: 8px;
        padding-right: 8px;
    }

    100% {
        opacity: 0;
        transform: scale(0.5) translateY(-15px);
        max-width: 0;
        padding-left: 0;
        padding-right: 0;
        margin-left: 0;
        margin-right: 0;
    }
}

.reaction-btn:not(.adding):not(.removing):hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.05) translateY(-1px);
    transition: all 0.2s ease;
}

.reaction-btn.active:not(.adding):not(.removing):hover {
    background: rgba(88, 101, 242, 0.3);
    border-color: #6b7aff;
    box-shadow: 0 4px 12px rgba(88, 101, 242, 0.4);
}

.reaction-btn.active {
    background: rgba(88, 101, 242, 0.2);
    border-color: #5865f2;
    color: white;
    box-shadow: 0 2px 8px rgba(88, 101, 242, 0.3);
}

.reaction-btn.reaction-add {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    padding: 0;
}

.reaction-icon {
    width: 16px;
    height: 16px;
}

.reaction-btn.reaction-add:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.5);
    color: white;
    transform: scale(1.15) translateY(-2px);
}

.reaction-emoji {
    font-size: 1.1rem;
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.reaction-btn:hover .reaction-emoji {
    transform: scale(1.2);
}

.reaction-count {
    color: rgba(255, 255, 255, 0.8);
    font-weight: 600;
    font-size: 0.9rem;
    transform: translateY(-1px);
}


.post-time {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.875rem;
}

#scroll-sentinel {
    height: 10px;
    width: 100%;
    position: relative;
    pointer-events: none;
    margin-top: 20px;
    margin-bottom: 0;
    background: rgba(255, 0, 0, 0.3);
    border: 2px dashed rgba(255, 255, 0, 0.5);
}

#scroll-sentinel::before {
    content: 'SCROLL SENTINEL - DEBUG';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    color: yellow;
    white-space: nowrap;
}

@media (max-width: 640px) {
    .posts-container {
        padding: 15px;
        padding-top: 90px;
        padding-bottom: 20px;
    }

    .posts-title {
        font-size: 1.5rem;
    }

    .post-card {
        padding: 15px;
    }

    .post-user-info h3 a {
        max-width: 11ch;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        display: inline-block;
    }

    .post-actions {
        gap: 12px;
        padding: 0;
        justify-content: center;
        align-items: center;
        display: flex;
        flex-wrap: nowrap;
    }

    .post-action.post-comment {
        margin-left: 0px;
    }

    .post-actions-right {
        margin-left: 0;
        display: contents;
    }


    .post-action {
        gap: 6px;
        padding: 6px 12px;
        font-size: 0.75rem;
        background: linear-gradient(135deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03));
        border: 1px solid rgba(255, 255, 255, 0.1);
        color: rgba(255, 255, 255, 0.7);
        width: 70px;
        height: 32px;
        text-align: center;
        justify-content: center;
        border-radius: 16px;
        font-weight: 500;
        transition: all 0.2s ease;
    }

    .post-action.post-comment {
        justify-content: center;
        width: 70px;
        height: 32px;
        background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(217, 119, 6, 0.1));
        border-color: rgba(245, 158, 11, 0.25);
        color: rgba(251, 191, 36, 0.9);
        font-weight: 600;
    }

    .post-action.post-share {
        background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), rgba(22, 163, 74, 0.1));
        border-color: rgba(34, 197, 94, 0.25);
        color: rgba(134, 239, 172, 0.9);
    }

    .post-action.post-repost {
        background: linear-gradient(135deg, rgba(168, 85, 247, 0.15), rgba(147, 51, 234, 0.1));
        border-color: rgba(168, 85, 247, 0.25);
        color: rgba(196, 181, 253, 0.9);
    }

    .post-media {
        height: 300px;
    }

    .post-media .media-previews {
        height: 100%;
        min-height: 150px;
        max-height: 220px;
    }

    .post-media:has(.media-previews) {
        min-height: 150px;
        max-height: 220px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .media-previews {
        gap: 8px;
        padding: 6px;
        align-items: center;
        justify-items: center;
    }

    .media-preview {
        aspect-ratio: 1/1;
    }

    .reaction-tray {
        top: -45px;
        padding: 6px;
    }

    .reaction-option {
        font-size: 1.1rem;
        padding: 4px;
    }

    .post-reactions {
        gap: 6px;
        margin-top: 10px;
        margin-bottom: 6px;
        margin-left: 0px;
    }

    .reaction-btn {
        padding: 3px 6px;
        font-size: 0.8rem;
    }

    .reaction-emoji {
        font-size: 1rem;
    }

    .reaction-count {
        font-size: 0.8rem;
        transform: translateY(-1px);
    }

    .reaction-btn.reaction-add {
        width: 28px;
        height: 28px;
    }

    .reaction-icon {
        width: 14px;
        height: 14px;
    }
}