/* =========================================
   1. ОСНОВНЫЕ ПЕРЕМЕННЫЕ И ТЕМА
   ========================================= */
:root {
    --bg-body: #f0f2f5;
    --bg-card: #ffffff;
    --text-main: #050505;
    --text-sec: #65676b;
    --accent: #1877f2;
    --danger: #ff3b30;
    --success: #2ecc71;
    --shadow: 0 4px 12px rgba(0,0,0,0.1);
    --radius: 20px;
}

[data-theme="dark"] {
    --bg-body: #18191a;
    --bg-card: #242526;
    --text-main: #e4e6eb;
    --text-sec: #b0b3b8;
    --shadow: 0 4px 12px rgba(0,0,0,0.4);
}

body {
    background: var(--bg-body);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    transition: background 0.3s ease, color 0.3s ease;
    overflow-y: scroll;
    /* Важно: отступ снизу, чтобы контент не прятался за нижней панелью */
    padding-bottom: 100px; 
}

a { text-decoration: none; }

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
}

/* Ссылка-иконка (назад и т.д.) */
.icon-link {
    text-decoration: none;
    color: var(--text-main);
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--bg-card);
    box-shadow: var(--shadow);
    display: inline-flex; align-items: center; justify-content: center;
    transition: transform 0.2s; border: none; cursor: pointer;
}
.icon-link:hover { transform: scale(1.1); }

/* =========================================
   2. ПЛАВАЮЩАЯ ШАПКА (ТОЛЬКО ПК)
   ========================================= */
.feed-header {
    position: sticky; 
    top: 15px; 
    z-index: 100; /* Слой навигации */
    background: var(--bg-card);
    border-radius: 50px;
    padding: 10px 25px;
    box-shadow: var(--shadow);
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    margin-bottom: 25px;
}

.logo-icon { height: 28px; width: auto; display: block; }
.nav-icons { display: flex; align-items: center; gap: 25px; position: relative; }

.nav-item {
    text-decoration: none; color: var(--text-sec);
    display: flex; align-items: center;
    transition: transform 0.2s, color 0.2s;
}
.nav-item:hover { color: var(--accent); transform: scale(1.1); }

.material-symbols-rounded {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    font-size: 26px; vertical-align: middle;
}

/* =========================================
   3. МЕНЮ ПРОФИЛЯ (Dropdown Desktop)
   ========================================= */
.user-avatar-trigger {
    width: 40px; height: 40px; border-radius: 50%; object-fit: cover;
    cursor: pointer; border: 2px solid transparent; transition: border-color 0.3s;
}
.user-avatar-trigger:hover { border-color: var(--accent); }

.dropdown-menu {
    position: absolute; top: 55px; right: 0;
    background: var(--bg-card); width: 220px;
    border-radius: 16px; box-shadow: var(--shadow); padding: 10px;
    opacity: 0; visibility: hidden; transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 101; /* Поверх шапки */
}
.dropdown-menu.active { opacity: 1; visibility: visible; transform: translateY(0); }

.menu-item {
    display: flex; align-items: center; gap: 12px; padding: 12px;
    color: var(--text-main); text-decoration: none; border-radius: 8px;
    transition: background 0.2s; font-size: 15px; cursor: pointer;
}
.menu-item:hover { background: rgba(0,0,0,0.05); }
.menu-item.logout { color: var(--danger); font-weight: 600; }
[data-theme="dark"] .menu-item:hover { background: rgba(255,255,255,0.1); }

/* =========================================
   4. ФОРМЫ И КНОПКИ (PILL)
   ========================================= */
input[type="text"], input[type="email"], input[type="password"], textarea, .pill-input {
    width: 100%; padding: 15px 25px; margin: 10px 0;
    border-radius: 50px; border: none;
    background: var(--bg-body); color: var(--text-main);
    font-size: 15px; font-family: inherit; box-sizing: border-box;
    outline: none; transition: box-shadow 0.2s;
}
input:focus, textarea:focus, .pill-input:focus {
    box-shadow: 0 0 0 2px var(--accent); background: var(--bg-card);
}
textarea { border-radius: 25px; resize: vertical; min-height: 100px; }

.btn {
    width: 100%; padding: 15px; border-radius: 50px; border: none;
    background: var(--accent); color: white;
    font-weight: bold; font-size: 16px; cursor: pointer; margin-top: 20px;
    transition: transform 0.2s, opacity 0.2s;
}
.btn:hover { opacity: 0.9; transform: scale(1.02); }

.file-upload-label {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    padding: 12px 20px; background: var(--bg-body); border-radius: 50px;
    cursor: pointer; color: var(--text-sec); font-size: 14px; margin: 10px 0;
    width: 100%; box-sizing: border-box; border: 1px dashed var(--text-sec);
}
.file-upload-label:hover { background: var(--bg-card); color: var(--text-main); }

/* Карточка авторизации */
.auth-card {
    background: var(--bg-card); padding: 40px;
    border-radius: 24px; box-shadow: var(--shadow);
    text-align: center; max-width: 400px; margin: 40px auto;
}

/* =========================================
   5. ФОРМА ПОСТА (В СТРОКУ)
   ========================================= */
.create-post-pill {
    background: var(--bg-card); border-radius: 50px;
    padding: 8px 15px 8px 8px; box-shadow: var(--shadow);
    margin-bottom: 25px; position: relative;
}
.input-row { display: flex; align-items: center; gap: 12px; width: 100%; }
.input-row img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.post-input { flex: 1; background: transparent; border: none; font-size: 15px; color: var(--text-main); outline: none; padding: 10px 0; }
.right-actions { display: flex; align-items: center; gap: 12px; }
.attach-btn { color: var(--text-sec); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: color 0.2s; }
.attach-btn:hover { color: var(--text-main); }
.send-btn-small, .send-btn-circle {
    background: var(--accent); color: white; width: 34px; height: 34px;
    border-radius: 50%; border: none; display: flex; align-items: center;
    justify-content: center; cursor: pointer; transition: transform 0.2s;
}
.send-btn-small:hover { transform: scale(1.1); }
#image-preview-container { padding: 10px 0 5px 52px; display: none; width: 100%; position: relative; }
#image-preview { max-height: 150px; border-radius: 12px; border: 1px solid rgba(0,0,0,0.1); }
.remove-preview { position: absolute; margin-left: -10px; margin-top: -10px; background: var(--danger); color: white; border-radius: 50%; width: 20px; height: 20px; text-align: center; cursor: pointer; font-weight: bold; line-height: 20px; }

/* =========================================
   6. ЛЕНТА И ПОСТЫ
   ========================================= */
.card { background: var(--bg-card); border-radius: 24px; padding: 20px; margin-bottom: 25px; box-shadow: var(--shadow); }
.post-header { display: flex; align-items: center; margin-bottom: 15px;  }
.post-header img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; margin-right: 12px; }
.username-link { color: var(--text-main); font-weight: 700; text-decoration: none; font-size: 15px; }
.post-image { width: 100%; border-radius: 16px; margin-top: 12px; border: 1px solid rgba(0,0,0,0.05); }

/* Репост */
.repost-box {
    border: 1px solid var(--text-sec); border-radius: 12px;
    padding: 12px; margin-top: 10px; background: rgba(0,0,0,0.02);
    cursor: pointer; transition: background 0.2s, border-color 0.2s;
    position: relative; z-index: 5;
}
.repost-box:hover { background: rgba(0,0,0,0.05); border-color: var(--text-main); }

/* Действия */
.action-bar { display: flex; gap: 20px; margin-top: 15px; border-top: 1px solid var(--bg-body); padding-top: 12px; }
.action-btn { background: none; border: none; cursor: pointer; display: flex; align-items: center; gap: 6px; color: var(--text-sec); font-size: 14px; padding: 5px 10px; border-radius: 20px; transition: background 0.2s; }
.action-btn:hover { background: var(--bg-body); color: var(--text-main); }
.action-btn.liked { color: var(--danger); }
.action-btn.reposted { color: var(--success); }
.delete-btn { color: var(--text-sec); text-decoration: none; padding: 5px; border-radius: 50%; border: none; background: none; cursor: pointer; }
.delete-btn:hover { color: var(--danger); background: rgba(255,0,0,0.1); }

/* Анимация лайка */
.like-anim { animation: likeBounce 0.3s ease; }
@keyframes likeBounce { 0% { transform: scale(1); } 50% { transform: scale(1.3); } 100% { transform: scale(1); } }

/* =========================================
   7. МОДАЛКА (POPUP)
   ========================================= */
.modal-overlay {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.8); z-index: 2000; /* Выше навигации */
    align-items: center; justify-content: center; backdrop-filter: blur(5px);
}
.modal-content {
    background: var(--bg-card); width: 100%; max-width: 600px; height: 80vh;
    border-radius: 20px; display: flex; flex-direction: column;
    position: relative; overflow: hidden; animation: slideUp 0.3s ease-out;
}
@keyframes slideUp { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header { padding: 15px 20px; border-bottom: 1px solid var(--bg-body); display: flex; justify-content: space-between; align-items: center; font-weight: bold; font-size: 18px; }
.modal-body { flex: 1; overflow-y: auto; padding: 20px; }
.modal-footer { padding: 15px; border-top: 1px solid var(--bg-body); background: var(--bg-card); }
.close-modal-btn { background: none; border: none; color: var(--text-main); cursor: pointer; font-size: 24px; display: flex; align-items: center; }

/* Комментарии */
.comments-list { margin-top: 15px; padding-top: 10px; border-top: 1px solid var(--bg-body); }
.comment-item { display: flex; gap: 12px; margin-bottom: 20px; align-items: flex-start; }
.comment-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.comment-content { flex: 1; }
.comment-header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.comment-author { font-weight: 700; font-size: 14px; color: var(--text-main); }
.comment-time { font-size: 12px; color: var(--text-sec); }
.comment-text { font-size: 15px; line-height: 1.4; color: var(--text-main); margin-bottom: 6px; }

/* =========================================
   8. ПРОФИЛЬ
   ========================================= */
.profile-card {
    background: var(--bg-card);
    border-radius: 24px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(0,0,0,0.08);
    overflow: hidden;
    margin-bottom: 25px;
    z-index: 10; 
}
.profile-cover {
    height: 180px;
    width: 100%;
    background-color: #cbd5e1;
    background-size: cover;
    background-position: center;
}

.profile-info {
    padding: 0 20px 25px 20px;
    position: relative;
    margin-top: -60px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.profile-username {
    font-size: 16px;
    color: var(--text-sec);
    margin-top: 4px;
    font-weight: 500;
    text-align: center;
}

.profile-avatar-big {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 5px solid var(--bg-card);
    background: var(--bg-card);
    object-fit: cover;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    margin-bottom: 10px;
}

.profile-name-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-top: 5px;
    margin-bottom: 15px;
    width: 100%;
}

.profile-realname {
    font-size: 24px;
    font-weight: 800;
    margin: 0;
    line-height: 1.2;
    color: var(--text-main);
}

.profile-username {
    font-size: 16px;
    color: var(--text-sec);
    margin-top: 4px;
    font-weight: 500;
    text-align: center;
}

.profile-bio {
    color: var(--text-sec);
    text-align: center;
    font-size: 15px;
    max-width: 400px;
    margin-bottom: 20px;
    line-height: 1.4;
}

.profile-actions {
    display: flex;
    gap: 10px;
    width: 100%;
    justify-content: center;
}

.btn-profile {
    flex: 1;
    max-width: 150px;
    padding: 10px 0;
    border-radius: 50px;
    border: none;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: transform 0.1s;
}

.btn-profile:active { transform: scale(0.96); }
.btn-blue { background: var(--accent); color: white; }
.btn-gray { background: var(--bg-body); color: var(--text-main); border: 1px solid rgba(0,0,0,0.05); }

.pinned-label {
    font-size: 12px; 
    color: var(--text-sec); 
    display: flex; 
    align-items: center; 
    margin-bottom: 5px;
}
.pinned-icon {
    color: var(--accent); 
    transform: rotate(45deg); 
    font-size: 20px; 
    margin-right: 5px; 
}
.hashtag-link { color: var(--accent); text-decoration: none; font-weight: 600; cursor: pointer; }
.hashtag-link:hover { text-decoration: underline; }

/* =========================================
   9. УВЕДОМЛЕНИЯ
   ========================================= */
.notif-link { position: relative; display: flex; align-items: center; text-decoration: none; color: var(--text-sec); }
.notif-link:hover { color: var(--accent); }
.notif-badge { 
    position: absolute; top: -5px; right: -5px; 
    background: var(--danger); color: white; 
    border-radius: 50%; padding: 2px 5px; font-size: 10px; 
    font-weight: bold; display: none; border: 2px solid var(--bg-card);
}

.notif-page-item {
    display: flex; align-items: center; gap: 15px; padding: 20px;
    background: var(--bg-card); border-bottom: 1px solid var(--bg-body);
    text-decoration: none; color: var(--text-main); transition: background 0.2s;
}
.notif-page-item:hover { background: rgba(0,0,0,0.02); }
.notif-page-item.new { background: rgba(24, 119, 242, 0.05); }
.notif-avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; }
.notif-content { flex: 1; }
.notif-text { font-size: 15px; line-height: 1.4; margin-bottom: 4px; }
.notif-date { font-size: 13px; color: var(--text-sec); }
.notif-icon-box {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* =========================================
   10. РЕДАКТОР ПРОФИЛЯ
   ========================================= */
.edit-container {
    background: var(--bg-card);
    border-radius: 24px;
    box-shadow: var(--shadow);
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

.edit-cover-zone {
    height: 160px;
    width: 100%;
    background-color: #cbd5e1;
    background-size: cover;
    background-position: center;
    position: relative;
}

.edit-cover-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.3);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.2s; cursor: pointer;
}
.edit-cover-zone:hover .edit-cover-overlay { opacity: 1; }

.edit-avatar-zone {
    width: 110px; height: 110px;
    border-radius: 50%;
    border: 5px solid var(--bg-card);
    position: absolute;
    top: 105px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--bg-card);
    z-index: 10;
    overflow: hidden;
}

.edit-avatar-img { width: 100%; height: 100%; object-fit: cover; }

.edit-avatar-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4);
    display: flex; align-items: center; justify-content: center;
    color: white; opacity: 0; transition: opacity 0.2s; cursor: pointer;
}
.edit-avatar-zone:hover .edit-avatar-overlay { opacity: 1; }

.camera-icon {
    width: 40px; height: 40px;
    background: rgba(0,0,0,0.5);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white; backdrop-filter: blur(4px);
}

.edit-form-content {
    padding: 70px 20px 30px 20px;
}

.form-group { margin-bottom: 20px; }
.form-label {
    display: block;
    font-size: 13px;
    color: var(--text-sec);
    margin-bottom: 8px;
    margin-left: 10px;
    font-weight: 600;
}

/* =========================================
   11. УВЕДОМЛЕНИЯ (Toast)
   ========================================= */
#toast {
    visibility: hidden; min-width: 250px; background-color: #333; color: #fff;
    text-align: center; border-radius: 50px; padding: 16px;
    position: fixed; z-index: 3000; left: 50%; bottom: 30px;
    transform: translateX(-50%); font-size: 14px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}
#toast.show { visibility: visible; animation: fadein 0.5s, fadeout 0.5s 2.5s; }
@keyframes fadein { from {bottom: 0; opacity: 0;} to {bottom: 30px; opacity: 1;} }
@keyframes fadeout { from {bottom: 30px; opacity: 1;} to {bottom: 0; opacity: 0;} }

/* =========================================
   12. АНИМАЦИИ И ПРОЧЕЕ
   ========================================= */
.spin-anim { animation: spin 1s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

button:disabled { cursor: not-allowed; pointer-events: none; }

.tag-header-block { display: flex; align-items: center; gap: 15px; margin-bottom: 25px; padding: 10px; background: var(--bg-card); border-radius: 20px; box-shadow: var(--shadow); }
.back-arrow-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--bg-body); display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-main); transition: 0.2s; }
.back-arrow-btn:hover { background: #e4e6eb; transform: scale(1.1); }
[data-theme="dark"] .back-arrow-btn:hover { background: #3a3b3c; }

/* =========================================
   13. МОБИЛЬНАЯ НАВИГАЦИЯ (ИСПРАВЛЕНО)
   ========================================= */

/* 1. ПО УМОЛЧАНИЮ (ПК) */
.feed-header { display: flex !important; }
.bottom-nav { display: none !important; }

/* 2. НА ТЕЛЕФОНЕ (экраны < 768px) */
@media (max-width: 768px) {
    /* Скрываем верхнюю шапку */
    .feed-header { display: none !important; }

    /* Показываем нижнюю панель (Z-INDEX 100, ЧТОБЫ БЫТЬ НИЖЕ МОДАЛОК) */
    .bottom-nav {
        display: flex !important;
        justify-content: space-around;
        align-items: center;
        
        position: fixed;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        
        width: 90%;
        max-width: 350px;
        height: 60px;
        
        background: var(--bg-card);
        background: rgba(255, 255, 255, 0.9);
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
        
        border-radius: 50px;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
        border: 1px solid rgba(0, 0, 0, 0.05);
        z-index: 100; /* <-- ИСПРАВЛЕНО: БЫЛО 99999 */
        padding: 0 10px;
    }

    [data-theme="dark"] .bottom-nav {
        background: rgba(36, 37, 38, 0.9);
        border: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    }

    .bottom-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        color: var(--text-sec);
        width: 25%;
        height: 100%;
        position: relative;
    }

    .bottom-nav-item.active { color: var(--accent); }

    .bottom-nav-item.active .material-symbols-rounded {
        font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
        transform: translateY(-2px);
    }

    .bottom-nav-item .material-symbols-rounded {
        font-size: 28px;
        margin-bottom: 2px;
        transition: 0.2s;
    }

    .nav-label { font-size: 10px; font-weight: 500; }

    .bottom-nav-avatar {
        width: 28px; height: 28px;
        border-radius: 50%; object-fit: cover;
        border: 2px solid transparent;
    }
    .bottom-nav-item.active .bottom-nav-avatar { border-color: var(--accent); }
    
    .bottom-nav-badge {
        position: absolute; top: 12px; right: 25%;
        width: 8px; height: 8px; background-color: #ff3b30;
        border-radius: 50%; border: 2px solid var(--bg-card);
        display: none;
    }
}