:root {
    --primary: #6366f1;
    /* Indigo */
    --primary-hover: #4f46e5;
    --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --card-bg: rgba(255, 255, 255, 0.85);
    --glass-border: 1px solid rgba(255, 255, 255, 0.3);
    --text-main: #1e293b;
    --text-secondary: #64748b;
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --radius: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    opacity: 0;
    animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes likeBounce {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.3);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes storySpin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Layout - Robust Fixes */
.app-container {
    display: flex;
    justify-content: center;
    max-width: 1280px;
    margin: 0 auto;
    min-height: 100vh;
    padding: 0 20px;
    gap: 30px;
    font-family: 'Inter', sans-serif;
}

body {
    background: var(--bg-gradient);
    min-height: 100vh;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--text-main);
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s;
}

/* Sidebar */
.sidebar {
    width: 240px;
    padding: 40px 10px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    flex-shrink: 0;
    border-right: 1px solid rgba(0, 0, 0, 0.05);
    background: transparent;
    display: flex;
    flex-direction: column;
}

@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
}

.sidebar-logo {
    font-family: 'Inter', sans-serif;
    font-size: 26px;
    font-weight: 800;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 40px;
    padding-left: 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    margin-bottom: 6px;
    border-radius: 12px;
    color: var(--text-main);
    font-weight: 600;
    transition: all 0.2s;
    font-size: 15px;
}

.nav-item:hover,
.nav-item.active {
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    color: var(--primary);
    transform: translateX(5px);
}

.nav-item i {
    font-size: 20px;
    margin-right: 16px;
    width: 24px;
    text-align: center;
}

/* Main Content Area */
.main-content {
    flex: 1;
    max-width: 600px;
    padding: 40px 0;
    width: 100%;
}

/* Right Sidebar (Suggestions) */
.right-sidebar {
    width: 300px;
    padding: 40px 0;
    position: sticky;
    top: 0;
    height: 100vh;
    flex-shrink: 0;
    display: none;
}

@media (min-width: 1100px) {
    .right-sidebar {
        display: block;
    }
}

/* Stories */
.stories-container {
    display: flex;
    gap: 16px;
    padding: 24px;
    background: white;
    border-radius: 20px;
    margin-bottom: 30px;
    overflow-x: auto;
    scrollbar-width: none;
    border: 1px solid rgba(0, 0, 0, 0.04);
    box-shadow: var(--shadow);
    white-space: nowrap;
}

.stories-container::-webkit-scrollbar {
    display: none;
}

.story-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    min-width: 74px;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.story-item:hover {
    transform: translateY(-3px);
}

.story-ring {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    padding: 3px;
    background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
    position: relative;
    margin-bottom: 6px;
}

.story-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid #fff;
    object-fit: cover;
    background: #fff;
}

.story-username {
    font-size: 11px;
    color: var(--text-secondary);
    max-width: 70px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Posts */
.post-card {
    background: white;
    border-radius: 20px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.03);
}

.post-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.post-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #e2e8f0;
}

.post-username {
    font-weight: 700;
    color: var(--text-main);
    font-size: 15px;
}

.post-image {
    width: 100%;
    height: auto;
    display: block;
    max-height: 700px;
    object-fit: cover;
    background: #f1f5f9;
}

.post-actions {
    padding: 16px 20px 0;
    font-size: 24px;
    display: flex;
    gap: 20px;
    color: #475569;
}

.post-action-btn:hover,
.btn-like:hover {
    color: var(--primary);
    transform: scale(1.15);
}

.post-likes {
    padding: 4px 20px;
    margin-top: 12px;
    font-weight: 700;
    color: var(--text-main);
}

.post-caption {
    padding: 0 20px;
    margin-bottom: 12px;
    color: #334155;
    line-height: 1.6;
}

.post-time {
    padding: 0 20px 24px;
    font-size: 12px;
    color: #94a3b8;
    font-weight: 500;
}

/* Suggestion Card */
.suggestion-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.suggestion-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-follow {
    color: var(--primary);
    font-weight: 600;
    font-size: 12px;
    background: none;
    border: none;
    cursor: pointer;
}

/* Auth Pages */
.auth-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background: url('https://images.unsplash.com/photo-1557683316-973673baf926?auto=format&fit=crop&w=2629&q=80') center/cover no-repeat;
    position: relative;
}

.auth-wrapper::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    z-index: 1;
}

.auth-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border: var(--glass-border);
    border-radius: var(--radius);
    padding: 48px;
    width: 100%;
    max-width: 420px;
    text-align: center;
    box-shadow: var(--shadow);
    z-index: 2;
    position: relative;
}

.auth-logo {
    font-size: 36px;
    font-weight: 800;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 32px;
    display: block;
    font-family: 'Inter', sans-serif;
    letter-spacing: -1px;
}

.input-group {
    margin-bottom: 16px;
}

.input-group input {
    width: 100%;
    padding: 14px 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    font-size: 15px;
    outline: none;
}

.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 14px;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    margin-top: 12px;
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.3);
}

.auth-switch {
    margin-top: 24px;
    font-size: 14px;
    color: var(--text-secondary);
}

.auth-switch a {
    color: var(--primary);
    font-weight: 600;
}

/* Modal */
.modal-content {
    background: white;
    padding: 32px;
    border-radius: 24px;
    width: 90%;
    max-width: 480px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: modalSlideIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalSlideIn {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Profile Specifics */
.profile-header {
    display: flex;
    align-items: center;
    gap: 40px;
    padding: 30px;
    margin-bottom: 30px;
    background: white;
    border-radius: 24px;
    box-shadow: var(--shadow);
    flex-wrap: wrap;
}

.profile-pic-lg {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid #fff;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.profile-user-settings {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.profile-username {
    font-size: 32px;
    font-weight: 300;
    margin: 0;
}

.profile-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.btn-profile-action {
    background: #efefef;
    color: var(--text-main);
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-profile-action:hover {
    background: #dbdbdb;
}

.btn-edit {
    background: transparent;
    border: 1px solid #dbdbdb;
}

.profile-stats {
    display: flex;
    gap: 30px;
    margin-bottom: 20px;
    font-size: 16px;
}

.stat-count {
    font-weight: 700;
    color: var(--text-main);
}

.profile-realname {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 4px;
}

.profile-bio {
    font-size: 15px;
    color: var(--text-main);
}

.profile-tabs {
    border-top: 1px solid #dbdbdb;
    display: flex;
    justify-content: center;
    gap: 60px;
    margin-bottom: 20px;
}

.tab-item {
    padding: 16px 0;
    color: #8e8e8e;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tab-item.active {
    color: var(--text-main);
    border-top: 1px solid var(--text-main);
    margin-top: -1px;
}

.posts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 28px;
}

.grid-item {
    position: relative;
    padding-bottom: 100%;
    overflow: hidden;
    border-radius: 12px;
    cursor: pointer;
}

.grid-item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.grid-item:hover img {
    transform: scale(1.05);
}

/* Grid Overlay */
.grid-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    gap: 30px;
    font-size: 18px;
    font-weight: bold;
}

.grid-item:hover .grid-overlay {
    opacity: 1;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 24px;
}