/* ============================================
   SOCIAL APP - MASTER STYLESHEET
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f0f2f5;
    color: #1a1a2e;
    min-height: 100vh;
    overflow-x: hidden;
    width: 100%;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: #4a6cf7;
}

/* ========== GUEST LAYOUT ========== */
.guest-layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: #f0f2f5;
}

.guest-header {
    background: white;
    border-bottom: 1px solid #e1e5e9;
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.guest-header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.guest-header .logo a {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.guest-header .logo h1 {
    font-size: 24px;
    font-weight: 700;
    color: #4a6cf7;
}

.guest-header .logo i {
    font-size: 24px;
    color: #4a6cf7;
}

.guest-nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

.guest-nav a {
    color: #1a1a2e;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background 0.3s;
}

.guest-nav a:hover {
    background: #f0f2f5;
}

.guest-nav .btn {
    background: #4a6cf7;
    color: white;
    padding: 8px 20px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
    touch-action: manipulation;
}

.guest-nav .btn:hover {
    background: #3a56d4;
}

.guest-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    min-height: calc(100vh - 140px);
}

/* ========== AUTH PAGES ========== */
.auth-container {
    width: 100%;
    max-width: 400px;
    padding: 10px;
}

.auth-box {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: #1a1a2e;
}

.auth-header p {
    color: #666;
    margin-top: 5px;
    font-size: 15px;
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e1e5e9;
}

.auth-footer p {
    margin: 4px 0;
    font-size: 14px;
    color: #666;
}

.auth-footer a {
    color: #4a6cf7;
    font-weight: 500;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* ========== FORM ELEMENTS ========== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.3s;
    font-family: inherit;
    background: white;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #4a6cf7;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: #666;
    font-size: 12px;
}

/* ========== BUTTONS ========== */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s, transform 0.1s;
    display: inline-block;
    text-align: center;
    min-height: 44px;
    touch-action: manipulation;
}

.btn-primary {
    background: #4a6cf7;
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: #3a56d4;
}

.btn-secondary {
    background: #e1e5e9;
    color: #333;
}

.btn-secondary:hover {
    background: #d1d5d9;
}

/* ========== ALERTS ========== */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

/* ========== APP LAYOUT ========== */
.hybrid-layout {
    display: flex;
    min-height: 100vh;
    background: #f0f2f5;
}

/* ========== LEFT SIDEBAR ========== */
.left-sidebar {
    width: 240px;
    background: white;
    border-right: 1px solid #e1e5e9;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    flex-shrink: 0;
    z-index: 100;
}

.sidebar-brand {
    padding: 0 20px 20px;
    border-bottom: 1px solid #f0f2f5;
}

.sidebar-brand a {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    font-size: 22px;
    font-weight: 700;
    color: #1a1a2e;
}

.sidebar-brand i {
    font-size: 28px;
    color: #4a6cf7;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: 10px;
    color: #1a1a2e;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.2s;
    position: relative;
    min-height: 48px;
}

.sidebar-nav a:hover {
    background: #f0f2f5;
    color: #4a6cf7;
}

.sidebar-nav a.active {
    background: #eef0ff;
    color: #4a6cf7;
}

.sidebar-nav a i {
    width: 24px;
    font-size: 20px;
    text-align: center;
}

.sidebar-nav a .badge {
    background: #dc3545;
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: auto;
}

.sidebar-nav a.logout-link {
    margin-top: 20px;
    border-top: 1px solid #f0f2f5;
    padding-top: 20px;
    color: #dc3545;
}

.sidebar-nav a.logout-link:hover {
    background: #fee2e2;
    color: #991b1b;
}

.sidebar-user {
    padding: 16px 20px;
    border-top: 1px solid #f0f2f5;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-user img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.sidebar-user strong {
    display: block;
    font-size: 14px;
    color: #1a1a2e;
}

.sidebar-user small {
    color: #666;
    font-size: 12px;
}

/* ========== MAIN CONTENT ========== */
.main-content {
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    margin-left: 240px;
}

.content-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 24px;
    width: 100%;
    flex: 1;
    padding-bottom: 60px;
}

/* ========== MOBILE HEADER ========== */
.mobile-header {
    display: none;
    background: white;
    padding: 4px 10px;
    border-bottom: 1px solid #e1e5e9;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    min-height: 52px;
}

.mobile-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    color: #1a1a2e;
}

.mobile-brand i {
    font-size: 27px;
    color: #4a6cf7;
}

.mobile-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.mobile-header-action {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    border-radius: 50%;
    color: #1a1a2e;
    text-decoration: none;
    transition: background-color 0.2s, transform 0.1s;
    touch-action: manipulation;
}

.mobile-header-action:active {
    transform: scale(0.92);
    background-color: #f0f2f5;
}

.mobile-header-action i {
    font-size: 18px;
}

.mobile-header-action .badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: #dc3545;
    color: white;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 10px;
    min-width: 14px;
    text-align: center;
    line-height: 1.4;
    border: 2px solid white;
}

.mobile-toggle {
    background: none;
    border: none;
    font-size: 24px;
    color: #1a1a2e;
    cursor: pointer;
    padding: 4px 8px;
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
}

.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
}

.mobile-overlay.active {
    display: block !important;
}

body.sidebar-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
}

/* ========== FEED ========== */
.feed-container {
    max-width: 680px;
    margin: 0 auto;
}

.feed-wrapper {
    display: flex;
    gap: 24px;
    max-width: 1200px;
    margin: 0 auto;
}

.feed-wrapper>div:first-child {
    flex: 1;
    min-width: 0;
}

/* Base mobile layout (Flex Column) */
.feed-layout-grid {
    display: flex;
    flex-direction: column;
}
.stories-bar { order: 1; max-width: 680px; width: 100%; margin-left: auto; margin-right: auto; }
.right-sidebar { order: 2; margin-bottom: 16px; position: static; width: 100%; flex-shrink: 0; }
.create-post { order: 3; max-width: 680px; width: 100%; margin-left: auto; margin-right: auto; }
.feed-posts { order: 4; max-width: 680px; width: 100%; margin-left: auto; margin-right: auto; }

/* Desktop layout (CSS Grid) */
@media (min-width: 992px) {
    .feed-layout-grid {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 16px 24px;
        align-items: start;
    }
    .stories-bar { grid-column: 1 / 3; order: unset; margin-bottom: 0; }
    .right-sidebar { grid-column: 2 / 3; grid-row: 2 / 4; order: unset; margin-bottom: 0; position: sticky; top: 20px; width: 280px; }
    .create-post { grid-column: 1 / 2; order: unset; margin-bottom: 16px; }
    .feed-posts { grid-column: 1 / 2; order: unset; }
}

/* ========== STORIES BAR ========== */
.stories-bar {
    background: white;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    gap: 16px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.stories-bar::-webkit-scrollbar {
    display: none;
}

.story-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    flex-shrink: 0;
}

.story-item .story-ring {
    position: relative;
    width: 68px;
    height: 68px;
    border-radius: 50%;
    padding: 3px;
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.story-item:hover .story-ring {
    transform: scale(1.05);
}

.story-item .story-ring.viewed {
    background: #e1e5e9;
}

.story-item .story-ring.own {
    background: transparent;
    border: 1px solid #e1e5e9;
    padding: 2px;
}

.story-item .story-media {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid white;
}

.story-item .story-name {
    font-size: 11px;
    color: #666;
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
}

/* ========== CREATE POST ========== */
.create-post {
    background: white;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.post-input {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.post-input textarea {
    flex: 1;
    border: none;
    padding: 8px 0;
    font-size: 15px;
    resize: none;
    font-family: inherit;
    min-height: 50px;
}

.post-input textarea:focus {
    outline: none;
}

.post-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid #e1e5e9;
    flex-wrap: wrap;
    gap: 8px;
}

.post-actions .btn-file {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #666;
    cursor: pointer;
    font-size: 14px;
    padding: 6px 12px;
    border-radius: 8px;
    transition: background 0.3s;
}

.post-actions .btn-file:hover {
    background: #f0f2f5;
}

.post-actions .btn {
    width: auto;
    padding: 8px 24px;
}

/* ========== POST CARD ========== */
.post-card {
    background: white;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.post-header {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
}

.post-header .avatar-medium {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
}

.post-user {
    flex: 1;
}

.post-user strong {
    display: block;
    font-size: 15px;
}

.post-user .username-text {
    color: #666;
    font-size: 13px;
}

.post-user .post-time {
    color: #999;
    font-size: 12px;
}

.post-content p {
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 10px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.post-image {
    width: 100%;
    height: auto;
    max-height: 600px;
    object-fit: contain;
    background: #000;
    border-radius: 8px;
    margin-top: 8px;
    transform: translateZ(0);
    will-change: transform;
}

.post-image.loading {
    min-height: 200px;
    background: linear-gradient(90deg, #f0f2f5 25%, #e1e5e9 50%, #f0f2f5 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

.post-media-container {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
    margin-top: 8px;
}

.post-media-container video {
    width: 100%;
    max-height: 500px;
    object-fit: contain;
    display: block;
}

.post-footer {
    display: flex;
    gap: 24px;
    border-top: 1px solid #f0f2f5;
    margin-top: 2px;
    flex-wrap: wrap;
}

.post-footer button {
    background: none;
    border: none;
    color: #666;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
    min-height: 40px;
    min-width: 40px;
    touch-action: manipulation;
}

.post-footer button:hover {
    background: #f0f2f5;
}

.post-footer button.liked {
    color: #dc3545;
}

.post-footer button.liked i {
    color: #dc3545;
}

/* ========== RIGHT SIDEBAR ========== */
.right-sidebar .suggestion-card {
    background: white;
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.right-sidebar .suggestion-card h4 {
    font-size: 14px;
    color: #666;
    margin-bottom: 12px;
}

/* Mobile Suggestions Carousel */
.suggestions-list {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    gap: 12px;
    padding-bottom: 8px;
    scrollbar-width: none; /* Firefox */
}
.suggestions-list::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.suggestion-item {
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 140px;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 16px 12px;
}

.suggestion-item img {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 10px;
}

.suggestion-item .suggestion-info {
    width: 100%;
    margin-bottom: 10px;
}

.suggestion-item .suggestion-info strong {
    display: block;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.suggestion-item .suggestion-info small {
    color: #666;
    font-size: 12px;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.suggestion-item .follow-btn {
    background: #4a6cf7;
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    min-height: 32px;
    touch-action: manipulation;
}

.suggestion-item .follow-btn:hover {
    background: #3a56d4;
}

/* Desktop Suggestions Vertical List */
@media (min-width: 992px) {
    .suggestions-list {
        flex-direction: column;
        overflow-x: visible;
        gap: 0;
        padding-bottom: 0;
    }
    
    .suggestion-item {
        flex-direction: row;
        align-items: center;
        text-align: left;
        width: auto;
        border: none;
        border-bottom: 1px solid #f0f2f5;
        border-radius: 0;
        padding: 8px 0;
    }
    
    .suggestion-item:last-child {
        border-bottom: none;
    }
    
    .suggestion-item img {
        width: 36px;
        height: 36px;
        margin-bottom: 0;
        margin-right: 12px;
    }
    
    .suggestion-item .suggestion-info {
        margin-bottom: 0;
        flex: 1;
    }
    
    .suggestion-item .follow-btn {
        width: auto;
        min-width: 56px;
    }
}

/* ========== NO POSTS ========== */
.no-posts {
    background: white;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    color: #666;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.no-posts i {
    display: block;
    font-size: 48px;
    color: #ccc;
    margin-bottom: 16px;
}

.no-posts p {
    font-size: 15px;
}

.no-posts strong {
    color: #1a1a2e;
}

/* ========== COMMENTS ========== */
.comments-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #f0f2f5;
}

.comment-list {
    margin-bottom: 10px;
}

.comment-item {
    display: flex;
    gap: 10px;
    padding: 6px 0;
    align-items: flex-start;
}

.comment-item .comment-user {
    font-weight: 600;
    font-size: 13px;
}

.comment-item .comment-text {
    font-size: 14px;
    color: #333;
}

.comment-input {
    display: flex;
    gap: 10px;
}

.comment-input input {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid #e1e5e9;
    border-radius: 20px;
    font-size: 14px;
    font-family: inherit;
}

.comment-input input:focus {
    outline: none;
    border-color: #4a6cf7;
}

.comment-input button {
    padding: 10px 20px;
    background: #4a6cf7;
    color: white;
    border: none;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
}

/* ========== MODAL ========== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-box {
    background: white;
    padding: 30px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-box h3 {
    margin-bottom: 20px;
    font-size: 22px;
}

/* ========== AVATARS ========== */
.avatar-small {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.avatar-medium {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.avatar-large {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
}

/* ============================================
   PROFILE PAGE - CLEAN ARCHITECTURE
   ============================================ */

/* Profile Wrapper - Same as feed */
.profile-wrapper {
    max-width: 680px;
    margin: 0 auto;
    padding: 0 16px;
    width: 100%;
}

/* Profile Card */
.profile-card {
    background: white;
    border-radius: 12px;
    padding: 24px 20px 16px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* Avatar */
.profile-avatar-wrapper {
    flex-shrink: 0;
    margin-bottom: 12px;
}

.profile-avatar-border {
    border: 4px solid white;
    border-radius: 50%;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    display: inline-block;
}

.profile-avatar-border img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

/* User Info */
.profile-user-info {
    width: 100%;
    margin-bottom: 16px;
}

.profile-full-name {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 2px;
    color: #1a1a2e;
    overflow-wrap: break-word;
    word-break: break-word;
}

.profile-username {
    color: #666;
    margin: 0 0 8px;
    font-size: 15px;
    overflow-wrap: break-word;
    word-break: break-word;
}

.profile-bio {
    color: #333;
    font-size: 14px;
    line-height: 1.5;
    margin: 0 0 8px;
    overflow-wrap: break-word;
    word-break: break-word;
}

.profile-private-badge {
    font-size: 12px;
    color: #4a6cf7;
    background: #eef0ff;
    padding: 4px 10px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Actions */
.profile-actions-wrapper {
    width: 100%;
    margin-bottom: 16px;
}

.profile-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    width: 100%;
}

.profile-action-btn {
    flex: 1;
    min-width: 100px;
    max-width: 200px;
    padding: 8px 16px;
    font-size: 14px;
    width: auto;
    justify-content: center;
    min-height: 44px;
}

.profile-action-btn.followed {
    background: #e1e5e9;
    color: #1a1a2e;
}

.profile-action-btn.requested {
    background: #ffc107;
    color: #1a1a2e;
}

/* Stats */
.profile-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    width: 100%;
    border-top: 1px solid #f0f2f5;
    padding-top: 16px;
}

.profile-stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.profile-stat-number {
    font-weight: 700;
    font-size: 18px;
    color: #1a1a2e;
}

.profile-stat-label {
    font-size: 13px;
    color: #666;
}

/* ============================================
   PROFILE TABS
   ============================================ */
.profile-tabs {
    background: white;
    border-radius: 12px;
    padding: 0 12px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow-x: auto;
    display: flex;
    flex-wrap: nowrap;
    border-bottom: 1px solid #e1e5e9;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.profile-tabs::-webkit-scrollbar {
    display: none;
}

.profile-tabs a {
    padding: 14px 16px;
    color: #666;
    text-decoration: none;
    font-weight: 400;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.2s;
    touch-action: manipulation;
    font-size: 14px;
}

.profile-tabs a:hover {
    color: #4a6cf7;
}

.profile-tabs a.active {
    color: #4a6cf7;
    font-weight: 600;
    border-bottom-color: #4a6cf7;
}

/* ============================================
   PROFILE CONTENT AREAS
   ============================================ */
.profile-content-area {
    width: 100%;
}

.profile-post-item {
    background: white;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    position: relative;
    max-width: 100%;
}

.delete-post-form {
    float: right;
}

.profile-post-item .delete-post-btn {
    background: none;
    border: none;
    color: #ccc;
    cursor: pointer;
    font-size: 16px;
    touch-action: manipulation;
    padding: 4px;
}

.profile-post-item .delete-post-btn:hover {
    color: #dc3545;
}

.profile-post-item .post-text {
    font-size: 15px;
    line-height: 1.6;
    margin: 0 0 10px;
    overflow-wrap: break-word;
    word-break: break-word;
}

.profile-post-item .post-image {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 8px;
}

.profile-post-item .post-meta {
    display: flex;
    gap: 16px;
    color: #666;
    font-size: 13px;
    padding-top: 8px;
    border-top: 1px solid #f0f2f5;
    flex-wrap: wrap;
}

/* ============================================
   PROFILE EMPTY STATES
   ============================================ */
.profile-no-posts {
    background: white;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    color: #999;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.profile-no-posts i {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
    color: #ddd;
}

.profile-private-box {
    background: white;
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.profile-private-box i {
    font-size: 48px;
    color: #4a6cf7;
    display: block;
    margin-bottom: 16px;
}

.profile-private-box h3 {
    margin-bottom: 8px;
    font-size: 18px;
}

.profile-private-box p {
    color: #666;
    margin-bottom: 16px;
    font-size: 14px;
}

.profile-private-box .btn {
    width: auto;
    padding: 10px 30px;
}

/* ============================================
   PROFILE ABOUT CARD
   ============================================ */
.profile-about-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.profile-about-card h4 {
    margin: 0 0 16px;
}

.profile-about-item {
    margin-bottom: 12px;
}

.profile-about-item:last-child {
    margin-bottom: 0;
}

.profile-about-item strong {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    color: #1a1a2e;
}

.profile-about-item p {
    color: #333;
    word-wrap: break-word;
    margin: 0;
}

/* ============================================
   PROFILE FRIENDS CARD
   ============================================ */
.profile-friends-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.profile-friends-card h4 {
    margin: 0 0 16px;
}

.profile-friends-empty {
    color: #999;
    text-align: center;
    margin: 0;
}

.profile-friends-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 110px), 1fr));
    gap: 12px;
}

.profile-friend-item {
    text-decoration: none;
    color: #333;
    text-align: center;
    padding: 12px 8px;
    border: 1px solid #f0f2f5;
    border-radius: 8px;
    transition: background 0.2s;
    overflow: hidden;
}

.profile-friend-item:hover {
    background: #f8f9fa;
}

.profile-friend-item img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 6px;
}

.profile-friend-item .friend-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-friend-item .friend-username {
    font-size: 11px;
    color: #999;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================
   PROFILE PHOTOS CARD
   ============================================ */
.profile-photos-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.profile-photos-card h4 {
    margin: 0 0 16px;
}

.profile-photos-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}

.profile-photo-item {
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 4px;
    background: #f0f2f5;
}

.profile-photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ============================================
   PROFILE CLIPS
   ============================================ */
.profile-clips-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    margin-bottom: 16px;
}

.profile-clip-item {
    aspect-ratio: 9/16;
    overflow: hidden;
    border-radius: 4px;
    background: #000;
    position: relative;
}

.profile-clip-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.profile-clip-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(220, 53, 69, 0.8);
    border: none;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    touch-action: manipulation;
}

.profile-clip-delete:hover {
    background: rgba(220, 53, 69, 1);
}

/* ============================================
   EDIT PROFILE MODAL
   ============================================ */
.edit-profile-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    align-items: center;
    justify-content: center;
}

.edit-profile-modal.active {
    display: flex;
}

.edit-profile-modal .modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.edit-profile-modal .modal-content h3 {
    margin-bottom: 20px;
    font-size: 22px;
}

.edit-profile-modal .modal-content h3 i {
    color: #4a6cf7;
    margin-right: 10px;
}

.edit-profile-modal .modal-subtitle {
    color: #666;
    font-size: 13px;
    margin-bottom: 16px;
}

.edit-profile-modal .modal-content .form-group {
    margin-bottom: 20px;
}

.edit-profile-modal .modal-content .form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.edit-profile-modal .modal-content .form-group input,
.edit-profile-modal .modal-content .form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.3s;
    box-sizing: border-box;
}

.edit-profile-modal .modal-content .form-group input:focus,
.edit-profile-modal .modal-content .form-group textarea:focus {
    outline: none;
    border-color: #4a6cf7;
}

.edit-profile-modal .modal-content .form-group input[type="file"] {
    padding: 8px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    width: 100%;
    box-sizing: border-box;
}

.edit-profile-modal .modal-content .form-group small {
    display: block;
    margin-top: 5px;
    color: #666;
    font-size: 12px;
}

.edit-profile-modal .modal-content .form-group input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
}

.edit-profile-modal .modal-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.edit-profile-modal .modal-actions .btn {
    flex: 1;
    min-width: 120px;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
    min-height: 44px;
}

.edit-profile-modal .modal-actions .btn-primary {
    background: #4a6cf7;
    color: white;
}

.edit-profile-modal .modal-actions .btn-primary:hover {
    background: #3a56d4;
}

.edit-profile-modal .modal-actions .btn-secondary {
    background: #e1e5e9;
    color: #333;
}

.edit-profile-modal .modal-actions .btn-secondary:hover {
    background: #d1d5d9;
}

#clipUploadProgress {
    display: none;
    text-align: center;
    padding: 20px;
}

#clipUploadProgress i {
    font-size: 24px;
    color: #4a6cf7;
}

#clipUploadProgress p {
    margin-top: 8px;
    color: #666;
}

/* ============================================
   RESPONSIVE - TABLET (600px and up)
   ============================================ */
@media (min-width: 600px) {
    .profile-wrapper {
        padding: 0 24px;
    }

    .profile-card {
        padding: 32px 32px 20px;
    }

    .profile-avatar-border img {
        width: 100px;
        height: 100px;
    }

    .profile-full-name {
        font-size: 26px;
    }

    .profile-action-btn {
        min-width: 120px;
        max-width: 220px;
    }

    .profile-stats {
        gap: 16px;
        padding-top: 20px;
    }

    .profile-stat-number {
        font-size: 20px;
    }
}

/* ============================================
   RESPONSIVE - DESKTOP (1024px and up)
   ============================================ */
@media (min-width: 1024px) {
    .profile-wrapper {
        max-width: 680px;
        padding: 0 24px;
    }

    .profile-avatar-border img {
        width: 120px;
        height: 120px;
    }

    .profile-full-name {
        font-size: 28px;
    }
}

/* ============================================
   RESPONSIVE - MOBILE (max-width: 768px)
   ============================================ */
@media (max-width: 767px) {
    .profile-wrapper {
        padding: 0 12px;
    }

    .profile-card {
        padding: 16px 12px;
    }

    .profile-avatar-border img {
        width: 72px;
        height: 72px;
    }

    .profile-full-name {
        font-size: 20px;
    }

    .profile-username {
        font-size: 14px;
    }

    .profile-bio {
        font-size: 13px;
    }

    .profile-action-btn {
        min-width: 80px;
        font-size: 13px;
        padding: 6px 12px;
    }

    .profile-stats {
        gap: 4px;
        padding-top: 14px;
    }

    .profile-stat-number {
        font-size: 16px;
    }

    .profile-stat-label {
        font-size: 12px;
    }

    .profile-tabs {
        padding: 0 8px;
    }

    .profile-tabs a {
        padding: 12px 10px;
        font-size: 13px;
    }

    .profile-post-item {
        padding: 12px 14px;
    }

    .profile-photos-grid,
    .profile-clips-grid {
        gap: 2px;
    }

    .profile-friends-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 80px), 1fr));
        gap: 8px;
    }

    .edit-profile-modal .modal-content {
        padding: 16px;
        width: 95%;
    }

    .edit-profile-modal .modal-content h3 {
        font-size: 18px;
        margin-bottom: 16px;
    }

    .edit-profile-modal .modal-actions .btn {
        padding: 10px;
        font-size: 14px;
    }
}

/* ============================================
   RESPONSIVE - SMALL PHONES (max-width: 480px)
   ============================================ */
@media (max-width: 480px) {
    .profile-wrapper {
        padding: 0 8px;
    }

    .profile-card {
        padding: 12px 8px;
    }

    .profile-avatar-border img {
        width: 64px;
        height: 64px;
    }

    .profile-full-name {
        font-size: 18px;
    }

    .profile-username {
        font-size: 13px;
    }

    .profile-bio {
        font-size: 12px;
    }

    .profile-action-btn {
        min-width: 60px;
        font-size: 12px;
        padding: 6px 8px;
    }

    .profile-stats {
        gap: 2px;
        padding-top: 12px;
    }

    .profile-stat-number {
        font-size: 14px;
    }

    .profile-stat-label {
        font-size: 11px;
    }

    .profile-tabs a {
        padding: 10px 8px;
        font-size: 12px;
    }

    .profile-post-item {
        padding: 10px 12px;
    }

    .profile-post-item .post-text {
        font-size: 14px;
    }
}

/* ============================================
   RESPONSIVE - 300px WIDTH SPECIFIC
   ============================================ */
@media (max-width: 360px) {
    .profile-wrapper {
        padding: 0 4px;
    }

    .profile-card {
        padding: 10px 8px;
    }

    .profile-avatar-border img {
        width: 56px;
        height: 56px;
    }

    .profile-full-name {
        font-size: 16px;
    }

    .profile-username {
        font-size: 12px;
    }

    .profile-bio {
        font-size: 11px;
    }

    .profile-actions {
        flex-direction: column;
        align-items: center;
        gap: 6px;
    }

    .profile-action-btn {
        min-width: 60px;
        max-width: 100%;
        width: 100%;
        font-size: 12px;
        padding: 6px 10px;
        min-height: 36px;
    }

    .profile-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 4px;
        padding-top: 10px;
    }

    .profile-stat-number {
        font-size: 14px;
    }

    .profile-stat-label {
        font-size: 10px;
    }

    .profile-tabs {
        padding: 0 4px;
    }

    .profile-tabs a {
        padding: 8px 6px;
        font-size: 10px;
    }

    .profile-post-item {
        padding: 8px 10px;
    }

    .profile-post-item .post-text {
        font-size: 13px;
    }
}

/* ============================================
   RESPONSIVE - TABLET (769px to 1024px)
   ============================================ */
@media (min-width: 768px) and (max-width: 1194px) {
    .left-sidebar {
        width: 72px !important;
    }

    .main-content {
        margin-left: 72px !important;
    }

    .left-sidebar .sidebar-brand span,
    .left-sidebar .sidebar-nav a span,
    .left-sidebar .sidebar-user div {
        display: none !important;
    }

    .left-sidebar .sidebar-nav a {
        justify-content: center !important;
        padding: 14px !important;
    }

    .left-sidebar .sidebar-nav a i {
        font-size: 22px !important;
        margin: 0 !important;
    }

    .left-sidebar .sidebar-user {
        justify-content: center !important;
        padding: 12px !important;
    }

    .left-sidebar .sidebar-user img {
        width: 32px !important;
        height: 32px !important;
    }

    .sidebar-nav a .badge {
        position: absolute;
        top: 2px;
        right: 2px;
        font-size: 9px;
        padding: 1px 6px;
    }

    body.clips-page .main-content {
        margin-left: 72px !important;
    }
}

@media (max-width: 1194px) {
    aside.right-sidebar:not(#suggestions-container) {
        display: none !important;
    }
    aside.right-sidebar#suggestions-container {
        display: block !important;
    }
}

/* ============================================
   RESPONSIVE - MOBILE (max-width: 768px)
   ============================================ */
@media (max-width: 767px) {
    .left-sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        width: 280px;
        height: 100vh;
        z-index: 200;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 2px 0 20px rgba(0, 0, 0, 0.15);
        border-right: none;
        padding: 0;
        overflow-y: auto;
    }

    .left-sidebar.open {
        left: 0;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .left-sidebar .sidebar-brand {
        padding: 16px 20px;
        border-bottom: 1px solid #f0f2f5;
    }

    .left-sidebar .sidebar-brand span {
        display: inline;
        font-size: 20px;
    }

    .left-sidebar .sidebar-nav a {
        justify-content: flex-start;
        padding: 14px 20px;
        border-radius: 0;
    }

    .left-sidebar .sidebar-nav a span {
        display: inline;
        font-size: 15px;
    }

    .left-sidebar .sidebar-nav a i {
        font-size: 20px;
        width: 28px;
    }

    .left-sidebar .sidebar-user {
        justify-content: flex-start;
        padding: 16px 20px;
        border-top: 1px solid #f0f2f5;
    }

    .left-sidebar .sidebar-user div {
        display: block;
    }

    .mobile-header {
        display: flex !important;
    }

    .content-wrapper {
        padding: 12px 10px !important;
        max-width: 100% !important;
    }

    .feed-container {
        max-width: 100% !important;
        padding: 0;
    }

    .feed-wrapper {
        flex-direction: column !important;
        gap: 0 !important;
        max-width: 100% !important;
    }

    .feed-wrapper>div:first-child {
        width: 100% !important;
        flex: 1 !important;
    }

    .stories-bar {
        padding: 10px 12px !important;
        gap: 12px !important;
    }

    .story-item .story-avatar {
        width: 56px !important;
        height: 56px !important;
        border-width: 2px !important;
    }

    .story-item .story-name {
        font-size: 10px !important;
        max-width: 60px !important;
    }

    .create-post {
        padding: 12px 14px !important;
    }

    .post-input textarea {
        font-size: 14px !important;
    }

    .post-actions .btn {
        width: 100% !important;
        padding: 10px !important;
    }

    .post-card {
        padding: 12px 14px !important;
    }

    .post-header .avatar-medium {
        width: 36px !important;
        height: 36px !important;
    }

    .post-content p {
        font-size: 14px !important;
    }

    .post-image {
        max-height: 300px !important;
        max-width: 100% !important;
        height: auto !important;
    }

    .post-footer button {
        font-size: 13px !important;
        min-height: 40px !important;
        min-width: 40px !important;
    }

    .no-posts {
        padding: 30px 20px !important;
    }

    .auth-container {
        padding: 10px !important;
        margin: 0 auto !important;
        max-width: 100% !important;
    }

    .auth-box {
        padding: 24px !important;
    }

    .auth-header h1 {
        font-size: 24px !important;
    }

    .guest-header .guest-header-content {
        padding: 0 16px !important;
    }

    .guest-header .logo h1 {
        font-size: 20px !important;
    }

    .guest-nav a {
        font-size: 13px !important;
        padding: 6px 12px !important;
    }

    .guest-nav .btn {
        padding: 6px 14px !important;
        font-size: 13px !important;
    }

    .guest-main {
        padding: 10px !important;
        min-height: calc(100vh - 60px) !important;
    }

    .comment-input input {
        max-width: calc(100% - 80px) !important;
    }

    .mobile-toggle {
        display: none !important;
    }

    .content-wrapper,
    .feed-wrapper,
    .main-content {
        padding-bottom: 75px !important;
    }

    /* ========== MOBILE BOTTOM NAV ========== */
    .mobile-bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 10px;
        background: #ffffff;
        border-top: 1px solid #dbdbdb;
        justify-content: space-around;
        align-items: center;
        z-index: 9999;
        padding: 0 8px env(safe-area-inset-bottom);
        box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.05);
    }

    .mobile-bottom-nav .nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        color: #8e8e8e;
        text-decoration: none;
        font-size: 10px;
        padding: 4px 8px;
        min-width: 44px;
        height: 100%;
        transition: color 0.15s ease;
        -webkit-tap-highlight-color: transparent;
        position: relative;
        gap: 2px;
    }

    .mobile-bottom-nav .nav-item i {
        font-size: 24px;
        color: #8e8e8e;
    }

    .mobile-bottom-nav .nav-item .nav-label {
        font-size: 9px;
        font-weight: 500;
        color: #8e8e8e;
    }

    .mobile-bottom-nav .nav-item.active,
    .mobile-bottom-nav .nav-item.active i,
    .mobile-bottom-nav .nav-item.active .nav-label,
    .mobile-bottom-nav .nav-item:hover,
    .mobile-bottom-nav .nav-item:hover i {
        color: #000000;
    }

    .mobile-bottom-nav .nav-add {
        background: #4a6cf7;
        color: white !important;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        display: flex !important;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        margin-top: -16px;
        box-shadow: 0 2px 8px rgba(74, 108, 247, 0.3);
        padding: 0;
        min-width: 44px;
    }

    .mobile-bottom-nav .nav-add i {
        font-size: 22px;
        color: white !important;
    }

    .mobile-bottom-nav .nav-add .nav-label {
        color: white !important;
        font-size: 8px;
        margin-top: 2px;
    }

    .mobile-bottom-nav .nav-add:active {
        transform: scale(0.92);
    }

    .mobile-bottom-nav .nav-avatar {
        width: 26px;
        height: 26px;
        border-radius: 50%;
        object-fit: cover;
        border: 2px solid transparent;
        transition: border-color 0.15s ease;
        display: block;
    }

    .mobile-bottom-nav .nav-item.active .nav-avatar {
        border-color: #000000;
    }

    .mobile-bottom-nav .nav-item .fa-user {
        font-size: 22px;
        color: #8e8e8e;
    }

    .mobile-bottom-nav .nav-item.active .fa-user {
        color: #000000;
    }

    .mobile-bottom-nav .nav-badge {
        position: absolute;
        top: 2px;
        right: 2px;
        background: #dc3545;
        color: white;
        font-size: 9px;
        font-weight: 700;
        padding: 1px 5px;
        border-radius: 10px;
        min-width: 16px;
        text-align: center;
        line-height: 1.4;
        border: 2px solid white;
    }

    body.clips-page .mobile-bottom-nav {
        background: rgba(0, 0, 0, 0.85) !important;
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
        border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 99999 !important;
        height: 60px !important;
    }

    body.clips-page .mobile-bottom-nav .nav-item,
    body.clips-page .mobile-bottom-nav .nav-item i,
    body.clips-page .mobile-bottom-nav .nav-item .nav-label {
        color: rgba(255, 255, 255, 0.5) !important;
    }

    body.clips-page .mobile-bottom-nav .nav-item.active,
    body.clips-page .mobile-bottom-nav .nav-item.active i,
    body.clips-page .mobile-bottom-nav .nav-item.active .nav-label {
        color: #ffffff !important;
    }

    body.clips-page .mobile-bottom-nav .nav-add {
        background: #4a6cf7 !important;
        box-shadow: 0 2px 12px rgba(74, 108, 247, 0.4) !important;
    }

    body.clips-page .mobile-bottom-nav .nav-badge {
        border-color: rgba(0, 0, 0, 0.85) !important;
    }
}

/* ============================================
   RESPONSIVE - SMALL PHONES (max-width: 480px)
   ============================================ */
@media (max-width: 480px) {
    .content-wrapper {
        padding: 8px 6px !important;
    }

    .stories-bar {
        padding: 8px 10px !important;
        gap: 8px !important;
    }

    .story-item .story-avatar {
        width: 48px !important;
        height: 48px !important;
    }

    .story-item .story-name {
        font-size: 9px !important;
        max-width: 48px !important;
    }

    .create-post {
        padding: 10px 12px !important;
    }

    .post-card {
        padding: 10px 12px !important;
    }

    .post-content p {
        font-size: 13px !important;
    }

    .post-image {
        max-height: 200px !important;
    }

    .post-footer {
        gap: 12px !important;
    }

    .post-footer button {
        font-size: 12px !important;
    }

    .mobile-brand {
        font-size: 16px !important;
    }

    .mobile-brand i {
        font-size: 20px !important;
    }

    .mobile-toggle {
        font-size: 20px !important;
    }

    .alert {
        padding: 10px 12px !important;
        font-size: 13px !important;
    }

    .no-posts {
        padding: 20px 16px !important;
    }

    .no-posts i {
        font-size: 28px !important;
    }

    .auth-box {
        padding: 16px !important;
    }

    .auth-header h1 {
        font-size: 20px !important;
    }

    .auth-header p {
        font-size: 13px !important;
    }

    .auth-box .form-group input {
        padding: 10px 12px !important;
        font-size: 14px !important;
    }

    .auth-footer {
        font-size: 12px !important;
    }

    .guest-header .guest-header-content {
        padding: 0 12px !important;
    }

    .guest-header .logo h1 {
        font-size: 17px !important;
    }

    .guest-nav a {
        font-size: 12px !important;
        padding: 4px 10px !important;
    }

    .guest-nav .btn {
        padding: 4px 12px !important;
        font-size: 12px !important;
    }

    .avatar-small {
        width: 28px !important;
        height: 28px !important;
    }

    .avatar-medium {
        width: 32px !important;
        height: 32px !important;
    }

    .avatar-large {
        width: 64px !important;
        height: 64px !important;
    }

    .mobile-bottom-nav {
        height: 54px;
        padding: 0 4px env(safe-area-inset-bottom);
    }

    .mobile-bottom-nav .nav-item {
        padding: 2px 4px;
        min-width: 36px;
    }

    .mobile-bottom-nav .nav-item i {
        font-size: 20px;
    }

    .mobile-bottom-nav .nav-item .nav-label {
        font-size: 8px;
    }

    .mobile-bottom-nav .nav-add {
        width: 40px;
        height: 40px;
        min-width: 40px;
        margin-top: -14px;
    }

    .mobile-bottom-nav .nav-add i {
        font-size: 18px;
    }

    .mobile-bottom-nav .nav-avatar {
        width: 22px;
        height: 22px;
    }

    .mobile-bottom-nav .nav-badge {
        font-size: 8px;
        min-width: 14px;
        padding: 0 4px;
        top: 1px;
        right: 1px;
    }

    .content-wrapper,
    .feed-wrapper,
    .main-content {
        padding-bottom: 65px !important;
    }
}

/* ============================================
   TABLET AND DESKTOP LAYOUT OVERRIDES (min-width: 769px)
   ============================================ */
@media (min-width: 768px) {
    .mobile-bottom-nav {
        display: none !important;
    }

    .left-sidebar {
        display: flex !important;
    }
}

@media (min-width: 1195px) {
    .main-content {
        margin-left: 240px !important;
    }
}

@media (min-width: 1195px) {
    body.clips-page .main-content {
        margin-left: 240px !important;
    }
}

/* ============================================
   NOTCH PHONE SAFE AREAS
   ============================================ */
@supports (padding: max(0px)) {
    .left-sidebar {
        padding-top: max(20px, env(safe-area-inset-top));
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }

    .mobile-header {
        padding-top: max(10px, env(safe-area-inset-top));
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }

    .auth-container {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
    }

    .mobile-bottom-nav {
        padding-left: max(8px, env(safe-area-inset-left));
        padding-right: max(8px, env(safe-area-inset-right));
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }
}

/* ============================================
   TOUCH OPTIMIZATION
   ============================================ */
@media (pointer: coarse) {
    .sidebar-nav a {
        min-height: 48px !important;
    }

    .post-footer button {
        min-height: 40px !important;
        min-width: 40px !important;
    }

    .mobile-toggle {
        min-height: 44px !important;
        min-width: 44px !important;
    }

    .follow-btn {
        min-height: 36px !important;
        min-width: 56px !important;
    }

    .btn {
        min-height: 44px !important;
    }
}

/* ============================================
   DARK COLOR SCHEME PREFERENCE
   ============================================ */
@media (prefers-color-scheme: dark) {
    .mobile-bottom-nav {
        background: #1a1a2e;
        border-top-color: #2a2a3e;
    }

    .mobile-bottom-nav .nav-item,
    .mobile-bottom-nav .nav-item i,
    .mobile-bottom-nav .nav-item .nav-label {
        color: #8e8e8e;
    }

    .mobile-bottom-nav .nav-item.active,
    .mobile-bottom-nav .nav-item.active i,
    .mobile-bottom-nav .nav-item.active .nav-label {
        color: #ffffff;
    }

    .mobile-bottom-nav .nav-item.active .nav-avatar {
        border-color: #ffffff;
    }

    .mobile-bottom-nav .nav-add {
        background: #4a6cf7;
    }

    .mobile-bottom-nav .nav-badge {
        border-color: #1a1a2e;
    }
}

/* ============================================
   INSTAGRAM-STYLE PROFILE (MIGRATED)
   ============================================ */

/* ============================================
   INSTAGRAM-STYLE PROFILE
   ============================================ */

/* Profile Header */
.ig-profile-header {
    background: white;
    padding: 16px;
    margin-bottom: 0;
}

/* Profile Info Row - Avatar + Stats */
.ig-profile-top {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 16px;
}

.ig-avatar-wrapper {
    flex-shrink: 0;
}

.ig-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #fff;
    box-shadow: 0 0 0 1px #dbdbdb;
}

.ig-stats-row {
    display: flex;
    flex: 1;
    justify-content: space-around;
    gap: 8px;
}

.ig-stat-item {
    text-align: center;
}

.ig-stat-number {
    display: block;
    font-size: 18px;
    font-weight: 700;
    color: #1a1a2e;
}

.ig-stat-label {
    font-size: 12px;
    color: #666;
}

/* Profile Name & Bio */
.ig-name {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 4px;
    color: #1a1a2e;
}

.ig-bio {
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    margin: 0 0 4px;
    word-wrap: break-word;
}

.ig-bio a {
    color: #00376b;
    text-decoration: none;
}

.ig-bio a:hover {
    text-decoration: underline;
}

.ig-bio .ig-link {
    color: #00376b;
    font-weight: 500;
}

.ig-followed-by {
    font-size: 13px;
    color: #666;
    margin: 4px 0;
}

.ig-followed-by strong {
    color: #1a1a2e;
}

/* Action Buttons */
.ig-actions {
    display: flex;
    gap: 8px;
    margin: 12px 0 16px;
    flex-wrap: wrap;
}

.ig-action-btn {
    flex: 1;
    min-width: 80px;
    padding: 7px 16px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid #dbdbdb;
    border-radius: 8px;
    background: white;
    color: #1a1a2e;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    min-height: 32px;
    touch-action: manipulation;
}

.ig-action-btn:hover {
    background: #f0f2f5;
}

.ig-action-btn.primary {
    background: #0095f6;
    color: white;
    border-color: #0095f6;
}

.ig-action-btn.primary:hover {
    background: #0081d6;
}

.ig-action-btn.following {
    background: #e1e5e9;
    color: #1a1a2e;
    border-color: #dbdbdb;
}

/* Highlight Categories */
.ig-highlights {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-top: 1px solid #dbdbdb;
    margin-bottom: 8px;
    overflow-x: auto;
    scrollbar-width: none;
}

.ig-highlights::-webkit-scrollbar {
    display: none;
}

.ig-highlight-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    flex-shrink: 0;
}

.ig-highlight-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid #dbdbdb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #666;
    background: #f8f9fa;
}

.ig-highlight-label {
    font-size: 11px;
    color: #666;
    max-width: 64px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Profile Tabs - Instagram Style */
.ig-tabs {
    display: flex;
    border-top: 1px solid #dbdbdb;
    background: white;
    margin-bottom: 0;
}

.ig-tab {
    flex: 1;
    text-align: center;
    padding: 12px 0;
    color: #666;
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    border-top: 1px solid transparent;
    transition: all 0.2s;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ig-tab i {
    font-size: 16px;
    display: block;
    margin-bottom: 2px;
}

.ig-tab.active {
    color: #1a1a2e;
    border-top-color: #1a1a2e;
}

.ig-tab:hover {
    color: #1a1a2e;
}

/* Post Grid - Instagram Style */
.ig-post-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    background: #f0f2f5;
}

.ig-post-item {
    aspect-ratio: 1;
    overflow: hidden;
    background: #f0f2f5;
    position: relative;
}

.ig-post-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ig-post-item .ig-post-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    opacity: 0;
    transition: opacity 0.2s;
    color: white;
    font-size: 14px;
    font-weight: 600;
}

.ig-post-item:hover .ig-post-overlay {
    opacity: 1;
}

.ig-post-overlay span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.ig-post-overlay i {
    font-size: 16px;
}

/* Empty State */
.ig-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.ig-empty-state i {
    font-size: 48px;
    color: #ddd;
    display: block;
    margin-bottom: 16px;
}

.ig-empty-state h3 {
    color: #1a1a2e;
    font-size: 18px;
    margin: 0 0 4px;
}

.ig-empty-state p {
    font-size: 14px;
    margin: 0;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 767px) {
    .ig-avatar {
        width: 64px;
        height: 64px;
    }

    .ig-stat-number {
        font-size: 16px;
    }

    .ig-stat-label {
        font-size: 11px;
    }

    .ig-name {
        font-size: 18px;
    }

    .ig-actions {
        gap: 6px;
    }

    .ig-action-btn {
        font-size: 13px;
        padding: 6px 12px;
        min-height: 30px;
    }

    .ig-highlight-circle {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }

    .ig-highlight-label {
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    .ig-avatar {
        width: 56px;
        height: 56px;
    }

    .ig-stat-number {
        font-size: 14px;
    }

    .ig-stat-label {
        font-size: 10px;
    }

    .ig-name {
        font-size: 16px;
    }

    .ig-bio {
        font-size: 13px;
    }

    .ig-action-btn {
        font-size: 12px;
        padding: 5px 8px;
        min-height: 28px;
    }

    .ig-tab {
        font-size: 10px;
        padding: 10px 0;
    }

    .ig-tab i {
        font-size: 14px;
    }
}

@media (max-width: 360px) {
    .ig-profile-top {
        gap: 12px;
    }

    .ig-avatar {
        width: 48px;
        height: 48px;
    }

    .ig-stat-number {
        font-size: 12px;
    }

    .ig-stat-label {
        font-size: 9px;
    }

    .ig-actions {
        flex-wrap: wrap;
    }

    .ig-action-btn {
        font-size: 11px;
        padding: 4px 6px;
        min-height: 26px;
        min-width: 60px;
    }

    .ig-highlight-circle {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .ig-highlight-label {
        font-size: 9px;
    }
}


/* ============================================
   CHAT / MESSAGES SYSTEM (MIGRATED)
   ============================================ */

/* ============================================
   CHAT / MESSAGES SYSTEM (REDESIGNED)
   ============================================ */
:root {
    /* Default Theme */
    --chat-bg: #ffffff;
    --chat-sidebar-bg: #f8f9fa;
    --chat-messages-bg: #f8f9fa;
    --chat-border: #e1e5e9;
    --chat-text: #333333;
    --chat-text-muted: #999999;
    --chat-bubble-own-bg: #4a6cf7;
    --chat-bubble-own-text: #ffffff;
    --chat-bubble-other-bg: #ffffff;
    --chat-bubble-other-text: #333333;
    --chat-input-bg: #ffffff;
    --chat-input-border: #e1e5e9;
    --chat-accent: #4a6cf7;
    --chat-accent-hover: #3a56d4;
    --chat-hover-bg: #f0f2f5;
    --chat-active-bg: #eef0ff;
}


[data-theme="dark"] {
    --chat-bg: #1e1e1e;
    --chat-sidebar-bg: #252526;
    --chat-messages-bg: #121212;
    --chat-border: #333333;
    --chat-text: #e0e0e0;
    --chat-text-muted: #aaaaaa;
    --chat-bubble-own-bg: #2b579a;
    --chat-bubble-own-text: #ffffff;
    --chat-bubble-other-bg: #252526;
    --chat-bubble-other-text: #e0e0e0;
    --chat-input-bg: #252526;
    --chat-input-border: #333333;
    --chat-accent: #3b82f6;
    --chat-accent-hover: #2563eb;
    --chat-hover-bg: #333333;
    --chat-active-bg: #2b579a;
}

[data-theme="cyberpunk"] {
    --chat-bg: #09090b;
    --chat-sidebar-bg: #09090b;
    --chat-messages-bg: #000000;
    --chat-border: #27272a;
    --chat-text: #e4e4e7;
    --chat-text-muted: #a1a1aa;
    --chat-bubble-own-bg: #06b6d4;
    --chat-bubble-own-text: #000000;
    --chat-bubble-other-bg: #18181b;
    --chat-bubble-other-text: #e4e4e7;
    --chat-input-bg: #18181b;
    --chat-input-border: #27272a;
    --chat-accent: #d946ef;
    --chat-accent-hover: #c026d3;
    --chat-hover-bg: #27272a;
    --chat-active-bg: #3f3f46;
}

[data-theme="love"] {
    --chat-bg: #fff0f5;
    --chat-sidebar-bg: #ffe4e1;
    --chat-messages-bg: #fff0f5;
    --chat-border: #ffb6c1;
    --chat-text: #4a0e2e;
    --chat-text-muted: #c97a95;
    --chat-bubble-own-bg: #ff69b4;
    --chat-bubble-own-text: #ffffff;
    --chat-bubble-other-bg: #ffffff;
    --chat-bubble-other-text: #4a0e2e;
    --chat-input-bg: #ffffff;
    --chat-input-border: #ffb6c1;
    --chat-accent: #ff1493;
    --chat-accent-hover: #c71585;
    --chat-hover-bg: #ffd1dc;
    --chat-active-bg: #ffb6c1;
}

[data-theme="ocean"] {
    --chat-bg: #e0f2f1;
    --chat-sidebar-bg: #b2dfdb;
    --chat-messages-bg: #e0f2f1;
    --chat-border: #80cbc4;
    --chat-text: #004d40;
    --chat-text-muted: #00796b;
    --chat-bubble-own-bg: #00897b;
    --chat-bubble-own-text: #ffffff;
    --chat-bubble-other-bg: #ffffff;
    --chat-bubble-other-text: #004d40;
    --chat-input-bg: #ffffff;
    --chat-input-border: #80cbc4;
    --chat-accent: #00796b;
    --chat-accent-hover: #004d40;
    --chat-hover-bg: #b2dfdb;
    --chat-active-bg: #80cbc4;
}

[data-theme="astrology"] {
    --chat-bg: #0f172a;
    --chat-sidebar-bg: #1e293b;
    --chat-messages-bg: #020617;
    --chat-border: #334155;
    --chat-text: #f8fafc;
    --chat-text-muted: #94a3b8;
    --chat-bubble-own-bg: #6366f1;
    --chat-bubble-own-text: #ffffff;
    --chat-bubble-other-bg: #1e293b;
    --chat-bubble-other-text: #f8fafc;
    --chat-input-bg: #1e293b;
    --chat-input-border: #334155;
    --chat-accent: #fbbf24;
    --chat-accent-hover: #f59e0b;
    --chat-hover-bg: #334155;
    --chat-active-bg: #475569;
}

/* Messages Architecture Flex Fixes */
body.messages-page,
body.messages-page html {
    height: 100dvh;
    overflow: hidden !important;
}

body.messages-page .hybrid-layout {
    height: 100dvh;
    overflow: hidden;
}

body.messages-page .main-content {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0 !important;
}

body.messages-page .content-wrapper {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
    flex: 1 1 auto !important;
    height: 100% !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    border: none !important;
}

.chat-container {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    margin: 0 !important;
    border-radius: 0 !important;
    background: var(--chat-bg);
    overflow: hidden;
    color: var(--chat-text);
}

.chat-sidebar {
    display: none;
    width: 100%;
    background: var(--chat-sidebar-bg);
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    border-right: 1px solid var(--chat-border);
}

.chat-sidebar.active {
    display: flex;
}

.chat-window {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    position: relative;
}

.chat-window.hidden {
    display: none;
}

.chat-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--chat-border);
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--chat-bg);
    flex-shrink: 0;
    z-index: 10;
}

.chat-header .back-btn {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    color: var(--chat-text);
}

.chat-header .header-profile-link {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    min-width: 0;
}

.chat-header img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.chat-header .chat-user-info {
    flex: 1;
    min-width: 0;
}

.chat-header .chat-user-info strong {
    font-size: 16px;
    display: block;
    color: var(--chat-text);
    font-weight: 600;
}

.chat-header .chat-user-info small {
    color: var(--chat-text-muted);
    font-size: 12px;
}

.chat-header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.theme-selector {
    background: var(--chat-input-bg);
    color: var(--chat-text);
    border: 1px solid var(--chat-input-border);
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 12px;
    outline: none;
    cursor: pointer;
}

.chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 16px;
    background: var(--chat-messages-bg);
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth;
}

.chat-messages .no-messages {
    text-align: center;
    padding: 40px 16px;
    color: var(--chat-text-muted);
    margin-top: auto;
    margin-bottom: auto;
}

.chat-messages .no-messages i {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
    opacity: 0.5;
}

.message-wrapper {
    display: flex;
    margin-bottom: 4px;
    animation: fadeIn 0.3s ease;
}

.message-wrapper.own {
    justify-content: flex-end;
}

.message-wrapper.other {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 70%;
    padding: 8px 14px;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    position: relative;
}

.message-bubble.own {
    background: var(--chat-bubble-own-bg);
    color: var(--chat-bubble-own-text);
    border-radius: 18px 18px 4px 18px;
}

.message-bubble.other {
    background: var(--chat-bubble-other-bg);
    color: var(--chat-bubble-other-text);
    border-radius: 18px 18px 18px 4px;
    border: 1px solid var(--chat-border);
}

.message-bubble p {
    margin: 0;
    font-size: 14px;
    line-height: 1.4;
}

.message-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: flex-end;
    margin-top: 4px;
}

.message-bubble .msg-time {
    font-size: 11px;
    opacity: 0.7;
}

.message-bubble.own .msg-status {
    font-size: 10px;
    opacity: 0.9;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-input {
    padding: 8px 12px;
    border-top: 1px solid var(--chat-border);
    background: var(--chat-bg);
    flex: 0 0 auto;
    z-index: 10;
}

.chat-input form {
    display: flex;
    gap: 12px;
    align-items: center;
}

.chat-input input[type="text"] {
    flex: 1;
    padding: 10px 14px;
    background: var(--chat-input-bg);
    border: 1px solid var(--chat-input-border);
    color: var(--chat-text);
    border-radius: 24px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.3s;
}

.chat-input input[type="text"]:focus {
    border-color: var(--chat-accent);
}

.chat-input button {
    background: var(--chat-accent);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.3s;
    flex-shrink: 0;
}

.chat-input button:hover {
    background: var(--chat-accent-hover);
}

.chat-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 30px;
    color: var(--chat-text-muted);
    background: var(--chat-bg);
}

.chat-empty i {
    font-size: 64px;
    opacity: 0.3;
    margin-bottom: 16px;
}

.chat-empty h3 {
    color: var(--chat-text);
    font-size: 22px;
    margin: 0 0 8px 0;
    font-weight: 600;
}

.chat-empty p {
    text-align: center;
    font-size: 15px;
    margin: 0;
}

.chat-empty a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--chat-accent);
    color: white;
    padding: 10px 20px;
    border-radius: 24px;
    margin-top: 16px;
    text-decoration: none;
    font-weight: 500;
    transition: background 0.2s;
}

.chat-empty a:hover {
    background: var(--chat-accent-hover);
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--chat-text);
    transition: background 0.2s;
    border-left: 3px solid transparent;
    cursor: pointer;
}

.conversation-item:hover {
    background: var(--chat-hover-bg);
}

.conversation-item.active {
    background: var(--chat-active-bg);
    border-left-color: var(--chat-accent);
}

.conversation-item img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.conversation-item .conv-info {
    flex: 1;
    min-width: 0;
}

.conversation-item .conv-info .conv-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.conversation-item .conv-info .conv-top strong {
    font-size: 15px;
    font-weight: 600;
}

.conversation-item .conv-info .conv-top small {
    color: var(--chat-text-muted);
    font-size: 11px;
}

.conversation-item .conv-info .conv-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
}

.conversation-item .conv-info .conv-bottom span {
    color: var(--chat-text-muted);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.conversation-item .unread-badge {
    background: var(--chat-accent);
    color: white;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

@media (max-width: 767px) {
    .chat-container {
        border: none !important;
        border-radius: 0 !important;
    }

    .chat-sidebar {
        display: flex;
        width: 100%;
        border-right: none;
    }

    .chat-sidebar.hidden {
        display: none;
    }

    .chat-window {
        display: none;
        width: 100%;
    }

    .chat-window.active {
        display: flex;
    }

    .chat-header .back-btn {
        display: block;
    }

    .message-bubble {
        max-width: 85%;
    }

    .chat-messages {
        padding: 12px;
    }

    .chat-input {
        padding: 10px 12px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }

    /* Hide the bottom navigation bar and mobile header when a conversation is active */
    .hybrid-layout:has(.chat-window.active) .mobile-bottom-nav,
    .main-content:has(.chat-window.active) .mobile-header {
        display: none !important;
    }

    /* Ensure layout wrappers expand to 100dvh when a conversation is active, giving input full space */
    body.messages-page:has(.chat-window.active) .main-content,
    body.messages-page:has(.chat-window.active) .chat-container,
    body.messages-page:has(.chat-window.active) .chat-window {
        height: 100dvh !important;
    }
}

@media (min-width: 768px) {
    .chat-container {
        flex-direction: row;
        border-radius: 12px !important;
        border: 1px solid var(--chat-border) !important;
        margin: 20px !important;
        height: calc(100dvh - 40px) !important;
        max-height: calc(100dvh - 40px) !important;
        flex: none !important;
    }

    .chat-sidebar {
        display: flex !important;
        width: 320px;
        height: 100%;
        min-height: 0;
    }

    .chat-window {
        display: flex !important;
        flex: 1;
        height: 100%;
        min-height: 0;
        flex-direction: column;
        overflow: hidden;
    }

    .chat-header .back-btn {
        display: none !important;
    }
}

@media (max-width:480px) {
    .message-bubble p {
        font-size: 14px;
    }

    .chat-header img {
        width: 36px;
        height: 36px;
    }

    .chat-header .chat-user-info strong {
        font-size: 15px;
    }

    .conversation-item {
        padding: 10px 12px;
    }

    .conversation-item img {
        width: 44px;
        height: 44px;
    }
}

/* ============================================
   TOAST NOTIFICATIONS AND CUSTOM CONFIRM
   ============================================ */
#toast-container {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
    width: 100%;
}

@media (min-width: 641px) {
    #toast-container {
        top: 20px;
        right: 20px;
    }
}

@media (max-width: 640px) {
    #toast-container {
        top: calc(env(safe-area-inset-top, 0px) + 16px);
        left: 50%;
        transform: translateX(-50%);
        padding: 0 16px;
        max-width: 100%;
    }
}

.toast-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #ffffff;
    color: #1e293b;
    padding: 14px 18px;
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    pointer-events: auto;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    transition: all 0.3s cubic-bezier(0.21, 1.02, 0.73, 1);
    transform: translateY(-20px);
    opacity: 0;
    border-left: 4px solid transparent;
}

@media (min-width: 641px) {
    .toast-card {
        transform: translateX(50px);
    }
}

.toast-card.show {
    transform: translate(0) !important;
    opacity: 1;
}

.toast-card.success {
    border-left-color: #10b981;
}

.toast-card.success i {
    color: #10b981;
}

.toast-card.error {
    border-left-color: #ef4444;
}

.toast-card.error i {
    color: #ef4444;
}

.toast-card.warning {
    border-left-color: #f59e0b;
}

.toast-card.warning i {
    color: #f59e0b;
}

.toast-card.info {
    border-left-color: #3b82f6;
}

.toast-card.info i {
    color: #3b82f6;
}

.toast-close {
    margin-left: auto;
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 14px;
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.toast-close:hover {
    background: #f1f5f9;
    color: #475569;
}

.custom-confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 10002;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease-in-out;
}

.custom-confirm-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.custom-confirm-modal {
    background: #ffffff;
    border-radius: 16px;
    padding: 24px;
    max-width: 340px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
    transform: scale(0.9);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.custom-confirm-overlay.active .custom-confirm-modal {
    transform: scale(1);
}

.confirm-icon {
    width: 48px;
    height: 48px;
    background: #fee2e2;
    color: #ef4444;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin: 0 auto 16px auto;
}

.confirm-message {
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    color: #334155;
    font-weight: 500;
    line-height: 1.5;
    margin-bottom: 24px;
}

.confirm-actions {
    display: flex;
    gap: 12px;
}

.confirm-actions button {
    flex: 1;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-confirm-cancel {
    background: #f1f5f9;
    color: #475569;
}

.btn-confirm-cancel:hover {
    background: #e2e8f0;
}

.btn-confirm-ok {
    background: #dc3545;
    color: #ffffff;
}

.btn-confirm-ok:hover {
    background: #c82333;
}

@media (prefers-color-scheme: dark) {
    .toast-card {
        background: #1e293b;
        color: #f1f5f9;
        box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
    }

    .toast-close:hover {
        background: #334155;
        color: #cbd5e1;
    }

    .custom-confirm-modal {
        background: #1e293b;
    }

    .confirm-message {
        color: #e2e8f0;
    }

    .btn-confirm-cancel {
        background: #334155;
        color: #cbd5e1;
    }

    .btn-confirm-cancel:hover {
        background: #475569;
    }
}

/* ============================================
   CHAT PHASE 1 ACTIONS
   ============================================ */

.message-actions-trigger {
    position: absolute;
    right: -25px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--chat-text-muted);
    opacity: 0;
    transition: opacity 0.2s;
    padding: 5px;
}
.message-wrapper.own .message-actions-trigger {
    left: -25px;
    right: auto;
}
.message-wrapper:hover .message-actions-trigger {
    opacity: 1;
}
.message-actions-menu {
    position: absolute;
    top: 50%;
    right: -130px;
    transform: translateY(-50%);
    background: var(--chat-bg);
    border: 1px solid var(--chat-border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: none;
    flex-direction: column;
    z-index: 100;
    min-width: 140px;
    overflow: hidden;
}
.message-wrapper.own .message-actions-menu {
    left: -140px;
    right: auto;
}
.message-actions-menu.show {
    display: flex;
}
.message-actions-menu button {
    background: none;
    border: none;
    padding: 8px 12px;
    text-align: left;
    cursor: pointer;
    color: var(--chat-text);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}
.message-actions-menu button:hover {
    background: var(--chat-hover-bg);
}
.message-actions-menu button.danger {
    color: #ef4444;
}
.message-quote {
    background: rgba(0,0,0,0.05);
    border-left: 3px solid var(--chat-accent);
    padding: 6px 10px;
    border-radius: 4px;
    margin-bottom: 6px;
    font-size: 13px;
    opacity: 0.8;
}
.message-bubble.own .message-quote {
    background: rgba(255,255,255,0.2);
    border-left-color: white;
}
.message-quote strong {
    display: block;
    margin-bottom: 2px;
}
.msg-edited-label {
    font-size: 11px;
    color: var(--chat-text-muted);
    margin-right: 4px;
    font-style: italic;
}
.reply-preview-bar {
    background: var(--chat-bg);
    border-top: 1px solid var(--chat-border);
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.reply-preview-content {
    border-left: 3px solid var(--chat-accent);
    padding-left: 10px;
    font-size: 13px;
    flex: 1;
    overflow: hidden;
}
.reply-preview-content strong {
    color: var(--chat-accent);
    display: block;
    margin-bottom: 2px;
}
.reply-preview-content p {
    margin: 0;
    color: var(--chat-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cancel-reply-btn {
    background: none;
    border: none;
    color: var(--chat-text-muted);
    cursor: pointer;
    padding: 5px;
}
.deleted-text {
    color: var(--chat-text-muted);
}
.message-bubble.deleted {
    background: transparent;
    border: 1px solid var(--chat-border);
    box-shadow: none;
}
.reaction-picker-row {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    background: var(--chat-bg);
    border-radius: 8px 8px 0 0;
    justify-content: space-between;
}
.reaction-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    transition: transform 0.2s;
    padding: 4px;
    border-radius: 50%;
}
.reaction-btn:hover {
    transform: scale(1.2);
    background: var(--chat-hover-bg);
}
.reaction-btn.active {
    background: var(--chat-accent);
}
.message-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: -8px;
    margin-bottom: 4px;
    padding: 0 4px;
    z-index: 10;
    position: relative;
}
.message-wrapper.own .message-reactions {
    justify-content: flex-end;
}
.reaction-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--chat-bg);
    border: 1px solid var(--chat-border);
    border-radius: 12px;
    padding: 2px 6px;
    font-size: 12px;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.reaction-badge.reacted {
    background: var(--chat-accent);
    color: white;
    border-color: var(--chat-accent);
}
.reaction-badge .emoji {
    font-size: 14px;
}

/* =========================================
   CHAT DETAILS PANEL
   ========================================= */
.chat-details-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 10002;
    display: none;
}

.chat-details-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 100%;
    max-width: 360px;
    height: 100%;
    background: var(--chat-bg);
    color: var(--chat-text);
    z-index: 10001;
    box-shadow: -4px 0 15px rgba(0,0,0,0.1);
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.chat-details-panel.open {
    right: 0;
}

.chat-details-header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--chat-border);
}

.chat-details-header h2 {
    margin: 0;
    font-size: 18px;
    flex: 1;
}

.chat-details-close {
    background: none;
    border: none;
    color: var(--chat-text);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
}

.chat-details-section {
    padding: 20px;
    border-bottom: 1px solid var(--chat-border);
}

.chat-details-section h3 {
    margin-top: 0;
    margin-bottom: 16px;
    font-size: 15px;
    font-weight: 600;
}

/* Toggle Switch */
.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.toggle-row span {
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--chat-border);
    transition: .3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: var(--chat-accent);
}

input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

/* Members */
.member-row {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--chat-text);
    padding: 8px 0;
    transition: opacity 0.2s;
}

.member-row:hover {
    opacity: 0.8;
}

.member-row img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.member-info strong {
    display: block;
    font-size: 15px;
    margin-bottom: 2px;
}

.member-info small {
    display: block;
    font-size: 13px;
    opacity: 0.7;
}

/* Actions */
.details-action-row {
    padding: 16px 20px;
    cursor: pointer;
    font-size: 15px;
    transition: background 0.2s;
}

.details-action-row:hover {
    background: var(--chat-input-bg);
}

.details-action-row.danger {
    color: #ef4444;
}

/* ============================================
   PWA INSTALLATION POPUP STYLES
   ============================================ */

.pwa-popup-overlay {
    position: fixed;
    bottom: -200px;
    left: 0;
    width: 100%;
    z-index: 99999;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding: 16px;
    box-sizing: border-box;
    pointer-events: none;
    transition: bottom 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
    opacity: 0;
}

.pwa-popup-overlay.active {
    bottom: 0;
    opacity: 1;
    pointer-events: auto;
}

.pwa-popup-card {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    width: 100%;
    max-width: 500px;
    padding: 20px;
    box-sizing: border-box;
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transform: translateY(20px);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.pwa-popup-overlay.active .pwa-popup-card {
    transform: translateY(0);
}

.pwa-popup-header {
    display: flex;
    align-items: center;
    gap: 14px;
}

.pwa-popup-logo {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(74, 108, 247, 0.2);
}

.pwa-popup-brand h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #1a1a2e;
    line-height: 1.2;
}

.pwa-popup-brand p {
    margin: 2px 0 0 0;
    font-size: 13px;
    color: #718096;
}

.pwa-popup-body {
    font-size: 14px;
    line-height: 1.5;
    color: #4a5568;
}

.pwa-popup-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.btn-pwa {
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 20px;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    touch-action: manipulation;
    min-height: 40px;
}

.btn-pwa:active {
    transform: scale(0.97);
}

.btn-pwa-install {
    background-color: #4a6cf7;
    color: #ffffff;
    flex: 1 0 120px;
}

.btn-pwa-install:hover {
    background-color: #3a56d4;
}

.btn-pwa-secondary {
    background-color: #edf2f7;
    color: #4a5568;
    flex: 1 0 120px;
}

.btn-pwa-secondary:hover {
    background-color: #e2e8f0;
}

.btn-pwa-link {
    background: transparent;
    color: #a0aec0;
    font-size: 13px;
    padding: 8px 12px;
    width: 100%;
    text-align: center;
    text-decoration: none;
}

.btn-pwa-link:hover {
    color: #718096;
    text-decoration: underline;
}

/* ---------- RESPONSIVE ADJUSTMENTS ---------- */
@media (min-width: 768px) {
    .pwa-popup-overlay {
        left: auto;
        right: 0;
        width: auto;
        padding: 24px;
        bottom: -200px;
    }
    
    .pwa-popup-overlay.active {
        bottom: 20px;
    }
    
    .pwa-popup-card {
        width: 360px;
        border-radius: 16px;
    }
    
    .btn-pwa-link {
        width: auto;
        margin-left: auto;
        padding: 4px 8px;
    }
}

/* ---------- DARK MODE SUPPORT ---------- */
@media (prefers-color-scheme: dark) {
    .pwa-popup-card {
        background: #1e1e2f;
        border-color: #2d2d44;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    }
    
    .pwa-popup-brand h3 {
        color: #ffffff;
    }
    
    .pwa-popup-brand p {
        color: #a0aec0;
    }
    
    .pwa-popup-body {
        color: #e2e8f0;
    }
    
    .btn-pwa-secondary {
        background-color: #2d2d44;
        color: #e2e8f0;
    }
    
    .btn-pwa-secondary:hover {
        background-color: #3d3d5c;
    }
    
    .btn-pwa-link {
        color: #718096;
    }
    
    .btn-pwa-link:hover {
        color: #a0aec0;
    }
}