/* =======================================================
   Карманный Молитвослов v1.2.1 - App Dashboard Layout
   ======================================================= */

/* 🔹 ТЕМЫ ОФОРМЛЕНИЯ */
.m-app-wrapper[data-theme="white"] {
    --bg: #ffffff; --text: #1a1a1a; --head: #000000; --accent: #c9a56a; 
    --rubric: #cc0000; --mask: rgba(240,240,240,0.88);
}
.m-app-wrapper[data-theme="cream"] {
    --bg: #fdfbf7; --text: #4a4541; --head: #2c2c2c; --accent: #c9a56a; 
    --rubric: #b22222; --mask: rgba(230,225,215,0.85);
}
.m-app-wrapper[data-theme="sepia"] {
    --bg: #e8dcc7; --text: #3b352d; --head: #2a251e; --accent: #8c6a32; 
    --rubric: #a82727; --mask: rgba(190,175,145,0.82);
}
.m-app-wrapper[data-theme="gray"] {
    --bg: #4b4b4d; --text: #e6e6e6; --head: #ffffff; --accent: #d4af6e; 
    --rubric: #ff7878; --mask: rgba(30,30,30,0.82);
}
.m-app-wrapper[data-theme="dark"] {
    --bg: #121110; --text: #e6dfd5; --head: #f5eedc; --accent: #d4af6e; 
    --rubric: #d44d4d; --mask: rgba(0,0,0,0.82);
}

/* 🔹 ОСНОВНОЙ КОНТЕЙНЕР */
.m-app-wrapper {
    width: 100% !important; max-width: 100% !important; margin: 0 !important; padding: 0 !important;
    font-family: Georgia, "Times New Roman", serif; position: relative;
    -webkit-font-smoothing: antialiased; background: var(--bg);
}

/* Эффект Свечи (на ПК под контентом, обходит сайдбары) */
.m-glow-overlay {
    position: fixed; top: 0; right: 0; bottom: 0; left: 320px;
    pointer-events: none; z-index: 10;
    background: radial-gradient(circle at 50% 50%, rgba(255, 185, 85, 0.12) 0%, rgba(250, 160, 60, 0.16) 55%, rgba(240, 130, 30, 0.24) 100%);
    box-shadow: inset 0 0 150px rgba(250, 150, 45, 0.22), inset 0 0 60px rgba(250, 150, 45, 0.15);
    opacity: 0; transition: opacity 0.5s ease;
}
.glow-active .m-glow-overlay { opacity: 1; }
.m-app-wrapper[data-theme="white"] .m-glow-overlay,
.m-app-wrapper[data-theme="cream"] .m-glow-overlay,
.m-app-wrapper[data-theme="sepia"] .m-glow-overlay { display: none !important; }

/* Z-index слои */
.m-top-layer { z-index: 100001 !important; position: relative; } /* Выше лупы, но ниже PWA-модалки */

/* Отключение скролла страницы при лупе */
body.m-no-scroll { overflow: hidden !important; }

/* 🔹 УНИФИЦИРОВАННЫЙ КЛАСС ТЕМНОГО МОКРОГО СТЕКЛА */
.glass-style {
    background: rgba(30, 30, 30, 0.75) !important;
    backdrop-filter: blur(12px) !important; -webkit-backdrop-filter: blur(12px) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important; color: #ffffff !important;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3) !important; transition: all 0.3s ease !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8) !important;
}
.glass-style:hover { background: rgba(15, 15, 15, 0.95) !important; border-color: rgba(212, 175, 55, 0.7) !important; }

/* 🔹 ШАПКА (Умная прозрачность, всегда поверх лупы z-index: 100000) */
.m-app-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 20px; z-index: 100000; position: sticky; top: 0; border-radius: 0 !important;
    background: rgba(20, 20, 20, 0.05) !important;
    backdrop-filter: blur(2px) !important; -webkit-backdrop-filter: blur(2px) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05); transition: all 0.3s ease !important;
}
.m-app-header:hover {
    background: rgba(15, 15, 15, 0.95) !important;
    backdrop-filter: blur(12px) !important; -webkit-backdrop-filter: blur(12px) !important;
}

.m-app-title { margin: 0; font-size: 22px; color: #d4af37 !important; font-family: inherit; letter-spacing: 1px; text-shadow: none !important; }
.m-header-right-actions { display: flex; align-items: center; gap: 10px; }

/* Кнопка На главную (Header) */
.m-home-link-header {
    display: flex; align-items: center; justify-content: center; text-decoration: none !important; color: #d4af37;
    font-size: 22px; font-weight: bold; margin-right: 15px; transition: all 0.2s; padding: 0 5px;
}
.m-home-link-header:hover { color: #fff; transform: scale(1.1); }

/* Кнопки иконок шапки */
.m-header-btn {
    width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; position: relative;
    cursor: pointer; color: #d4af37; background: transparent; border: 1px solid transparent; font-size: 22px; transition: all 0.2s ease;
}
.m-header-btn:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.2); }

/* Прячем мобильные кнопки на ПК */
.m-mobile-only-btn { display: none !important; }
.m-mobile-only-menu { display: none !important; }

/* 🔹 ЛЕЙАУТ (С фонариками на ПК) */
.m-layout { 
    display: flex; min-height: calc(100vh - 65px); background: transparent; position: relative; z-index: 20;
}

@media (min-width: 901px) {
    .m-layout {
        background-image: url('/calendar_data/calendar_images/separator3.webp');
        background-attachment: fixed; background-position: left 20px top 75px;
        background-repeat: no-repeat; background-size: 280px auto;
    }
    .m-transparent-sidebar.glass-style { background: rgba(30, 30, 30, 0.25) !important; }
    .m-transparent-sidebar.glass-style:hover { background: rgba(15, 15, 15, 0.95) !important; }
}

/* Левый Сайдбар (ПК) */
.m-desktop-only-menu {
    width: 320px; flex-shrink: 0; padding: 30px 20px 100px 20px; display: flex; flex-direction: column;
    position: relative; border-radius: 0 !important; border-top: none !important; border-bottom: none !important; z-index: 100;
}
.m-desktop-only-menu h3 {
    color: #fdfcf9 !important; text-align: center; font-size: 1.25em; font-weight: bold;
    margin-bottom: 25px; padding-bottom: 10px; border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

/* Кнопка "На главную" внизу сайдбаров */
.m-home-link-sidebar {
    display: block; text-decoration: none !important; color: #d4af37; font-size: 15px; font-weight: bold; margin-top: 30px;
    padding: 12px; text-align: center; border: 1px solid rgba(212, 175, 55, 0.3); border-radius: 10px; background: rgba(30, 30, 30, 0.4); transition: all 0.2s;
}
.m-home-link-sidebar:hover { background: rgba(212, 175, 55, 0.2); color: #fff; }

/* АККОРДЕОНЫ */
.m-accordion { margin-bottom: 15px; border-radius: 12px; background: rgba(30, 30, 30, 0.5); border: 1px solid rgba(255, 255, 255, 0.1); }
.m-accordion summary { padding: 14px; font-weight: 600; font-size: 0.95em; cursor: pointer; list-style: none; color: #ffffff; }
.m-accordion[open] summary { border-bottom: 1px solid rgba(255, 255, 255, 0.15); color: #d4af37; }
.m-nav-item {
    padding: 10px 14px; margin: 8px 10px; font-size: 0.9em; cursor: pointer; border-radius: 8px;
    background: rgba(255,255,255,0.05); color: #ccc; transition: all 0.2s;
}
.m-nav-item:hover, .m-nav-item.active { background: rgba(212, 175, 55, 0.2); color: #d4af37; font-weight: bold; }

/* 🔹 ЦЕНТРАЛЬНАЯ ЧАСТЬ */
.m-content-area {
    flex: 1; position: relative; display: flex; flex-direction: column;
    background: transparent; color: var(--text); z-index: 20;
}
.m-ajax-wrapper { position: relative; flex: 1; }
.m-ajax-container { padding: 40px 60px 80px 60px; max-width: 1000px; margin: 0 auto; }

/* Умная кнопка "В начало" */
#m-go-home.notch-mode {
    position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    padding: 8px 30px 12px 30px; border-radius: 0 0 18px 18px;
    font-size: 13px; font-weight: bold; z-index: 50; text-decoration: none;
}
#m-go-home.sticky-mode {
    position: sticky; top: 50%; display: block; width: max-content;
    margin: 40px auto 20px auto; padding: 12px 35px; border-radius: 20px;
    font-size: 14px; font-weight: bold; z-index: 100; transform: none !important; text-decoration: none;
}

/* Оформление молитв (Больше воздуха) */
.m-rule-header {
    font-size: 2.4em; text-align: center; color: var(--head); 
    margin-top: 50px; margin-bottom: 40px; padding-top: 20px; padding-bottom: 20px; 
    border-bottom: 2px solid var(--accent); font-family: inherit;
}
.m-prayer-block { margin-bottom: 40px; transition: opacity 0.3s ease; }
.m-prayer-title { color: var(--head); font-size: 1.6em; margin: 0 0 10px 0; text-align: center; font-family: inherit; }
.m-prayer-author { text-align: center; font-style: italic; font-size: 0.9em; opacity: 0.7; margin-bottom: 15px; }

/* Уставные указания (Допинфо - киноварь) */
.m-rubric { display: block; font-size: 0.85em; color: var(--rubric); opacity: 0.9; font-style: italic; margin-bottom: 15px; text-align: center; line-height: 1.4; }
.m-prayer-text { line-height: 1.6; font-size: 18px; color: var(--text); text-align: justify; }

/* Разделитель в конце */
.m-end-separator { text-align: center; margin: 50px 0 30px 0; }
.m-end-separator img { max-width: 150px; opacity: 0.8; }

/* Фокус абзацев */
.m-paragraph-focus-mode .m-focus-block { opacity: 0.25; transition: opacity 0.2s ease; }
.m-paragraph-focus-mode .m-focus-block.m-active-paragraph { opacity: 1; }

/* 🔹 ПРАВЫЙ САЙДБАР (Парящие настройки z-index: 100010, ниже шапки) */
.m-settings-floating {
    position: fixed; top: 120px; right: -400px; 
    width: 320px; max-height: calc(100vh - 140px);
    border-radius: 20px; padding: 20px 15px; overflow-y: auto;
    z-index: 100010; transition: right 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.m-settings-floating.active { right: 20px; }
.m-close-menu { position: absolute; top: 15px; right: 20px; font-size: 28px; color: #f0e6d2; cursor: pointer; background: none; border: none; }

.m-settings-scroll-area { display: flex; flex-direction: column; gap: 20px; margin-top: 10px; }
.m-setting-group { display: flex; flex-direction: column; gap: 10px; }
.m-setting-label { font-size: 10px; text-transform: uppercase; color: #d4af37; opacity: 0.8; font-family: sans-serif; letter-spacing: 1px; text-align: center; }

/* Кругляши (Капли) - Уменьшенный размер 46x46 (На мобилке 40х40) */
.m-drops-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; }
.m-drop-btn {
    width: 46px; height: 46px; border-radius: 50%;
    background: rgba(20,20,20,0.8); color: #fff;
    border: 1px solid rgba(255,255,255,0.2); box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.2s ease; padding: 0; margin: 0; position: relative;
}
.m-drop-btn:hover { transform: scale(1.1); background: rgba(40,40,40,0.9); border-color: #d4af37; }
.m-drop-btn.active { outline: 2px solid #d4af37; outline-offset: 2px; color: #d4af37; }
.m-drop-btn.font-btn { font-size: 15px; font-weight: bold; font-family: Georgia, serif; }
.m-drop-btn svg { width: 20px; height: 20px; }
.m-focus-badge {
    position: absolute; top: -2px; right: -2px; width: 16px; height: 16px;
    background: #d4af37; color: #121110; border-radius: 50%;
    font-size: 10px; display: flex; align-items: center; justify-content: center; font-weight: bold; font-family: sans-serif;
}

/* Select под кругляш */
select.m-drop-select {
    appearance: none; -webkit-appearance: none; color: transparent;
    background-repeat: no-repeat; background-position: center; background-size: 20px;
}
select.m-drop-select option { color: #1a1a1a; background: #fff; }
.drop-icon-font { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="%23ffffff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 7 4 4 20 4 20 7"/><line x1="9" y1="20" x2="15" y2="20"/><line x1="12" y1="4" x2="12" y2="20"/></svg>'); }
.drop-icon-align { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="%23ffffff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="21" y1="10" x2="3" y2="10"/><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="14" x2="3" y2="14"/><line x1="21" y1="18" x2="3" y2="18"/></svg>'); }

/* Оверлей для клика мимо меню */
.m-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 99980; display: none; backdrop-filter: blur(2px);
}
.m-overlay.active { display: block; }

/* 🔹 СЛОИ ФОКУСА (Линейка, Лупа) */
.m-reading-mask {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0; pointer-events: none; z-index: 99985; display: none;
    background: linear-gradient(to bottom, var(--mask) 0%, var(--mask) calc(var(--mask-y, 50vh) - 65px), rgba(0,0,0,0) calc(var(--mask-y, 50vh) - 28px), rgba(0,0,0,0) calc(var(--mask-y, 50vh) + 28px), var(--mask) calc(var(--mask-y, 50vh) + 65px), var(--mask) 100%);
}
.m-reading-mask.active { display: block; }

/* Лупа - z-index ниже шапки и настроек! (99980) */
.m-loupe {
    position: fixed; top: 0; left: 0; width: 260px; height: 260px; border-radius: 50%;
    border: 2px solid var(--accent); background-color: var(--bg);
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55), inset 0 0 18px rgba(201, 165, 106, 0.25);
    overflow: hidden; pointer-events: none; z-index: 99980; display: none;
    transform: translate3d(-9999px, -9999px, 0); will-change: transform;
}
.m-loupe.active { display: block; }
.m-loupe-inner { position: absolute; top: 0; left: 0; transform-origin: 0 0; pointer-events: none; color: var(--text); will-change: transform; }
.m-loupe-inner * { background: transparent !important; }
.m-loupe-badge {
    position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
    background: rgba(18, 17, 16, 0.8); color: var(--accent); border: 1px solid rgba(201, 165, 106, 0.5);
    padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: bold; font-family: sans-serif;
}

/* Скроллбар для лупы */
.m-loupe-scrollbar {
    position: fixed; top: 65px; right: 2px; width: 6px; bottom: 5px;
    background: rgba(0,0,0,0.1); border-radius: 3px; z-index: 99997; display: none;
}
.m-loupe-scrollbar.active { display: block; }
.m-loupe-scroll-thumb {
    position: absolute; top: 0; left: 0; width: 100%; min-height: 40px;
    background: var(--accent); border-radius: 3px; cursor: pointer;
}

/* 🔹 МОДАЛЬНОЕ ОКНО PWA УСТАНОВКИ (Самый верх - 100020) */
.m-pwa-modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7); display: none; align-items: center; justify-content: center;
    backdrop-filter: blur(5px); z-index: 100020;
}
.m-pwa-modal.active { display: flex; }
.m-pwa-modal-content {
    width: 90%; max-width: 400px; border-radius: 15px; padding: 30px;
    text-align: center; position: relative;
}
.m-pwa-install-btn {
    display: inline-block; padding: 12px 25px; margin-top: 15px;
    font-size: 16px; font-weight: bold; color: #fff; background: rgba(212, 175, 55, 0.3);
    border: 1px solid #d4af37; border-radius: 10px; cursor: pointer; transition: all 0.2s;
}
.m-pwa-install-btn:hover { background: rgba(212, 175, 55, 0.6); }

/* 🔹 МОБИЛЬНАЯ АДАПТАЦИЯ */
@media (max-width: 900px) {
    .m-layout { flex-direction: column; }
    
    .m-desktop-only-btn { display: none !important; } 
    .m-desktop-only-menu { display: none !important; } 
    .m-mobile-only-btn { display: flex !important; } 
    
    /* Шапка на мобильном: сжатая */
    .m-app-header { padding: 5px 10px; }
    .m-app-title { font-size: 17px; }
    .m-header-right-actions { gap: 2px; }
    .m-header-btn { width: 38px; height: 38px; font-size: 18px; }

    /* Парящие настройки на мобильном выплывают под шапкой (top: 55px) и не наезжают на нее */
    .m-settings-floating {
        top: 75px; height: calc(100vh - 55px); right: -100%; border-radius: 0; width: 300px; z-index: 100015;
    }
    .m-settings-floating.active { right: 0; }
    
    /* Уменьшенные кругляши на мобильном */
    .m-drop-btn { width: 40px; height: 40px; }
    .m-drop-btn svg { width: 18px; height: 18px; }
    .m-drop-btn.font-btn { font-size: 14px; }
    select.m-drop-select { background-size: 18px; }

    /* Свеча на 100% экрана для мобильных (перекрывает пустоты) */
    .m-glow-overlay { left: 0; height: 100vh; width: 100vw; position: fixed; }
    
    .m-ajax-container { padding: 30px 20px 60px 20px; }
    .m-loupe { width: 200px; height: 200px; }
    
    /* Мобильное левое меню - Парящее, Z-index 100015, как настройки */
    .m-floating-menu {
        display: block !important; position: fixed; left: -100%; top: 55px; width: 85%; max-width: 320px; height: calc(100vh - 55px);
        z-index: 100015; transition: left 0.3s ease; padding: 20px; overflow-y: auto;
        border-radius: 0 !important; box-shadow: 5px 0 20px rgba(0,0,0,0.5) !important;
    }
    .m-floating-menu.active { left: 0; }
}