body {
    font-family: "Inter", Arial, sans-serif;
    background: #f6f8fa;
    margin: 0;
    padding: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: #1a1a1a;
}

#main-container {
    display: none; /* hide by default */
}

/* --- App Header --- */
#app-header {
    position: fixed;
    top: 0;
    align-self: flex-start;
    padding-left: 20px;
    width: 100%;
    height: 60px;
    background: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    z-index: 1500;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 100%;
}

#app-logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
}

#app-name {
    font-size: 1.4rem;
    color: #333;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* Adjust main container to fit below header */
#main-container {
    grid-template-columns: 1fr 3fr;
    height: calc(100vh - 60px);
    margin-top: 60px; /* Offset header */
    overflow: hidden;
}


/* Loading state */
#loading {
    text-align: center;
    margin-top: 150px;
    color: #444;
    font-size: 16px;
}

/* Main layout */
#main-container {
    display: grid;
    grid-template-columns: 1fr 2fr; /* or 1fr 3fr if you want */
    height: calc(100vh - 60px);     /* viewport height minus header */
    margin-top: 60px;               /* offset for fixed header */
    overflow: hidden;
}

/* Post section */
#post-container {
    padding: 20px;
    border-right: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: #fff;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* Internet Explorer 10+ */
    height: 100%;      /* ADD THIS */
    min-height: 0;     /* ADD THIS */
}

#post-container::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Edge */
}


#post-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

#profile-img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

#username {
    font-weight: 600;
    font-size: 16px;
}

#shared-on {
    margin-left: auto;
    font-size: 13px;
    color: #666;
}

#post-title {
    font-size: 22px;
    font-weight: bold;
    margin: 8px 0;
}

#post-text {
    font-size: 15px;
    line-height: 1.6;
    color: #333;
}

#post-images {
    display: flex;
    flex-direction: row;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 0;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE & Edge */
    min-height: 250px;    /* ADD THIS */
    flex-shrink: 0; 
}

#post-images::-webkit-scrollbar {
    display: none; /* Chrome, Safari */
}

#post-images img {
    width: 250px;
    height: 250px;
    border-radius: 6px;
    flex-shrink: 0; /* Prevent images from shrinking */
    object-fit: cover;
}


#chat-count, #active-users {
    margin-top: 8px;
    color: #666;
    font-size: 14px;
}

/* Join button */
#join-btn {
    background: #2563eb;
    color: #fff;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    margin-top: 16px;
    transition: background 0.2s ease;
}

#join-btn:hover {
    background: #1d4ed8;
}

/* Chat box */
#chat-box {
    padding: 0;
    display: flex;
    flex-direction: column;
    background: #fff;
    height: 100%;
    overflow: hidden;
    border-left: 1px solid #ddd;
}

#chat-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 16px;
    min-height: 0;
    scroll-behavior: smooth;
}

.chat-message {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
}

.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-content {
    background: #f0f2f5;
    padding: 10px 14px;
    border-radius: 10px;
    max-width: 80%;
}

.chat-time {
    display: block;
    font-size: 12px;
    color: #888;
    margin-top: 4px;
}

/* Typing indicator */
#typing-indicator {
    color: #777;
    margin: 6px 16px;
    font-style: italic;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Chat form */
#chat-form {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    border-top: 1px solid #ddd;
    background: #fafafa;
}

#chat-input {
    height: 42px;
    flex: 1;
    padding: 0 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

#chat-input:focus {
    border-color: #2563eb;
}

#chat-form button {
    background: #2563eb;
    color: #fff;
    border: none;
    padding: 10px 16px;
    margin-left: 8px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s ease;
}

#chat-form button:hover {
    background: #1d4ed8;
}

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: #fff;
    padding: 20px;
    border-radius: 10px;
    width: 320px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.close-btn {
    float: right;
    cursor: pointer;
    font-size: 20px;
    color: #666;
}

#auth-tabs {
    margin-bottom: 10px;
}

#auth-tabs button {
    margin: 4px;
    padding: 6px 12px;
    border: 1px solid #2563eb;
    border-radius: 6px;
    background: #fff;
    color: #2563eb;
    cursor: pointer;
    font-weight: 500;
}

#auth-tabs button:hover {
    background: #2563eb;
    color: #fff;
}


/* Fullscreen image viewer */
.image-modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.95);
    overflow-x: scroll;
    overflow-y: hidden;
    white-space: nowrap;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    z-index: 2000;
}

.image-modal::-webkit-scrollbar {
    display: none; /* Hide scrollbar */
}

#modal-slider {
    display: flex;
    height: 100%;
    width: 100%;
}

#modal-slider img {
    width: 100vw;
    height: 100vh;
    object-fit: contain;
    scroll-snap-align: center;
    flex-shrink: 0;
    user-select: none;
}

#close-modal {
    position: fixed;
    top: 20px;
    right: 30px;
    font-size: 36px;
    color: white;
    cursor: pointer;
    z-index: 2100;
    transition: opacity 0.2s;
}

#close-modal:hover {
    opacity: 0.8;
}

.download-app {
    margin-right: 70px
}

.download-app a {
    text-decoration: none;
    background-color: #007bff;
    color: #fff;
    padding: 9px 16px;
    border-radius: 20px;
    font-size: 1rem;
    font-weight: 500;
    font-family: "Inter", "Segoe UI", sans-serif;
    transition: background 0.2s ease;
}

.download-app a:hover {
    background-color: #0056b3;
}

#share-btn {
    background: none;
    border: 1px solid #dfdfdf;
    cursor: pointer;
    padding: 2px 10px;
    border-radius: 20px;
    margin-left: 10px;
    transition: color 0.2s;
}

#share-btn:hover {
    color: #1d4ed8;
}

#share-btn img {
    display: block;
    width: 20px;
    height: 20px;
}



/* Responsive Design */
@media (max-width: 900px) {
    body {
        overflow-y: auto !important;
        height: auto !important;
        min-height: 100dvh !important; /* dynamic mobile height */
    }

    #main-container {
        height: auto !important;
        min-height: calc(100dvh - 60px) !important;
        overflow: visible !important;
    }

    #chat-form {
        position: fixed !important;
        bottom: 0;
        left: 0;
        width: 100%;
        background: #fff;
        z-index: 1000;
        border-top: 1px solid #ddd;
        padding: 8px 12px;
    }

    #chat-container {
        padding-bottom: 70px !important; /* space for fixed input */
    }

    #main-container {
        grid-template-columns: 1fr;
    }

    #post-container {
        border-right: none;
        border-bottom: 1px solid #ddd;
        height: fit-content;
    }

    #post-images {
        min-height: auto !important;  /* let height adapt */
        height: auto !important;      /* remove fixed height */
        padding: 5px 0 !important;    /* reduce vertical padding */
        gap: 6px !important;          /* reduce horizontal gap */
    }
    #chat-count, #active-users {
        margin-top: 4px !important;
        font-size: 13px !important;
    }



    #chat-box {
        /*height: 60vh;*/
    }

    #post-images img {
        width: 50px;
        height: 50px;
    }

    #post-text {
        display: -webkit-box;
        -webkit-line-clamp: 3; /* show only 2 lines */
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
        cursor: pointer; /* clickable */
        max-height: 4.5em;
    }

    .download-app {
        margin-right: 30px
    }

    #username {
        font-weight: 600;
        font-size: 14px;
    }

    #profile-img {
        width: 30px;
        height: 30px;
    }

    #shared-on {
        margin-left: auto;
        font-size: 13px;
        color: #666;
    }

    #post-title {
        font-size: 17px;
        font-weight: bold;
        margin: 2px 0;
    }

    #post-text {
        font-size: 15px;
        line-height: 1.6;
        color: #333;
    }

    #share-btn img {
        display: block;
        width: 16px;
        height: 16px;
    }

    #share-btn {
        padding: 2px 6px;
    }
    #typing-indicator {
        position: fixed !important; /* stay above the input */
        bottom: 60px;               /* adjust based on input height */
        left: 16px;
        right: 16px;
        display: flex !important;
        align-items: center;
        gap: 6px;
        z-index: 1001;
        background: rgba(255, 255, 255, 0.9);
        padding: 4px 8px;
        border-radius: 8px;
        font-size: 12px;
    }

    #post-text.expanded {
        display: block;
        -webkit-line-clamp: unset;
        -webkit-box-orient: unset;
        overflow: visible;
        text-overflow: unset;
        max-height: none;
    }
    .post-text-expanded {
        display: block !important;
        -webkit-line-clamp: unset !important;
        overflow: visible !important;
    }
    #read-more-toggle {
        color: #2563eb;
        cursor: pointer;
        display: none;
    }

}