/* --- 1. ШРИФТЫ И ПЕРЕМЕННЫЕ --- */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=Inter:wght@400;500;600;800&display=swap');

:root {
    --bg-color: #0f1115;
    --card-bg: rgba(20, 23, 30, 0.70);
    --accent: #00aaff;
    --accent-glow: rgba(0, 170, 255, 0.5);
    --text: #ffffff;
    --text-sec: #64748b;
    --danger: #ff3366;
    --online: #00ff9d;
    --online-glow: rgba(0, 255, 157, 0.4);
    
    --font-main: 'Inter', sans-serif;
    --font-code: 'JetBrains Mono', monospace;
    
    --capsule-height: 52px; /* Чуть увеличил высоту для удобства */
}

/* --- 2. БАЗА --- */
body {
    margin: 0; padding: 0;
    font-family: var(--font-main);
    background: linear-gradient(-45deg, #050505, #0f1116, #09121a, #11090f);
    background-size: 400% 400%;
    animation: gradientBG 20s ease infinite;
    color: var(--text);
    min-height: 100vh;
    scrollbar-width: thin; scrollbar-color: var(--accent) transparent;
    -webkit-tap-highlight-color: transparent;
}
body::before {
    content: " "; display: block; position: fixed; top: 0; left: 0; bottom: 0; right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    z-index: 999; background-size: 100% 2px, 3px 100%; pointer-events: none;
}
@keyframes gradientBG { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 2px; }

/* --- 3. ХЕДЕР --- */
.view { display: none; padding: 15px; padding-top: 80px; padding-bottom: 80px; }
.view.active { display: block; }

.header {
    display: flex; justify-content: space-between; align-items: center;
    position: fixed; top: 0; left: 0; right: 0; z-index: 50;
    background: rgba(10, 12, 18, 0.85); 
    backdrop-filter: blur(25px) saturate(1.5); -webkit-backdrop-filter: blur(25px) saturate(1.5);
    padding: 12px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 4px 30px rgba(0,0,0,0.5);
}
h1 { font-family: var(--font-main); font-weight: 800; font-size: 18px; flex-grow: 1; text-align: center; margin: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats-btn { background: rgba(255,255,255,0.03); color: var(--accent); border: 1px solid rgba(0, 170, 255, 0.15); width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: 0.3s; }
.stats-btn:active { box-shadow: 0 0 15px var(--accent-glow); transform: scale(0.95); background: rgba(0, 170, 255, 0.1); }

/* --- 4. ГЛИТЧ --- */
.glitch { position: relative; color: var(--text); font-weight: 800; letter-spacing: -0.5px; }
.glitch::before, .glitch::after { content: attr(data-text); position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
.glitch::before { left: 2px; text-shadow: -1px 0 #ff00c1; clip: rect(44px, 450px, 56px, 0); animation: glitch-anim 5s infinite linear alternate-reverse; }
.glitch::after { left: -2px; text-shadow: -1px 0 #00fff9; clip: rect(44px, 450px, 56px, 0); animation: glitch-anim2 5s infinite linear alternate-reverse; }
@keyframes glitch-anim { 0% { clip: rect(38px, 9999px, 84px, 0); } 100% { clip: rect(67px, 9999px, 1px, 0); } }
@keyframes glitch-anim2 { 0% { clip: rect(54px, 9999px, 17px, 0); } 100% { clip: rect(56px, 9999px, 60px, 0); } }

/* --- 5. ГЛАВНЫЕ ВКЛАДКИ (Активные / Архив) --- */
.main-tabs-container {
    display: flex;
    margin: 10px 0 15px 0;
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
    padding: 3px;
}
.main-tab {
    flex: 1;
    background: none;
    border: none;
    color: #888;
    padding: 10px;
    font-family: var(--font-code);
    font-size: 12px;
    font-weight: 600;
    border-radius: 9px;
    cursor: pointer;
    transition: 0.2s;
    text-transform: uppercase;
}
.main-tab.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    text-shadow: 0 0 10px rgba(255,255,255,0.5);
}

/* --- 6. КАПСУЛА НАВИГАЦИИ (ИСПРАВЛЕНО) --- */
.capsule-container {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
    position: sticky;
    top: 80px; 
    z-index: 40;
}

.capsule-track {
    position: relative;
    display: flex;
    box-sizing: border-box; /* Важно! */
    background: rgba(30, 30, 35, 0.8); /* Чуть темнее фон для контраста */
    backdrop-filter: blur(12px);
    border-radius: 30px;
    padding: 4px; /* Фиксированный паддинг */
    width: 94%; /* Чуть шире */
    max-width: 400px;
    height: var(--capsule-height);
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.08);
}

.capsule-glider {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    /* ФОРМУЛА: (100% ширины - 8px паддингов) / 4 элемента */
    width: calc((100% - 8px) / 4);
    background: var(--accent);
    border-radius: 25px;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 0 15px var(--accent-glow);
    z-index: 1;
}

.capsule-item {
    flex: 1; /* Растягиваем равномерно */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2;
    cursor: pointer;
    color: #777;
    font-size: 20px; /* Иконки чуть крупнее */
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.capsule-item.active {
    color: #fff;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.2));
}

/* --- 7. ДИНАМИЧЕСКИЙ ЗАГОЛОВОК --- */
.dynamic-title-container {
    text-align: center;
    margin-bottom: 20px;
    height: 30px; 
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}
#dynamic-tab-title {
    font-family: var(--font-code);
    font-size: 14px;
    letter-spacing: 2px;
    color: var(--text-sec);
    font-weight: 700;
    margin: 0;
    text-transform: uppercase;
}
.fade-in-up {
    animation: titleSlideUp 0.3s ease forwards;
}
@keyframes titleSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Контент вкладок */
.tab-content { display: none !important; opacity: 0; }
.tab-content.active { display: block !important; opacity: 1; animation: fadeInContent 0.3s ease; }
@keyframes fadeInContent { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* --- 8. КАРТОЧКИ --- */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(15px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

.target-card {
    background: var(--card-bg); border-radius: 18px; padding: 12px; margin-bottom: 12px;
    display: flex; justify-content: space-between; align-items: center;
    backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px);
    transition: transform 0.2s, background 0.2s;
    animation: fadeInUp 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
    user-select: none;
    border: none;
    box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.1), inset 0 0 20px 0 rgba(0, 0, 0, 0.3), 0 10px 20px rgba(0, 0, 0, 0.4);
    position: relative; overflow: hidden;
}
.target-card:active { transform: scale(0.97); background: rgba(255,255,255,0.08); }
.target-card::before { content: ""; position: absolute; inset: 0; border-radius: 18px; padding: 1px; background: linear-gradient(180deg, rgba(255,255,255,0.1), rgba(255,255,255,0)); -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none; }

.target-card.archived {
    filter: grayscale(1) opacity(0.7);
    border: 1px dashed rgba(255,255,255,0.1);
    box-shadow: none;
}
.archived-badge {
    position: absolute;
    top: 5px; right: 45px; 
    background: #222; color: #777;
    font-size: 8px; padding: 3px 6px; border-radius: 4px;
    font-family: var(--font-code); border: 1px solid #444;
    transform: rotate(-3deg); z-index: 10;
}

.card-content { display: flex; align-items: center; flex-grow: 1; overflow: hidden; pointer-events: none; }
.avatar-wrapper { position: relative; margin-right: 15px; width: 56px; height: 56px; flex-shrink: 0; pointer-events: auto; }
.avatar, .avatar-placeholder { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,255,255,0.1); box-shadow: 0 4px 15px rgba(0,0,0,0.5); z-index: 2; position: relative; }
.avatar-placeholder { display: flex; justify-content: center; align-items: center; font-weight: 700; font-size: 24px; color: #fff; background: linear-gradient(135deg, #2b32b2 0%, #1488cc 100%); }
.avatar-wrapper::after { content: ''; position: absolute; top: -5px; left: -5px; right: -5px; bottom: -5px; border-radius: 50%; border: 1px dashed rgba(0, 170, 255, 0.3); border-top-color: var(--accent); animation: spin-hud 8s linear infinite; pointer-events: none; z-index: 1; }
@keyframes spin-hud { 100% { transform: rotate(360deg); } }
.bg-1 { background: linear-gradient(135deg, #F05F57 0%, #360940 100%); } .bg-2 { background: linear-gradient(135deg, #2E3192 0%, #1BFFFF 100%); } .bg-3 { background: linear-gradient(135deg, #D4145A 0%, #FBB03B 100%); } .bg-4 { background: linear-gradient(135deg, #009245 0%, #FCEE21 100%); } .bg-5 { background: linear-gradient(135deg, #662D8C 0%, #ED1E79 100%); } .bg-6 { background: linear-gradient(135deg, #EE9CA7 0%, #FFDDE1 100%); color: #333; } .bg-7 { background: linear-gradient(135deg, #614385 0%, #516395 100%); } .bg-8 { background: linear-gradient(135deg, #02AAB0 0%, #00CDAC 100%); }
.status-dot { position: absolute; bottom: 2px; right: 2px; width: 14px; height: 14px; border-radius: 50%; background-color: #333; border: 3px solid #1a1d24; z-index: 5; transition: 0.3s; box-shadow: 0 0 5px rgba(0,0,0,0.8); }
.status-dot.online { background-color: var(--online); box-shadow: 0 0 10px var(--online), 0 0 20px var(--online-glow); border-color: var(--online); }

.info { overflow: hidden; }
.info h3 { margin: 0 0 4px 0; font-size: 17px; font-weight: 700; text-shadow: 0 0 15px rgba(0, 170, 255, 0.15); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.info p { margin: 0; color: var(--text-sec); font-size: 11px; font-family: var(--font-code); text-transform: uppercase; letter-spacing: 0.5px; }
.target-badges { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; justify-content: center; padding-left: 10px; }
.badge { display: flex; align-items: center; font-size: 11px; font-family: var(--font-code); background: rgba(0,0,0,0.3); padding: 5px 10px; border-radius: 8px; color: #777; border: 1px solid rgba(255,255,255,0.03); transition: 0.2s; }
.badge i { margin-right: 6px; font-size: 10px; }
.badge.active { color: #fff; border-color: rgba(0, 170, 255, 0.2); } .badge.active i.fa-comment-alt { color: var(--accent); } .badge.likes.active { border-color: rgba(255, 51, 102, 0.2); } .badge.likes.active i.fa-heart { color: var(--danger); }

/* --- 9. СООБЩЕНИЯ И ЛАЙКИ --- */
.msg-card { background: var(--card-bg); border-radius: 16px; padding: 15px; margin-bottom: 15px; border: none; position: relative; box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 5px 15px rgba(0,0,0,0.3); animation: fadeInUp 0.4s ease backwards; }
.msg-card::after { content: ''; position: absolute; left: 0; top: 16px; bottom: 16px; width: 3px; background: var(--accent); border-radius: 0 4px 4px 0; box-shadow: 0 0 10px var(--accent-glow); }
.msg-header { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-sec); margin-bottom: 8px; font-family: var(--font-code); text-transform: uppercase; letter-spacing: 1px; }
.msg-text { font-size: 15px; line-height: 1.55; white-space: pre-wrap; word-wrap: break-word; color: #eee; }
.reply-context { background: rgba(0, 170, 255, 0.08); border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; font-size: 13px; color: #ccc; border-left: 2px solid rgba(0, 170, 255, 0.5); }
.msg-link { display: inline-block; margin-top: 10px; color: var(--accent); font-size: 11px; text-decoration: none; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; opacity: 0.8; }
.msg-card.deleted { background: rgba(30, 15, 15, 0.6); }
.msg-card.deleted::after { background: var(--danger); box-shadow: 0 0 10px rgba(255, 51, 102, 0.4); }
.msg-card.deleted .msg-text { color: #999; text-decoration: line-through; }
.msg-card.deleted .msg-header::after { content: 'DELETED'; display: inline-block; margin-left: 10px; font-size: 10px; color: var(--danger); border: 1px solid var(--danger); padding: 1px 5px; border-radius: 4px; }

.like-card { padding: 15px; background: var(--card-bg); border-radius: 16px; margin-bottom: 12px; position: relative; box-shadow: inset 0 1px 0 rgba(255,255,255,0.05); }
.like-card::after { content: ''; position: absolute; left: 0; top: 16px; bottom: 16px; width: 3px; background: var(--danger); border-radius: 0 4px 4px 0; }
.like-header i { color: var(--danger); margin-right: 8px; }
.like-text { font-style: italic; color: #aaa; padding-left: 10px; border-left: 2px solid rgba(255,255,255,0.1); margin: 8px 0; }

/* --- 10. СЕТКА СТОРИС --- */
.story-grid-container {
    display: grid;
    grid-template-columns: repeat(5, 1fr); /* 5 в ряд */
    gap: 6px;
    padding: 0 5px;
}
.story-item {
    aspect-ratio: 9/16;
    background: #000;
    border-radius: 6px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.1);
    transition: transform 0.2s;
    animation: fadeInUp 0.4s ease backwards;
}
.story-item:active { transform: scale(0.95); }
.story-thumb { width: 100%; height: 100%; object-fit: cover; }
.story-type-icon { position: absolute; top: 4px; right: 4px; color: #fff; font-size: 10px; text-shadow: 0 1px 2px #000; z-index: 2; }
.story-expired { opacity: 0.6; filter: grayscale(1); }
.story-expired::after { content: ''; position: absolute; inset: 0; background: rgba(0,0,0,0.5); }

/* Просмотрщик сторис */
.story-modal-content { background: #000; width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: center; position: relative; border-radius: 0; }
#story-media-container { flex-grow: 1; display: flex; align-items: center; justify-content: center; background: #000; }
#story-media-container img, #story-media-container video { max-width: 100%; max-height: 100%; object-fit: contain; }
.story-close-btn { position: absolute; top: 20px; right: 20px; width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,0.2); border: none; color: #fff; font-size: 24px; cursor: pointer; z-index: 100; backdrop-filter: blur(5px); }
.story-info { position: absolute; bottom: 0; left: 0; right: 0; padding: 30px 20px; background: linear-gradient(to top, rgba(0,0,0,0.9), transparent); color: #fff; text-align: center; }
#story-date { font-size: 12px; color: #aaa; font-family: var(--font-code); }
#story-caption { margin: 8px 0 0 0; font-size: 14px; }

/* --- 11. ПРОЧЕЕ --- */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 300px; color: #333; text-align: center; }
.empty-state i { font-size: 64px; margin-bottom: 20px; opacity: 0.15; color: #fff; }
.empty-state p { font-family: var(--font-code); font-size: 14px; color: #555; letter-spacing: 1px; text-transform: uppercase; }

.add-btn { background: linear-gradient(135deg, var(--accent), #0066cc); box-shadow: 0 0 15px var(--accent-glow); border: none; color: white; width: 42px; height: 42px; border-radius: 14px; font-size: 20px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: 0.3s; }
.add-btn:active { transform: scale(0.92); }
.back-btn { background: none; border: none; color: var(--accent); font-size: 16px; font-weight: 700; cursor: pointer; display: flex; align-items: center; width: 40px; justify-content: flex-start; }
.action-restore { color: var(--online); }
.action-archive { color: #ffcc00; }

.skeleton { background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.03) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite linear; border-radius: 6px; }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
.skeleton-card { display: flex; padding: 15px; background: rgba(255,255,255,0.02); border-radius: 16px; margin-bottom: 10px; }
.modal-overlay { background: rgba(0,0,0,0.8); backdrop-filter: blur(8px); display: none; position: fixed; inset: 0; z-index: 100; justify-content: center; align-items: flex-end; } .modal-overlay.open { display: flex; } .modal-content { background: #12141a; width: 100%; max-height: 85%; border-radius: 24px 24px 0 0; padding: 25px; border-top: 1px solid rgba(255,255,255,0.1); box-shadow: 0 -10px 40px rgba(0,0,0,0.7); overflow-y: auto; } .modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; } .modal-header h2 { font-size: 20px; font-weight: 800; }
.toast-container { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); z-index: 2000; width: 90%; max-width: 350px; display: flex; flex-direction: column; gap: 10px; pointer-events: none; } .toast { background: rgba(20, 25, 35, 0.95); backdrop-filter: blur(10px); border: 1px solid rgba(255, 255, 255, 0.1); border-left: 4px solid var(--accent); color: #fff; padding: 14px 18px; border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,0.6); font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 12px; animation: slideUpFade 0.3s ease forwards; pointer-events: auto; } .toast.success { border-left-color: var(--online); } .toast.error { border-left-color: var(--danger); }
.action-sheet-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 3000; backdrop-filter: blur(5px); flex-direction: column; justify-content: flex-end; align-items: center; padding-bottom: 25px; opacity: 0; transition: 0.3s; } .action-sheet-overlay.open { display: flex; opacity: 1; } .action-sheet { background: rgba(30, 34, 43, 0.95); width: 94%; max-width: 420px; border-radius: 16px; overflow: hidden; transform: translateY(150%); transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); box-shadow: 0 20px 50px rgba(0,0,0,0.8); border: 1px solid rgba(255,255,255,0.1); margin-bottom: 10px; backdrop-filter: blur(20px); } .action-sheet.open { transform: translateY(0); } .action-item { padding: 18px; text-align: center; color: #fff; font-size: 16px; border-bottom: 1px solid rgba(255,255,255,0.08); cursor: pointer; display: flex; align-items: center; justify-content: center; font-weight: 600; } .action-item:last-child { border-bottom: none; } .action-item:active { background: rgba(255,255,255,0.1); } .action-download { color: var(--accent); } .action-delete { color: var(--danger); } .action-cancel { color: #fff; font-weight: 600; } .action-sheet.cancel-block { background: rgba(30, 34, 43, 0.95); margin-bottom: 0; }
