/* Retain original responsive and theme styles, but adapt for Instagram-like layout */
@media (max-width: 600px) {
    html, body {
        width: 100vw;
        overflow-x: hidden !important;
        margin: 0;
        padding: 0;
    }
    .content {
        padding: 14px 0 80px 0;
        width: 100%;
        max-width: 100%;
        min-height: calc(100vh - 64px - 60px);
        box-sizing: border-box;
        margin: 0;
    }
    .header {
        font-size: 1.05rem;
        padding: 10px;
        width: 100vw;
        box-sizing: border-box;
    }
    .footer {
        left: 0;
        bottom: 0;
        width: 100vw;
        position: fixed;
        box-sizing: border-box;
    }
    .footer a { font-size: 20px; }
    .modal-content {
        max-width: 98vw;
        width: 98vw;
        min-width: 0;
        padding: 18px 6vw 16px 6vw;
        border-radius: 12px;
        font-size: 1rem;
    }
    .modal-content h3 {
        font-size: 1.15rem;
    }
    .modal-content label,
    .modal-content input[type="text"],
    .modal-content input[type="password"],
    .modal-content button {
        font-size: 1rem;
    }
    .close {
        top: 8px;
        right: 12px;
        font-size: 1.5rem;
    }
    .feed-post {
        max-width: 100%;
    }
    .stories {
        padding: 0 10px;
    }
}
:root {
    --primary: #4a4fcf;
    --primary-dark: #3a3fb0;
    --bg: #f3f3f3;
    --text: #222;
    --btn-text: #fff;
    --header-bg: #4a4fcf;
    --header-text: #fff;
}
[data-theme="dark"] {
    --primary: #222b45;
    --primary-dark: #151a30;
    --bg: #181a20;
    --text: #f3f3f3;
    --btn-text: #fff;
    --header-bg: #222b45;
    --header-text: #fff;
}
[data-theme="forest"] {
    --primary: #388e3c;
    --primary-dark: #256029;
    --bg: #e8f5e9;
    --text: #1b3a1b;
    --btn-text: #fff;
    --header-bg: #388e3c;
    --header-text: #fff;
}
[data-theme="ocean"] {
    --primary: #1976d2;
    --primary-dark: #0d47a1;
    --bg: #e3f2fd;
    --text: #0d223a;
    --btn-text: #fff;
    --header-bg: #1976d2;
    --header-text: #fff;
}
[data-theme="rose"] {
    --primary: #d81b60;
    --primary-dark: #880e4f;
    --bg: #fff1f6;
    --text: #3a1b2f;
    --btn-text: #fff;
    --header-bg: #d81b60;
    --header-text: #fff;
}
body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: background 0.3s, color 0.3s;
}
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: var(--header-bg);
    color: var(--header-text);
    font-size: 1.5rem;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    position: relative;
    transition: background 0.3s, color 0.3s;
}
.header .logo {
    font-size: 1.8rem;
    font-weight: bold;
}
.header .icons {
    display: flex;
    gap: 15px;
    font-size: 1.5rem;
    cursor: pointer;
    align-items: center;
}
.header .icons i:hover {
    opacity: 0.7;
}
.content {
    flex: 1 0 auto;
    padding: 20px 20px 80px 20px;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    margin-top: 0 !important;
    padding-top: 0 !important;
}
.stories {
    display: flex;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid #ddd;
    margin-bottom: 20px;
    overflow-x: auto;
}
.story {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(45deg, #f09433 0%,#e6683c 25%,#dc2743 50%,#cc2366 75%,#bc1888 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}
.story img {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: 2px solid white;
    object-fit: cover;
}
.feed {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.feed-post {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    max-width: 100%;
}
.post-header {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    gap: 10px;
}
.post-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #e0e0de;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.post-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}
.post-user {
    font-weight: 600;
    color: #333;
}
.post-image {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
}
.post-actions {
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
}
.post-actions-left {
    display: flex;
    gap: 15px;
    font-size: 1.5rem;
    cursor: pointer;
}
.post-actions-left i:hover {
    color: #e6683c;
}
.post-likes {
    font-weight: 600;
    padding: 0 15px 5px;
}
.post-caption {
    padding: 0 15px 10px;
}
.post-comments {
    padding: 0 15px 10px;
    border-top: 1px solid #eee;
}
.comment {
    margin-bottom: 8px;
}
.comment-user {
    font-weight: 600;
    margin-right: 8px;
}
.add-comment {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    border-top: 1px solid #eee;
    gap: 10px;
}
.add-comment input {
    flex: 1;
    border: none;
    outline: none;
    padding: 8px;
}
.add-comment button {
    background: none;
    border: none;
    color: #4a4fcf;
    font-weight: 600;
    cursor: pointer;
}
.footer {
    background: var(--primary);
    display: flex;
    justify-content: space-around;
    padding: 14px 0 10px;
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    z-index: 1002;
    box-shadow: 0 -3px 8px rgba(0, 0, 0, 0.15);
    transition: background 0.3s;
}
.footer a {
    text-decoration: none;
    color: black;
    font-size: 24px;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: color 0.2s ease;
}
.footer a.active::before {
    content: "";
    width: 50px;
    height: 50px;
    background: var(--primary);
    border-radius: 50%;
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
}
.footer a.active i {
    font-size: 30px;
    transform: translateY(-5px);
    z-index: 2;
}
.footer a:hover {
    color: #2c3abf;
}

/* Modal styling */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.3s ease;
}
.hidden {
    display: none !important;
    opacity: 0;
}
.modal-content {
    max-width: 500px;
    width: 90vw;
    background: white;
    max-height: 85vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    border-radius: 20px;
    box-shadow: 0 8px 28px rgba(60, 60, 60, 0.25);
    padding: 28px 30px 22px 30px;
    gap: 1.5em;
    position: relative;
    box-sizing: border-box;
}
.modal-content h3 {
    margin: 0 0 20px;
    color: #3a6ea5;
    text-align: center;
    font-weight: 700;
    font-size: 1.5rem;
    user-select: none;
}
.modal-content label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: #222;
    font-size: 1rem;
}
.modal-content input[type="text"],
.modal-content input[type="password"] {
    width: 95%;
    padding: 10px 14px;
    border: 1.8px solid #d1d1d1;
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.2s ease;
    outline-offset: 2px;
}
.modal-content input[type="text"]:focus,
.modal-content input[type="password"]:focus {
    border-color: #4a4fcf;
    outline: none;
}
.modal-content button {
    margin-top: 14px;
    background: #4a4fcf;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    padding: 12px 0;
    cursor: pointer;
    transition: background-color 0.25s ease;
    font-weight: 700;
    user-select: none;
}
.modal-content button:hover {
    background: #3a3ecf;
}
.modal-content p {
    text-align: center;
    font-size: 0.9rem;
    color: #666;
    user-select: none;
}
.modal-content p a {
    color: #4a4fcf;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s ease;
}
.modal-content p a:hover {
    color: #3a3ecf;
}
.close {
    position: absolute;
    top: 14px;
    right: 20px;
    font-size: 2rem;
    color: #666;
    cursor: pointer;
    user-select: none;
    transition: color 0.25s ease;
}
.close:hover {
    color: #4a4fcf;
}
.auth-footer-btn {
    background: #4a4fcf;
    color: white;
    border-radius: 12px;
    padding: 12px 0;
    font-size: 1.05rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background-color 0.25s ease;
    user-select: none;
}
.auth-footer-btn:hover {
    background: #3a3ecf;
}
.signout-btn {
    background: #d9534f;
    margin-top: 0;
}
.signout-btn:hover {
    background: #b43734;
}
/* Add styles for post modal */
.post-modal .modal-content {
    max-width: 400px;
}
.post-form textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    resize: none;
    height: 80px;
}
.post-form input[type="url"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
}
/* Responsive tweaks */
@media (max-width: 600px) {
    .feed-post {
        border-radius: 0;
    }
}
/* Desktop feed layout: image + actions on left, text on right (stacked properly) */
@media (min-width: 900px) {
    .feed-post {
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        background: white;
        border-radius: 12px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        overflow: hidden;
        margin-bottom: 30px;
    }

    /* Left side (image + like/comment buttons) */
    .feed-post .post-left {
        flex: 0 0 45%;
        display: flex;
        flex-direction: column;
        border-right: 1px solid #eee;
    }

    .feed-post .post-image {
        width: 100%;
        height: auto;
        object-fit: cover;
        display: block;
    }

    .feed-post .post-actions {
        display: flex;
        justify-content: space-between;
        padding: 10px 15px;
        border-top: 1px solid #eee;
    }

    /* Right side (text/comments stacked vertically) */
    .feed-post .post-right {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        padding: 10px 15px;
    }

    .feed-post .post-header {
        display: flex;
        align-items: center;
        gap: 10px;
        border-bottom: 1px solid #eee;
        padding-bottom: 8px;
        margin-bottom: 8px;
    }

    .feed-post .post-caption,
    .feed-post .post-likes,
    .feed-post .post-comments,
    .feed-post .add-comment {
        margin-bottom: 10px;
    }

    .feed-post .post-comments {
        border-top: 1px solid #eee;
        padding-top: 8px;
        max-height: 200px;
        overflow-y: auto;
    }

    .feed-post .add-comment {
        display: flex;
        align-items: center;
        gap: 8px;
        border-top: 1px solid #eee;
        padding-top: 8px;
    }

    .content {
        max-width: 900px;
        margin: 90px auto 90px auto;
        padding: 0 20px;
    }
}
/* === Smooth responsive layout between mobile & desktop === */

/* Base: mobile-first (already stacked) */
.feed-post {
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}

/* Desktop (≥900px): image left, text right */
@media (min-width: 900px) {
    .feed-post {
        flex-direction: row;
        align-items: flex-start;
        background: white;
        border-radius: 12px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        overflow: hidden;
        margin-bottom: 30px;
        transition: all 0.3s ease;
    }

    .feed-post .post-left {
        flex: 0 0 45%;
        display: flex;
        flex-direction: column;
        border-right: 1px solid #eee;
        transition: all 0.3s ease;
    }

    .feed-post .post-right {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        padding: 10px 15px;
        transition: all 0.3s ease;
    }

    .feed-post .post-header {
        background: #fafafa;
        border-bottom: 1px solid #eee;
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 12px 15px;
        transition: background 0.3s ease;
    }

    .feed-post .post-image {
        width: 100%;
        height: auto;
        display: block;
        object-fit: cover;
        transition: all 0.3s ease;
    }

    .feed-post .post-actions {
        display: flex;
        justify-content: space-between;
        padding: 10px 15px;
        border-top: 1px solid #eee;
        transition: all 0.3s ease;
    }

    .feed-post .post-right .post-comments {
        border-top: 1px solid #eee;
        margin-top: 10px;
        max-height: 200px;
        overflow-y: auto;
        transition: all 0.3s ease;
    }

    .feed-post .add-comment {
        display: flex;
        align-items: center;
        gap: 8px;
        border-top: 1px solid #eee;
        padding-top: 8px;
        transition: all 0.3s ease;
    }

    .content {
        max-width: 900px;
        margin: 90px auto 90px auto;
        padding: 0 20px;
        transition: all 0.3s ease;
    }
}
/* === End smooth responsive layout === */

.fab {
    position: fixed;
    bottom: 80px;
    right: 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    font-size: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.25);
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease;
    z-index: 2000;
}
.fab:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.welcome-banner {
    text-align: center;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--btn-text);
    padding: 18px 14px;
    border-radius: 16px;
    margin: 15px auto 15px auto; /* smaller top space */
    max-width: 900px;
    box-shadow: 0 3px 12px rgba(0,0,0,0.15);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.welcome-banner:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(0,0,0,0.25);
}

.welcome-banner h2 {
    margin: 0 0 6px 0;
    font-weight: 700;
}

.welcome-banner p {
    margin: 0;
    opacity: 0.9;
}

/* --- Fade animation for welcome message --- */
#welcomeTitle,
#welcomeSubtitle {
    transition: opacity 0.4s ease;
}

.fade-out {
    opacity: 0;
}

.fade-in {
    opacity: 1;
}

/* --- Enhanced mobile look --- */
@media (max-width: 899px) {
    .feed {
        padding-bottom: 80px; /* room above footer */
    }

    .feed-post {
        border-radius: 16px;
        overflow: hidden;
        background: white;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
        margin-bottom: 22px;
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }

    .feed-post:active {
        transform: scale(0.99);
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    }

    .feed-post .post-header {
        background: #fafafa;
        border-bottom: 1px solid #eee;
    }

    .feed-post .post-image {
        border-radius: 0;
    }

    .feed-post .post-actions {
        border-top: 1px solid #eee;
    }
}
/* --- End enhanced mobile look --- */