@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600&display=swap');

        /* --- АПП-СТИЛИ (Убираем браузерное поведение) --- */
        html, body {
            overscroll-behavior: none; 
            -webkit-user-select: none; 
            user-select: none; 
            -webkit-tap-highlight-color: transparent; 
        }

        input, textarea, .msg-bubble, .single-email {
            -webkit-user-select: text;
            user-select: text;
        }

        .email-list, .reader-body {
            -webkit-overflow-scrolling: touch;
        }

        /* --- Стилизация скроллбара --- */
        ::-webkit-scrollbar { width: 8px; }
        ::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.2); border-radius: 10px; }
        ::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 10px; transition: background 0.3s ease; }
        ::-webkit-scrollbar-thumb:hover { background: var(--accent-color); }
        * { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.15) rgba(0, 0, 0, 0.2); }

        :root {
            --text-color: #e2e8f0;
            --text-muted: #94a3b8;
            --accent-color: #38bdf8;
            --accent-hover: #0ea5e9;
            --glass-bg: rgba(15, 23, 42, 0.7);
            --glass-border: rgba(255, 255, 255, 0.1);
        }

        * { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif; }

        body {
            background: url('../images/bg.jpg') no-repeat center center/cover;
            background-color: #0f172a;
            color: var(--text-color);
            height: 100vh;
            height: 100dvh;
            overflow: hidden;
        }

        .screen { display: none; height: 100%; width: 100%; align-items: center; justify-content: center; animation: fadeIn 0.5s ease; }
        .screen.active { display: flex; }
        @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

        .glass-panel {
            background: var(--glass-bg);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            border: 1px solid var(--glass-border);
            box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
        }

/* ЭКРАН ЛОГИНА */
        .login-box { width: 90%; max-width: 400px; padding: 40px; border-radius: 24px; text-align: center; }
        .logo { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 30px; }
        .logo.small { flex-direction: row; margin-bottom: 40px; }
        .Luna-icon { width: 48px; height: 48px; color: var(--accent-color); }
        .logo.small .Luna-icon { width: 28px; height: 28px; }

        .input-group { text-align: left; margin-bottom: 20px; }
        .input-group label { display: block; font-size: 14px; color: var(--text-muted); margin-bottom: 8px; }
        .input-group input, .input-group select { width: 100%; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--glass-border); background: rgba(0, 0, 0, 0.3); color: #fff; outline: none; transition: border 0.3s; }
        .input-group input:focus, .input-group select:focus { border-color: var(--accent-color); }
        .input-group select { appearance: none; cursor: pointer; }
        .input-group select option { background: #0f172a; color: #fff; } /* Темный фон для опций селектора */

        .btn { width: 100%; padding: 14px; border-radius: 12px; border: none; background: var(--accent-color); color: #fff; font-weight: 600; cursor: pointer; transition: background 0.3s; }
        .btn:hover { background: var(--accent-hover); }

        /* ЭКРАН ПОЧТЫ */
        .mail-container { width: 95%; max-width: 1300px; height: 90vh; border-radius: 24px; display: flex; overflow: hidden; position: relative; }

        .sidebar { width: 260px; padding: 24px; border-right: 1px solid var(--glass-border); background: rgba(0, 0, 0, 0.3); display: flex; flex-direction: column; transition: transform 0.3s ease; }
        .compose-btn { margin-bottom: 30px; }

        /* Меню и иконки */
        .nav-menu { flex: 1; overflow-y: auto; margin-bottom: 15px; } 
        .nav-menu a { display: flex; align-items: center; justify-content: space-between; padding: 12px; color: var(--text-muted); text-decoration: none; border-radius: 12px; margin-bottom: 5px; transition: all 0.3s; }
        .nav-menu a:hover, .nav-menu a.active { background: rgba(255, 255, 255, 0.1); color: var(--text-color); }

        .menu-item-left { display: flex; align-items: center; gap: 12px; }
        .menu-icon { width: 18px; height: 18px; stroke-width: 2px; opacity: 0.7; transition: 0.3s; }
        .nav-menu a:hover .menu-icon { opacity: 1; }
        .nav-menu a.active .menu-icon { opacity: 1; color: var(--accent-color); }
        .badge { background: var(--accent-color); color: #fff; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: bold; }

        /* --- РЕКЛАМНЫЙ БЛОК --- */
        .ad-banner {
            padding: 15px;
            background: linear-gradient(135deg, rgba(255,255,255,0.05), rgba(255,255,255,0.01));
            border: 1px dashed rgba(255, 255, 255, 0.2);
            border-radius: 12px;
            text-align: center;
            display: flex;
            flex-direction: column;
            gap: 6px;
            transition: 0.3s;
            margin-bottom: 15px;
            cursor: pointer;
        }
        .ad-banner:hover {
            border-color: var(--accent-color);
            background: rgba(255,255,255,0.08);
        }
        .ad-text {
            font-size: 11px;
            font-weight: 600;
            color: var(--text-color);
            line-height: 1.4;
        }
        .ad-label {
            font-size: 9px;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        /* --- НИЖНЯЯ ПАНЕЛЬ САЙДБАРА (ПРОФИЛЬ И ХРАНИЛИЩЕ) --- */
        .sidebar-footer { padding-top: 15px; border-top: 1px solid var(--glass-border); display: flex; flex-direction: column; gap: 15px; }

        .add-mailbox-btn { display: flex; align-items: center; gap: 12px; color: var(--text-muted); text-decoration: none; font-size: 14px; transition: 0.2s; cursor: pointer; }
        .add-mailbox-btn:hover { color: var(--text-color); }
        .add-mailbox-btn .menu-icon { color: var(--accent-color); opacity: 1; }

        .sidebar-user { display: flex; align-items: center; gap: 10px; color: var(--text-color); font-weight: 600; font-size: 14px; }
        .sidebar-user .avatar { width: 32px; height: 32px; }
        .storage-info { font-size: 12px; color: var(--text-muted); }
        .storage-text { margin-bottom: 5px; }
        .progress-bar { width: 100%; height: 6px; background: rgba(0, 0, 0, 0.3); border-radius: 3px; overflow: hidden; }
        .progress-fill { height: 100%; background: var(--accent-color); border-radius: 3px; }

        .mail-content { flex: 1; display: flex; min-height: 0;  flex-direction: column; position: relative; min-width: 0; }
        .mail-header { padding: 20px 30px; border-bottom: 1px solid var(--glass-border); display: flex; justify-content: space-between; align-items: center; gap: 15px; }
        .search-bar { flex: 1; max-width: 300px; padding: 10px 16px; border-radius: 20px; border: 1px solid var(--glass-border); background: rgba(255, 255, 255, 0.05); color: #fff; outline: none; }

        /* Иконки в шапке */
        .header-controls { display: flex; align-items: center; gap: 15px; }
        .btn-action-icon { background: none; border: none; color: var(--text-muted); cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center; }
        .btn-action-icon:hover { color: #fff; }
        .btn-action-icon svg { width: 22px; height: 22px; }

        /* Кнопка бургера (скрыта на ПК) */
        .burger-btn { display: none; background: none; border: none; color: var(--text-color); cursor: pointer; padding: 5px; }
        .burger-btn svg { width: 28px; height: 28px; }

        .user-profile { display: flex; align-items: center; justify-content: center; gap: 10px; white-space: nowrap; margin-left: 10px; border-left: 1px solid var(--glass-border); padding-left: 20px; }
        .avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--glass-border); object-fit: cover; }

        /* --- КАСТОМНЫЕ ЧЕКБОКСЫ --- */
        input[type="checkbox"] { 
            appearance: none;
            -webkit-appearance: none;
            width: 18px; 
            height: 18px; 
            border: 2px solid var(--text-muted); 
            border-radius: 5px; 
            background: rgba(0, 0, 0, 0.2); 
            cursor: pointer; 
            position: relative; 
            transition: all 0.2s ease-in-out;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
        }
        input[type="checkbox"]:hover {
            border-color: var(--accent-color);
        }
        input[type="checkbox"]:checked {
            background-color: var(--accent-color);
            border-color: var(--accent-color);
        }
        input[type="checkbox"]:checked::after {
            content: '';
            width: 4px;
            height: 9px;
            border: solid white;
            border-width: 0 2px 2px 0;
            transform: rotate(45deg);
            margin-bottom: 2px;
        }

        /* --- БАР МЕНЮ (ПАНЕЛЬ ДЕЙСТВИЙ) --- */
        .action-bar { padding: 12px 30px; border-bottom: 1px solid var(--glass-border); display: flex; align-items: center; gap: 20px; background: rgba(255, 255, 255, 0.02); flex-wrap: wrap; }
        .select-all-label { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; color: var(--text-muted); }
        .action-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
        .action-btn { background: rgba(255, 255, 255, 0.05); border: 1px solid var(--glass-border); color: var(--text-color); padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; transition: 0.2s; white-space: nowrap; }
        .action-btn:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }

        /* СПИСОК ПИСЕМ */
        .email-list { flex: 1; overflow-y: auto; padding: 10px; min-height: 0; }
        .email-item { display: grid; grid-template-columns: 30px 200px 1fr auto; gap: 15px; padding: 20px; border-bottom: 1px solid var(--glass-border); cursor: pointer; transition: background 0.2s; align-items: center; }
        .email-item:hover { background: rgba(255, 255, 255, 0.08); }
        .email-item.unread { font-weight: 600; color: #fff; background: rgba(255, 255, 255, 0.03); }
        .email-item.unread .email-sender { color: var(--accent-color); }
        .email-checkbox-wrap { display: flex; align-items: center; justify-content: center; }
        .email-info { min-width: 0; } 
        .email-subject { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px;}
        .email-desc { color: var(--text-muted); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        .email-time { font-size: 13px; color: var(--text-muted); white-space: nowrap; }

        /* ОКНО ЧТЕНИЯ */
        .mail-reader { position: absolute; top: 73px; left: 0; right: 0; bottom: 0; background: var(--glass-bg); backdrop-filter: blur(20px); display: flex; flex-direction: column; z-index: 10; }
        .reader-header { padding: 20px 30px; border-bottom: 1px solid var(--glass-border); display: flex; align-items: center; gap: 20px; }
        .btn-icon { background: none; border: none; color: var(--accent-color); font-size: 12px; cursor: pointer; padding: 5px 10px; border-radius: 8px; transition: 0.2s; white-space: nowrap; }
        .btn-icon:hover { background: rgba(255, 255, 255, 0.1); }
        .reader-body { flex: 1; overflow-y: auto; padding: 30px; display: flex; flex-direction: column; gap: 20px; min-height: 0; }

        /* СТИЛИ ЧАТА / ПИСЬМА */
        .message-wrap { display: flex; flex-direction: column; max-width: 70%; margin-bottom: 10px; }
        .message-wrap.me { align-self: flex-end; align-items: flex-end; }
        .message-wrap.them { align-self: flex-start; align-items: flex-start; }

        .msg-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 5px; padding: 0 5px; }
        .msg-bubble { padding: 15px 20px; border-radius: 18px; line-height: 1.5; font-size: 15px; }
        .message-wrap.them .msg-bubble { background: rgba(255, 255, 255, 0.1); border-bottom-left-radius: 4px; }
        .message-wrap.me .msg-bubble { background: var(--accent-color); color: #fff; border-bottom-right-radius: 4px; }

        .single-email { background: rgba(255, 255, 255, 0.05); padding: 30px; border-radius: 16px; line-height: 1.6; white-space: pre-wrap; }

        .msg-image {
            max-width: 100%;
            max-height: 400px;
            border-radius: 12px;
            margin-top: 15px; 
            display: block;
            object-fit: cover;
        }

        /* ПАНЕЛЬ ОТВЕТА ВНУТРИ ПИСЬМА */
        .reader-reply-actions { display: flex; gap: 15px; margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--glass-border); }
        .reader-reply-actions .action-btn { display: flex; align-items: center; gap: 8px; padding: 10px 20px; font-weight: 600; }

        /* АДАПТИВ (БУРГЕР И МОБИЛЬНАЯ ВЕРСИЯ) */
        @media (max-width: 850px) {
            .single-email {
                font-size: 13px;
            }
            .ad-banner {
                display: none;
            }
            .nav-menu a {
                font-size: 11px;
                padding: 3px;
            }
            .compose-btn {
                margin-bottom: 10px;
                padding: 5px;
                font-size: 11px;
            }
            .msg-bubble {
                font-size: 13px;
            }
            .msg-meta {
                font-size: 10px;
            }
            #reader-subject {
                font-size: 11px;
            }
            
            .burger-btn { display: block; }

            .sidebar { 
                position: absolute; left: 0; top: 0; bottom: 0; z-index: 100;
                transform: translateX(-100%); 
                background: rgba(15, 23, 42, 0.95); 
                backdrop-filter: blur(25px);
            }
            .sidebar.open { transform: translateX(0); box-shadow: 20px 0 50px rgba(0,0,0,0.5); }

            .mail-header { padding: 15px 20px; }

            .user-profile span { display: none; }
            .user-profile { border-left: none; padding-left: 0; margin-left: auto; } 

            .search-bar { max-width: 100%; display: none; }

            .action-bar { 
                padding: 10px 20px; 
                flex-wrap: nowrap;
                overflow-x: auto;
                scrollbar-width: none;
                -webkit-overflow-scrolling: touch;
            }
            .action-bar::-webkit-scrollbar { display: none; }
            .select-all-label { flex-shrink: 0; }
            .action-buttons { flex-wrap: nowrap; gap: 8px; }
            .email-item {
                font-size: 11px;
            }
            .action-btn {
                font-size: 10px;
            }
            .email-item { grid-template-columns: 30px 1fr; gap: 5px 10px; padding: 15px 20px; position: relative; }
            .email-checkbox-wrap { grid-row: span 2; align-items: flex-start; margin-top: 2px; }
            .email-time { position: absolute; top: 15px; right: 20px; font-size: 9px; }
            .email-desc { padding-right: 10px; }

            .reader-header { padding: 15px 20px; }
            .reader-body { padding: 20px; }
            .message-wrap { max-width: 90%; } 

            .reader-reply-actions { flex-direction: column; gap: 10px; }
            .reader-reply-actions .action-btn { justify-content: center; width: 100%; }

            .mail-container { 
                width: 100%; 
                height: 100dvh; 
                border-radius: 0; 
            }
        }

        /* Дополнения для нового ящика; существующие экраны сохраняют свой вид. */
        #recovery-box { max-height: calc(100dvh - 32px); overflow-y: auto; }
        #mail-screen[data-account="melianov"] .email-sender { min-width: 0; overflow-wrap: anywhere; }
        #mail-screen[data-account="melianov"] .single-email { overflow-wrap: anywhere; }
        @media (max-width: 850px) {
            #mail-screen[data-account="melianov"] .email-sender { padding-right: 112px; }
        }
