/* MOBILE FAB (Bottom Right) */
.mobile-fab {
    display: none; position: fixed; bottom: 25px; right: 25px; width: 60px; height: 60px;
    border-radius: 50%; background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
    color: white; border: none; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6); z-index: 9990;
    cursor: pointer; align-items: center; justify-content: center; font-size: 1.8rem;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s;
}
.mobile-fab:active { transform: scale(0.9); }

/* NEW: Hide FAB when any modal is open */
body.modal-open .mobile-fab {
    display: none !important;
    opacity: 0;
    pointer-events: none;
}

/* MENU BACKDROP */
body.menu-open::after {
    content: ''; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
    z-index: 9980; opacity: 0; animation: fadeInOverlay 0.3s forwards; pointer-events: none;
}
@keyframes fadeInOverlay { from { opacity: 0; } to { opacity: 1; } }

/* DRAG HANDLE */
.mobile-menu-handle { display: none; width: 100%; height: 25px; justify-content: center; align-items: center; cursor: pointer; margin: 0; }
.mobile-menu-handle::after { content: ''; width: 40px; height: 5px; background: #444; border-radius: 10px; }

/* MEDIA QUERIES */
@media (max-width: 768px) {
    /* Page Adjustments */
    .page { padding: 0 15px 100px 15px; margin-top: 10px; }
    .db-grid, .guide-grid { grid-template-columns: 1fr; }
    .header-toggle-strip, #sticky-sentinel { display: none !important; }
    
    /* Show Mobile Elements */
    .mobile-fab, .mobile-menu-handle { display: flex; }
    .config-view-btn { width: 100%; margin: 0 0 10px 0; text-align: center; }

    /* Bottom Sheet Toolbar */
    .sticky-toolbar-container {
        position: fixed; top: auto; bottom: 0; left: 0; width: 100%; height: auto; max-height: 85vh;
        background: rgba(15, 16, 20, 0.98); backdrop-filter: blur(15px); border-top: 1px solid var(--accent-start);
        border-bottom: none; border-radius: 20px 20px 0 0; box-shadow: 0 -10px 40px rgba(0,0,0,0.8);
        padding: 10px 20px 30px 20px; z-index: 10000; transform: translateY(120%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); flex-direction: column; align-items: stretch; overflow-y: auto;
        gap: 10px !important; /* Reduced Gap */
    }
    
    .sticky-toolbar-container.is-mobile-open { transform: translateY(0); }

    /* FORCE VISIBILITY & RESET DESKTOP COLLAPSE */
    .sticky-toolbar-container .nav-bar, 
    .sticky-toolbar-container .injector-panel {
        max-height: none !important;
        opacity: 1 !important;
        padding: 0 !important;
        margin: 0 !important;
        pointer-events: auto !important;
        visibility: visible !important;
        border: none !important;
    }

    /* NAVIGATION GRID */
    .nav-bar { 
        display: grid !important; 
        grid-template-columns: 1fr 1fr; 
        gap: 10px; 
        width: 100%; 
    }
    .nav-btn { width: 100%; text-align: center; padding: 12px; background: rgba(255,255,255,0.05); border: 1px solid #333; }

    /* INJECTOR PANEL (Bottom Section) */
    .injector-panel { 
        flex-direction: column; align-items: stretch; gap: 12px; background: transparent; width: 100%; 
        /* Divider Styling */
        padding-top: 15px !important;
        border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
    }
    .injector-panel select { width: 100%; max-width: none; padding: 12px; font-size: 1rem; }
    .add-btn { margin: 0 0 10px 0; text-align: center; }

    /* Mobile Toggles */
    .nav-toggle-label { display: flex; justify-content: space-between; padding: 15px; margin: 0; background: rgba(0,0,0,0.4); border: 1px solid #333; font-size: 0.9rem; }
    .mobile-switch-visual { position: relative; width: 40px; height: 20px; background: #333; border-radius: 20px; transition: 0.3s; }
    .mobile-switch-visual::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: 0.3s; }
    input[type="checkbox"]:checked ~ .mobile-switch-visual { background: var(--success); }
    input[type="checkbox"]:checked ~ .mobile-switch-visual::after { transform: translateX(20px); }
}