/* ========== VARIABLES ========== */
:root {
    --primary: #6C5CE7;
    --primary-light: #A29BFE;
    --primary-dark: #5A4BD1;
    --secondary: #00CEC9;
    --accent: #FD79A8;
    --bg: #FAFAFA;
    --bg-card: #FFFFFF;
    --bg-input: #F5F5F5;
    --text: #2D3436;
    --text-secondary: #636E72;
    --text-muted: #B2BEC3;
    --border: #E8E8E8;
    --shadow: 0 2px 20px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.12);
    --radius: 16px;
    --radius-sm: 10px;
    --radius-full: 9999px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --gradient: linear-gradient(135deg, #6C5CE7, #A29BFE, #FD79A8);
}

[data-theme="dark"] {
    --primary: #58A6FF;
    --primary-light: #79C0FF;
    --bg: #0D1117;
    --bg-card: #161B22;
    --bg-input: #21262D;
    --text: #F0F6FC;
    --text-secondary: #8B949E;
    --text-muted: #484F58;
    --border: #30363D;
    --shadow: 0 2px 20px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.4);
}

/* ========== RESET ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    transition: var(--transition);
    overflow-x: hidden;
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}

/* ========== LIENS ========== */
a {
    color: inherit;
    text-decoration: none;
}

.profile-website a {
    color: var(--primary);
    text-decoration: none;
}

.profile-website a:hover {
    text-decoration: underline;
    opacity: 0.8;
}

[data-theme="dark"] .profile-website a {
    color: var(--primary-light);
}

/* ========== HEADER ========== */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
}

[data-theme="dark"] .app-header {
    background: rgba(22,27,34,0.85);
}

.header-logo {
    font-size: 24px;
    font-weight: 800;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    cursor: pointer;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    border: none;
    background: var(--bg-input);
    color: var(--text);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.header-btn:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.05);
}

.header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 14px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* ========== MAIN CONTENT ========== */
.main-content {
    padding-top: 64px;
    padding-bottom: 80px;
    min-height: 100vh;
}

.page-container {
    display: block;
}

/* ========== STORIES ========== */
.stories-wrapper {
    border-bottom: 1px solid var(--border);
}

.stories-container {
    padding: 16px 24px;
    overflow-x: auto;
    display: flex;
    gap: 16px;
    scrollbar-width: none;
}

.stories-container::-webkit-scrollbar {
    display: none;
}

.story-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    flex-shrink: 0;
}

.story-ring {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    padding: 3px;
    background: var(--gradient);
    transition: var(--transition);
}

.story-ring.seen {
    background: var(--text-muted);
}

.story-ring.add {
    background: var(--bg-input);
    border: 2px dashed var(--text-muted);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--text-muted);
}

.story-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 20px;
}

.story-name {
    font-size: 11px;
    color: var(--text-secondary);
    max-width: 68px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
}

/* ========== FEED ========== */
.feed-container {
    max-width: 620px;
    margin: 0 auto;
    padding: 0 16px;
}

/* ========== POST CARD ========== */
.post-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
    animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.post-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    flex-wrap: nowrap;
}

.post-user-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.post-fullname {
    font-weight: 700;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.post-username {
    font-weight: normal;
    font-size: 12px;
    color: var(--text-secondary);
    margin-left: 6px;
    white-space: nowrap;
}

.post-menu {
    flex-shrink: 0;
    margin-left: auto;
}

.post-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.post-avatar:hover {
    transform: scale(1.05);
}

.post-location {
    font-size: 12px;
    color: var(--text-secondary);
}

.post-menu-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    transition: var(--transition);
}

.post-menu-btn:hover {
    color: var(--text);
}

.post-image-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    overflow: hidden;
    cursor: pointer;
}

.post-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.post-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 60px;
    background: var(--bg-input);
}

.post-actions {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 16px;
}

.post-action-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
    padding: 4px;
    display: flex;
    align-items: center;
}

.post-action-btn:hover {
    transform: scale(1.15);
}

.post-action-btn.liked {
    color: #E74C3C;
    animation: likeAnim 0.4s ease;
}

@keyframes likeAnim {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.post-action-btn.spacer {
    margin-left: auto;
}

.post-stats {
    padding: 0 16px 8px;
}

.post-likes {
    font-weight: 700;
    font-size: 14px;
}

.post-caption {
    padding: 0 16px 12px;
    font-size: 14px;
    line-height: 1.5;
}

.post-caption .uname {
    font-weight: 700;
    cursor: pointer;
}

.post-caption .uname:hover {
    text-decoration: underline;
}

.post-time {
    padding: 0 16px 14px;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.post-comment-input {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    gap: 12px;
}

.post-comment-input input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    color: var(--text);
    font-family: inherit;
}

.post-comment-input input:focus {
    outline: none;
}

.post-comment-input input::placeholder {
    color: var(--text-muted);
}

.post-comment-input button {
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    opacity: 0.5;
    transition: var(--transition);
    font-family: inherit;
}

.post-comment-input button.active {
    opacity: 1;
}

.double-tap-heart {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    font-size: 80px;
    color: #E74C3C;
    pointer-events: none;
    z-index: 10;
}

.double-tap-heart.show {
    animation: doubleTapHeart 0.8s ease forwards;
}

@keyframes doubleTapHeart {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }
    15% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 1;
    }
    30% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    80% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0;
    }
}

/* ========== BOTTOM NAV ========== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 100;
}

[data-theme="dark"] .bottom-nav {
    background: rgba(22,27,34,0.9);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    color: var(--text-secondary);
    font-size: 24px;
    border: none;
    background: none;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item span {
    font-size: 10px;
    font-weight: 600;
}

.nav-item:hover {
    color: var(--primary);
}

.nav-create {
    width: 44px;
    height: 44px;
    background: var(--gradient);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4);
    transition: var(--transition);
}

.nav-create:hover {
    transform: scale(1.1) rotate(90deg);
}

/* ========== MODALS ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border-radius: 20px;
    width: 90%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlide 0.4s ease;
}

.modal-large {
    max-width: 600px;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    padding: 20px;
}

.modal-input {
    width: 100%;
    padding: 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    margin-bottom: 12px;
    transition: var(--transition);
}

.modal-input:focus {
    outline: none;
    border-color: var(--primary);
}

.modal-submit {
    width: 100%;
    padding: 14px;
    background: var(--gradient);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 8px;
    transition: var(--transition);
    font-family: inherit;
}

.modal-submit:hover {
    box-shadow: 0 6px 20px rgba(108, 92, 231, 0.4);
}

.modal-footer-link {
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
    color: var(--text-secondary);
}

.modal-footer-link a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.modal-footer-link a:hover {
    text-decoration: underline;
}

/* ========== UPLOAD ========== */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: rgba(108, 92, 231, 0.05);
}

.upload-area i {
    font-size: 48px;
    color: var(--primary);
    margin-bottom: 16px;
}

.upload-area p {
    color: var(--text-secondary);
    font-size: 14px;
}

.upload-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
}

.upload-preview {
    width: 100%;
    max-height: 300px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    display: none;
}

.upload-preview.active {
    display: block;
}

.upload-caption {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    margin-top: 16px;
    transition: var(--transition);
}

.upload-caption:focus {
    outline: none;
    border-color: var(--primary);
}

.upload-submit {
    width: 100%;
    padding: 14px;
    background: var(--gradient);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 16px;
    transition: var(--transition);
    font-family: inherit;
}

.upload-submit:hover {
    box-shadow: 0 6px 20px rgba(108, 92, 231, 0.4);
}

/* ========== PROFIL ========== */
.profile-content {
    text-align: center;
    padding: 0 0 20px 0;
}

.profile-avatar-large {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 4px solid var(--primary-light);
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 32px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.profile-name {
    font-size: 20px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.profile-handle {
    color: var(--text-secondary);
    font-size: 14px;
}

.profile-bio {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 8px;
    line-height: 1.5;
}

.profile-stats {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-top: 20px;
    padding: 16px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.profile-stat {
    text-align: center;
}

.profile-stat .number {
    font-size: 18px;
    font-weight: 800;
}

.profile-stat .label {
    font-size: 12px;
    color: var(--text-secondary);
}

.profile-actions {
    display: flex;
    gap: 12px;
    padding: 16px 0;
    margin-top: 20px;
}

.btn-outline {
    flex: 1;
    padding: 10px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    background: transparent;
    color: var(--text);
    border: 2px solid var(--border);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.profile-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    margin-top: 16px;
    width: 100%;
}

.profile-grid-item {
    aspect-ratio: 1 / 1;
    overflow: hidden;
    position: relative;
    background: var(--bg-input);
}

.profile-grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.profile-grid-item .overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    opacity: 0;
    transition: var(--transition);
    color: white;
    font-weight: 600;
}

.profile-grid-item:hover .overlay {
    opacity: 1;
}

/* ========== BADGES ========== */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 6px;
    font-size: 12px;
    vertical-align: middle;
}

.badge.verified {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #2EA043; /* vert GitHub */
    color: white;
    font-size: 11px;
    font-weight: bold;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    margin-left: 6px;
    padding: 0;
    text-decoration: none;
}

.badge.reporter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #FF4757;
    color: white;
    font-size: 11px;
    font-weight: bold;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    margin-left: 6px;
    padding: 0;
}

.badge.admin {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #2D3436;
    padding: 2px 6px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: bold;
}

.badge.moderator {
    background: linear-gradient(135deg, #4facfe, #00f2fe);
    color: white;
    padding: 2px 6px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: bold;
}

/* ========== BOUTON SUIVRE ========== */
.btn-follow {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-follow:hover {
    background: var(--primary-dark);
    transform: scale(1.02);
}

.btn-follow.following {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-follow.following:hover {
    background: rgba(231, 76, 60, 0.1);
    color: #E74C3C;
    border-color: #E74C3C;
}

/* ========== FORMULAIRES PROFIL ========== */
.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.form-group {
    flex: 1;
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.form-group .modal-input {
    margin-bottom: 0;
}

@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
        gap: 0;
    }
}

/* ========== AVATAR UPLOAD ========== */
.avatar-upload-area {
    width: 120px;
    height: 120px;
    margin: 0 auto 16px;
    border-radius: 50%;
    border: 3px solid var(--primary);
    overflow: hidden;
    cursor: pointer;
    position: relative;
    background: var(--bg-input);
}

.avatar-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-secondary);
    font-size: 12px;
}

.avatar-placeholder i {
    font-size: 32px;
    margin-bottom: 8px;
    color: var(--primary);
}

.avatar-placeholder p {
    margin: 0;
    font-size: 11px;
}

.avatar-placeholder small {
    font-size: 9px;
}

/* ========== POST MENU ========== */
.post-menu {
    position: relative;
}

.post-menu-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    transition: var(--transition);
}

.post-menu-btn:hover {
    color: var(--text);
}

.post-menu-dropdown {
    position: absolute;
    top: 30px;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    min-width: 150px;
    overflow: hidden;
}

.post-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
    color: var(--text);
}

.post-menu-item:hover {
    background: var(--bg-input);
}

.post-menu-item i {
    font-size: 16px;
    width: 20px;
}

/* ========== HASHTAG ========== */
.hashtag {
    color: var(--primary);
    text-decoration: none;
    cursor: pointer;
}

.hashtag:hover {
    text-decoration: underline;
    opacity: 0.8;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .feed-container {
        padding: 0 8px;
    }

    .post-card {
        border-radius: 12px;
    }

    .stories-container {
        padding: 12px 16px;
    }

    .modal {
        max-width: 95%;
    }

    .toast {
        white-space: normal;
        text-align: center;
        max-width: 90%;
    }
}

/* ========== TOAST ========== */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text);
    color: var(--bg);
    padding: 12px 24px;
    border-radius: var(--radius-full);
    font-size: 14px;
    font-weight: 600;
    z-index: 400;
    transition: transform 0.3s ease;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    visibility: visible;
}

/* ========== LOADING ========== */
.loading-spinner {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

/* ========== FIX MESSAGES PRIVÉS MOBILE ========== */
#messagesModal .modal {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

#messagesModal .modal-body {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    padding: 12px !important;
    min-height: 0 !important;
}

#messagesModal #messagesThread {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    min-height: 0 !important;
}

#messagesModal #messagesList {
    flex: 1 !important;
    overflow-y: auto !important;
    min-height: 0 !important;
}

/* Barre d'envoi toujours visible en bas */
#messagesModal #messagesThread > div:last-child {
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 10px 0 !important;
    padding-bottom: env(safe-area-inset-bottom, 12px) !important;
    background: var(--bg-card) !important;
    border-top: 1px solid var(--border) !important;
}

#messagesModal .btn-primary,
#messagesModal button[onclick*="send"],
#messagesModal button[onclick*="Send"] {
    flex-shrink: 0 !important;
    width: auto !important;
    padding: 10px 18px !important;
    font-size: 14px !important;
    white-space: nowrap !important;
}

#messagesModal input[type="text"],
#messagesModal textarea {
    flex: 1 !important;
    min-width: 0 !important;
}
/* ========== FIX INPUT MESSAGES MODE SOMBRE ========== */
[data-theme="dark"] #messagesModal input[type="text"],
[data-theme="dark"] #messagesModal textarea {
    color: var(--text) !important;
    background: var(--bg-input) !important;
}

[data-theme="dark"] #messagesModal input::placeholder,
[data-theme="dark"] #messagesModal textarea::placeholder {
    color: var(--text-muted) !important;
}

/* Boutons du profil */
.profile-actions .btn-primary,
.profile-actions .btn-outline {
    transition: var(--transition);
    font-weight: 600;
    cursor: pointer;
}

.profile-actions .btn-primary {
    background: var(--gradient);
    color: white;
    border: none;
    padding: 10px;
    border-radius: var(--radius-sm);
}

.profile-actions .btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

.profile-actions .btn-outline {
    background: transparent;
    color: var(--text);
    border: 2px solid var(--border);
    padding: 10px;
    border-radius: var(--radius-sm);
}

.profile-actions .btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}/* Bouton Envoyer dans les messages privés */
#messagesModal .btn-primary {
    background: var(--gradient) !important;
    color: white !important;
    border: none !important;
    padding: 10px 20px !important;
    border-radius: var(--radius-full) !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    cursor: pointer !important;
    transition: var(--transition) !important;
}

#messagesModal .btn-primary:hover {
    opacity: 0.9 !important;
    transform: scale(1.02) !important;
}

/* Version désactivée */
#messagesModal .btn-primary:disabled {
    opacity: 0.5 !important;
    transform: none !important;
    cursor: not-allowed !important;
}/* Boutons génériques */
.btn-primary {
    background: var(--gradient);
    color: white;
    border: none;
    padding: 10px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    color: var(--text);
    border: 2px solid var(--border);
    padding: 10px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}.post-caption {
    white-space: pre-line; /* ou pre-wrap */
}.post-caption {
    white-space: pre-line;
    line-height: 1.2; /* Réduit l'espace entre les lignes */
    margin-bottom: 0;
}

.post-caption br {
    display: block;
    content: "";
    margin: 0;
    line-height: 0; /* Supprime l'espace autour des <br> */
}.caption-line {
    line-height: 1.2;
    margin-bottom: 0;
}

/* Masquer le panneau des commentaires par défaut */
/* ========== COMMENTS PANEL ========== */
.comments-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 299;
    display: none;
    backdrop-filter: blur(2px);
}

.comments-backdrop.open {
    display: block;
}

.comments-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70vh;
    background: var(--bg-card);
    border-radius: 20px 20px 0 0;
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 30px rgba(0,0,0,0.15);
    z-index: 300;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.comments-panel.open {
    transform: translateY(0);
}

.comments-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.comments-header h3 {
    font-size: 15px;
    font-weight: 700;
}

.comments-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
}

.comments-input {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    padding-bottom: env(safe-area-inset-bottom, 12px);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg-card);
}

.comments-input input {
    flex: 1;
    padding: 10px 14px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
}

.comments-input input:focus {
    outline: none;
    border-color: var(--primary);
}

.comments-input button {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--gradient);
    color: white;
    border: none;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--transition);
}

.comments-input button:hover {
    opacity: 0.85;
    transform: scale(1.05);
}

.comments-panel.open {
    transform: translateY(0);
}/* ========== COMMENTS PANEL - FIX MOBILE ========== */
.comments-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60vh;
    background: var(--bg-card) !important;
    border-radius: 20px 20px 0 0;
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 30px rgba(0,0,0,0.2);
    z-index: 300;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* CRITIQUE : force le fond même sur mobile */
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

[data-theme="dark"] .comments-panel {
    background: #161B22 !important;
}

.comments-panel.open {
    transform: translateY(0);
}

.comments-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg-card);
    border-radius: 20px 20px 0 0;
}

[data-theme="dark"] .comments-header {
    background: #161B22;
}

.comments-header h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

.comments-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    background: var(--bg-card);
    -webkit-overflow-scrolling: touch;
}

[data-theme="dark"] .comments-list {
    background: #161B22;
}

/* CRITIQUE : input fixe en bas, ne bouge pas avec le clavier */
.comments-input {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg-card);
    position: sticky;
    bottom: 0;
}

[data-theme="dark"] .comments-input {
    background: #161B22;
}

.comments-input input {
    flex: 1;
    min-width: 0;
    padding: 10px 14px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    font-size: 16px; /* 16px minimum pour éviter le zoom iOS */
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
}

[data-theme="dark"] .comments-input input {
    color: #F0F6FC !important;
    background: #21262D !important;
    border-color: #30363D !important;
}

.comments-input input::placeholder {
    color: var(--text-muted);
}

.comments-input input:focus {
    outline: none;
    border-color: var(--primary);
}

.comments-input button {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
    background: var(--gradient);
    color: white;
    border: none;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--transition);
}

.comments-input button:hover {
    opacity: 0.85;
    transform: scale(1.05);
}

/* Quand le clavier s'ouvre sur mobile */
@media (max-height: 500px) {
    .comments-panel {
        height: 100vh;
        border-radius: 0;
    }
}.post-comments-count {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
    display: inline-block;
    margin-left: 16px;
}

.post-comments-count:hover {
    color: var(--primary);
    text-decoration: underline;
}.see-more-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 4px;
    padding: 0;
}

.see-more-btn:hover {
    text-decoration: underline;
}

/* Correction de l'espace sous les vidéos */
.post-image-container:has(iframe) {
    aspect-ratio: auto;
    line-height: 0;
}

.post-image-container iframe {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    display: block;
    border: none;
}