/* =========================================================
   Tools shell integration with the global app navigation
   2026-09-06

   The global app sidebar is the only persistent sidebar.
   The native tools list is a temporary picker/drawer on all viewports.
   ========================================================= */

body.tools-page .native-tools-page {
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: minmax(0, 1fr) !important;
    position: relative !important;
}

body.tools-page .native-tools-main {
    grid-column: 1 / -1 !important;
    grid-row: 1 !important;
    width: 100% !important;
    min-width: 0 !important;
}

body.tools-page .native-tools-sidebar {
    position: fixed !important;
    top: calc(var(--global-nav-height, 58px) + 14px) !important;
    right: 14px !important;
    bottom: calc(var(--log-height, 0px) + 14px) !important;
    left: auto !important;
    z-index: 420920 !important;
    display: grid !important;
    grid-template-rows: auto auto minmax(0, 1fr) !important;
    width: min(390px, calc(100vw - 28px)) !important;
    min-width: 0 !important;
    max-width: 390px !important;
    height: auto !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 14px !important;
    overflow: hidden !important;
    border: 1px solid var(--tools-border) !important;
    border-radius: 16px !important;
    background: color-mix(in srgb, var(--tools-card) 97%, transparent) !important;
    box-shadow: 0 22px 70px rgba(0, 0, 0, .42) !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transform: translateX(calc(100% + 28px)) !important;
    transition: transform .22s cubic-bezier(.22,.61,.36,1), opacity .18s ease, visibility .18s ease !important;
    touch-action: pan-y !important;
}

body.light-mode.tools-page .native-tools-sidebar,
html.light-mode body.tools-page .native-tools-sidebar {
    background: rgba(248, 248, 248, .98) !important;
}

body.tools-page.tools-native-sidebar-open .native-tools-sidebar,
html.tools-native-sidebar-open body.tools-page .native-tools-sidebar,
body.tools-page .native-tools-page.tools-native-sidebar-open .native-tools-sidebar {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: translateX(0) !important;
}

body.tools-page .native-tools-brand {
    grid-template-columns: auto minmax(0, 1fr) auto !important;
}

body.tools-page .native-tools-brand-copy {
    min-width: 0 !important;
}

body.tools-page .native-tools-picker-close {
    display: grid !important;
    place-items: center !important;
    flex: 0 0 38px !important;
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    min-height: 38px !important;
    margin-left: auto !important;
    padding: 0 !important;
    color: var(--tools-text) !important;
    border: 1px solid var(--tools-border) !important;
    border-radius: 10px !important;
    background: rgba(255, 255, 255, .06) !important;
    box-shadow: none !important;
    font: inherit !important;
    font-size: 1.5rem !important;
    line-height: 1 !important;
    cursor: pointer !important;
}

body.light-mode.tools-page .native-tools-picker-close,
html.light-mode body.tools-page .native-tools-picker-close {
    background: rgba(0, 0, 0, .04) !important;
}

body.tools-page .native-tools-nav {
    min-height: 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    touch-action: pan-y !important;
}

body.tools-page .native-tools-picker-backdrop {
    position: fixed !important;
    inset: var(--global-nav-height, 58px) 0 0 0 !important;
    z-index: 420910 !important;
    display: block !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: rgba(0, 0, 0, .46) !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transition: opacity .18s ease, visibility .18s ease !important;
    touch-action: manipulation !important;
}

body.tools-page.tools-native-sidebar-open .native-tools-picker-backdrop,
html.tools-native-sidebar-open body.tools-page .native-tools-picker-backdrop,
body.tools-page .native-tools-page.tools-native-sidebar-open .native-tools-picker-backdrop {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

body.tools-page .native-tools-picker-toggle {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    white-space: nowrap !important;
}

body.tools-page .native-tools-picker-toggle-icon {
    font-size: 1rem;
    line-height: 1;
}

/* The old tools-specific fixed mobile action bar would create a second app-level
   bottom bar next to the new global navigation. All actions remain available
   in the normal tools header; therefore the legacy bar is deliberately disabled. */
html body.tools-page #native-tools-mobile-shell,
html body.tools-page .native-tools-mobile-shell {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

body.tools-page .native-tools-main {
    padding-bottom: 18px !important;
}

@media (max-width: 760px) {
    body.tools-page #content.app-content {
        height: 100% !important;
        max-height: 100% !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }

    body.tools-page #content-area {
        height: 100% !important;
        max-height: 100% !important;
        min-height: 0 !important;
        overflow: hidden !important;
        padding-bottom: 0 !important;
    }

    body.tools-page .native-tools-page {
        width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }

    body.tools-page .native-tools-main {
        width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        min-height: 0 !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior-y: contain !important;
        touch-action: pan-y !important;
        padding: 8px 8px calc(var(--app-mobile-nav-height, 70px) + 18px + env(safe-area-inset-bottom, 0px)) !important;
    }

    body.tools-page .native-tools-sidebar {
        top: calc(var(--global-nav-height, 58px) + 8px) !important;
        right: 8px !important;
        bottom: calc(var(--app-mobile-nav-height, 70px) + env(safe-area-inset-bottom, 0px) + 8px) !important;
        width: min(92vw, 360px) !important;
        max-width: min(92vw, 360px) !important;
        padding: 12px !important;
        border-radius: 16px !important;
    }

    body.tools-page .native-tools-picker-backdrop {
        inset: var(--global-nav-height, 58px) 0 calc(var(--app-mobile-nav-height, 70px) + env(safe-area-inset-bottom, 0px)) 0 !important;
    }

    body.tools-page .native-tools-header {
        gap: 10px !important;
    }

    body.tools-page .native-tools-header-controls {
        width: 100% !important;
    }

    body.tools-page .native-tools-picker-toggle {
        min-height: 44px !important;
    }
}

@media (max-width: 460px) {
    body.tools-page .native-tools-sidebar {
        right: 6px !important;
        width: calc(100vw - 12px) !important;
        max-width: calc(100vw - 12px) !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    body.tools-page .native-tools-sidebar,
    body.tools-page .native-tools-picker-backdrop {
        transition: none !important;
    }
}
