
    /* 0. Remove custom cursor on mobile */
    * {
        cursor: auto !important;
    }
    button, a, [role="button"], .grid-btn, .tab-btn {
        cursor: pointer !important;
    }
    #editor {
        cursor: text !important;
    }

    /* 1. Hide Desktop Action Bar and Status Bar */
    .action-bar-wrapper {
        display: none !important;
    }
    
    .status-bar, #btn-layout-toggle {
        display: none !important;
    }
    
    /* 2. Hide Fake Caret & Custom I-Beam Cursor logic since mobile keyboards don't need it */
    #fake-caret-overlay, .fake-caret-inline, #custom-cursor {
        display: none !important;
    }

    /* 3. Layout Overrides for Mobile */
    #editor-wrapper {
        padding-bottom: 0 !important;
        height: calc(100% - 40px) !important; /* Leave space for mobile footer */
    }

    .editor-container {
        padding: 0 !important;
        max-width: 100% !important;
    }

    #editor {
        padding: 15px 15px 0px 15px !important;
        font-size: 1.15rem !important;
    }

    /* Split View Override for Mobile */
    #editor-wrapper.split-active {
        flex-direction: column-reverse !important;
    }
    
    #editor-wrapper.split-active #editor,
    #editor-wrapper.split-active #markdown-preview {
        width: 100% !important;
    }
    
    #editor-wrapper.split-active #md-resizer {
        position: relative !important;
        width: 100% !important;
        height: 16px !important;
        cursor: row-resize !important;
        background: transparent !important;
        border: none !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        z-index: 100 !important;
        opacity: 1 !important;
    }
    
    #editor-wrapper.split-active #md-resizer::after {
        content: '' !important;
        display: block !important;
        width: 40px !important;
        height: 6px !important;
        background: var(--text-color) !important;
        opacity: 0.4 !important;
        border-radius: 3px !important;
    }

    #bottom-bg-block, #btn-exit-focus {
        display: none !important;
    }

    /* 4. Mobile FAB Styles */
    #mobile-fab {
        position: fixed !important;
        bottom: max(24px, env(safe-area-inset-bottom));
        right: 8px;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: var(--ui-bg);
        box-shadow: 0 4px 16px rgba(0,0,0,0.25);
        border: 1px solid var(--ui-border);
        z-index: 1000;
        display: flex;
        justify-content: center;
        align-items: center;
        transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.2s;
        pointer-events: auto;
        padding: 0;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        outline: none;
        transform: translateY(calc(-1 * var(--kb-offset, 0px))) rotate(var(--fab-rotate, 0deg));
    }
    
    [data-theme="dark"] #mobile-fab { background: rgba(48, 49, 52, 1); }
    [data-theme="warm"] #mobile-fab { background: rgba(245, 230, 149, 1); }

    #mobile-fab img {
        width: 32px;
        height: 32px;
        object-fit: contain;
        transition: transform 0.3s;
    }
    
    .fab-open #mobile-fab {
        --fab-rotate: 45deg;
    }
    
    /* 5. Mobile FAB Menus */
    #mobile-fab-menu {
        position: fixed;
        bottom: 0; right: 0; left: 0; top: 0;
        max-width: none;
        pointer-events: none;
        z-index: 900;
        background: transparent;
    }
    
    #mobile-qt-trigger {
        position: fixed !important;
        bottom: calc(max(24px, env(safe-area-inset-bottom)) + 4px); /* slightly smaller 48px, so +4px vertically aligns with 56px FAB */
        right: 80px;
        width: 48px;
        height: 48px;
        border-radius: 50%;
        background: var(--ui-bg);
        box-shadow: 0 4px 16px rgba(0,0,0,0.25);
        border: 1px solid var(--ui-border);
        z-index: 1000;
        display: flex;
        justify-content: center;
        align-items: center;
        transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.3s;
        pointer-events: none;
        opacity: 0;
        transform: translateY(calc(-1 * var(--kb-offset, 0px))) scale(0);
        cursor: pointer;
        font-size: 20px;
    }
    
    #mobile-qt-trigger.visible {
        opacity: 1;
        pointer-events: auto;
        transform: translateY(calc(-1 * var(--kb-offset, 0px))) scale(1);
    }
    
    .fab-open #mobile-qt-trigger {
        opacity: 0 !important;
        pointer-events: none !important;
        transform: translateY(calc(-1 * var(--kb-offset, 0px))) scale(0) !important;
    }
    
    #quick-tip-popup.qt-mobile-anchored {
        top: auto !important;
        left: auto !important;
        right: 16px !important;
        bottom: calc(max(24px, env(safe-area-inset-bottom)) + 80px) !important;
        transform: translateY(calc(-1 * var(--kb-offset, 0px))) !important;
        transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s !important;
        max-height: calc(100vh - var(--kb-offset, 0px) - max(24px, env(safe-area-inset-bottom)) - 100px) !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Make submenus accordion-style so they aren't clipped by overflow-y */
    #quick-tip-popup.qt-mobile-anchored .qt-submenu {
        position: static !important;
        width: auto !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        padding: 0 0 0 8px !important;
        margin: 4px 16px 4px 8px;
        background: transparent !important;
        border-left: 2px solid var(--ui-border) !important;
    }
    
    #quick-tip-popup.qt-mobile-anchored .has-submenu:hover>button.submenu-trigger span,
    #quick-tip-popup.qt-mobile-anchored .has-submenu.kb-open>button.submenu-trigger span {
        transform: rotate(90deg);
        display: inline-block;
    }
    
    .action-group-horizontal {
        position: absolute;
        bottom: calc(max(24px, env(safe-area-inset-bottom)) + 9px);
        right: 8px;
        display: flex;
        flex-direction: row-reverse;
        align-items: center;
        gap: 10px;
        background: var(--ui-bg);
        border: 1px solid var(--ui-border);
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        border-radius: 12px 28px 28px 12px;
        padding: 2px 56px 2px 2px;
        pointer-events: none;
        opacity: 0;
        transform: translateY(calc(-1 * var(--kb-offset, 0px))) translateX(20px) scale(0.9);
        transform-origin: calc(100% - 28px) center;
        transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }
    
    .action-group-vertical {
        position: absolute;
        bottom: max(24px, env(safe-area-inset-bottom));
        right: 17px;
        display: flex;
        flex-direction: column-reverse;
        align-items: center;
        gap: 10px;
        background: var(--ui-bg);
        border: 1px solid var(--ui-border);
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        border-radius: 12px 12px 28px 28px;
        padding: 2px 2px 56px 2px;
        pointer-events: none;
        opacity: 0;
        transform: translateY(calc(20px - var(--kb-offset, 0px))) scale(0.9);
        transform-origin: center calc(100% - 28px);
        transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }
    
    .fab-open .action-group-horizontal {
        opacity: 1;
        pointer-events: auto;
        transform: translateY(calc(-1 * var(--kb-offset, 0px))) translateX(0) scale(1);
    }
    
    .fab-open .action-group-vertical {
        opacity: 1;
        pointer-events: auto;
        transform: translateY(calc(-1 * var(--kb-offset, 0px))) scale(1);
    }
    
    .action-group-horizontal > *, .action-group-vertical > * {
        background: transparent;
        border: none;
        position: relative !important;
        width: 34px !important; height: 34px !important;
        min-width: 34px !important; min-height: 34px !important;
        max-width: 34px !important; max-height: 34px !important;
        box-sizing: border-box !important;
        display: flex; justify-content: center; align-items: center;
        padding: 0 !important;
        margin: 0 !important;
        cursor: pointer;
        border-radius: 50%;
        transition: background 0.2s;
        -webkit-tap-highlight-color: transparent;
        outline: none;
    }

    /* Dividers between buttons */
    .action-group-horizontal > *:not(:last-child)::after {
        content: '';
        position: absolute;
        left: -5.5px;
        top: 50%;
        transform: translateY(-50%);
        width: 1px;
        height: 16px;
        background: var(--ui-border);
        opacity: 0.8;
    }

    .action-group-vertical > *:not(:last-child)::after {
        content: '';
        position: absolute;
        top: -5.5px;
        left: 50%;
        transform: translateX(-50%);
        width: 16px;
        height: 1px;
        background: var(--ui-border);
        opacity: 0.8;
    }

    .action-group-horizontal > button, .action-group-vertical > button {
        font-size: 1.1rem;
        color: var(--text-color);
    }

    .action-group-horizontal .dropdown > button, .action-group-vertical .dropdown > button {
        width: 100%; height: 100%;
        display: flex; justify-content: center; align-items: center;
        background: transparent; border: none; padding: 0; margin: 0;
        font-size: 1.1rem; border-radius: 50%;
        color: var(--text-color);
    }

    .action-group-horizontal > *:active, .action-group-vertical > *:active,
    .action-group-horizontal .dropdown > button:active, .action-group-vertical .dropdown > button:active {
        background: rgba(128, 128, 128, 0.15);
    }
    
    .fab-open .action-group-horizontal, .fab-open .action-group-vertical {
        opacity: 1;
        transform: translate(0, 0) scale(1);
        pointer-events: auto;
    }

    /* 1. Hide the explicit hide-mobile spans on the main buttons (File, Insert, Tools, Info) */
    #mobile-fab-menu .hide-mobile,
    body > .dropdown-content .hide-mobile {
        display: none !important;
    }

    /* 3. Portaled Dropdown — moved to document.body by mobile.js.
          JS sets position:fixed + top/left/maxHeight/maxWidth dynamically
          to avoid overlapping the FAB zone. CSS only sets base appearance. */
    body > .dropdown-content {
        overflow-y: auto !important;
        z-index: 99999 !important;
        box-sizing: border-box !important;
    }
    
    /* 6. Mobile Footer */
    #mobile-footer {
        position: fixed !important;
        bottom: 0; left: 0; right: 0;
        height: 24px;
        background: var(--ui-bg);
        border-top: 1px solid var(--ui-border);
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 16px;
        font-family: inherit;
        font-size: 0.75rem;
        color: var(--text-color);
        z-index: 1000;
    }

    /* 7. Focus Mode on Mobile */
    body.mobile-focus-mode #mobile-footer {
        display: none !important;
    }

    body.mobile-focus-mode #editor-wrapper {
        height: 100% !important;
    }

    body.mobile-focus-mode #mobile-fab-menu:not(.fab-open) #mobile-fab {
        right: 0; left: auto; bottom: 0;
        border-radius: 100% 0 0 0;
        width: 48px; height: 48px;
        border-right: none; border-bottom: none;
        transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    }

    body.mobile-focus-mode #mobile-fab-menu.fab-open #mobile-fab {
        right: 8px; left: auto;
        bottom: max(24px, env(safe-area-inset-bottom));
        border-radius: 50%;
        width: 56px; height: 56px;
        border: 1px solid var(--ui-border);
        transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    }

    /* 8. Landscape Mode Swap */
    @media (orientation: landscape) {
        .action-group-horizontal {
            bottom: max(24px, env(safe-area-inset-bottom));
            right: 17px;
            flex-direction: column-reverse;
            align-items: center;
            padding: 2px 2px 56px 2px;
            border-radius: 12px 12px 28px 28px;
            transform: translateY(calc(20px - var(--kb-offset, 0px))) scale(0.9);
            transform-origin: center calc(100% - 28px);
        }
        
        .action-group-vertical {
            bottom: calc(max(24px, env(safe-area-inset-bottom)) + 9px);
            right: 8px;
            flex-direction: row-reverse;
            align-items: center;
            padding: 2px 56px 2px 2px;
            border-radius: 12px 28px 28px 12px;
            transform: translateY(calc(-1 * var(--kb-offset, 0px))) translateX(20px) scale(0.9);
            transform-origin: calc(100% - 28px) center;
        }
        
        .fab-open .action-group-horizontal {
            transform: translateY(calc(-1 * var(--kb-offset, 0px))) scale(1);
        }
        
        .fab-open .action-group-vertical {
            transform: translateY(calc(-1 * var(--kb-offset, 0px))) translateX(0) scale(1);
        }
        
        /* Swap Dividers for Landscape */
        .action-group-horizontal > *:not(:last-child)::after {
            left: 50%;
            top: -5.5px;
            transform: translateX(-50%);
            width: 16px;
            height: 1px;
        }

        .action-group-vertical > *:not(:last-child)::after {
            top: 50%;
            left: -5.5px;
            transform: translateY(-50%);
            width: 1px;
            height: 16px;
        }

        /* Dropdowns are universally centered now, no need to swap orientations! */
    }

    /* 9. Fix Sticky Hover on Touch Devices */
    @media (hover: none) {
        #mobile-fab-menu button:not(#mobile-fab):hover {
            background: transparent !important;
        }
        #mobile-fab-menu button:not(#mobile-fab):active {
            background: rgba(128, 128, 128, 0.15) !important;
        }
    }

    /* 10. Remove native tap highlight and non-keyboard focus rings from all FAB buttons */
    #mobile-fab,
    #mobile-fab-menu button {
        -webkit-tap-highlight-color: transparent !important;
    }
    
    #mobile-fab:focus:not(:focus-visible),
    #mobile-fab-menu button:focus:not(:focus-visible) {
        outline: none !important;
        box-shadow: none !important;
    }
