/* 13 — the sidebar: its tools panel, the off-canvas drawer on phones, the version line. */
.sidebar-tools {
    display: none;
    flex-direction: column;
}
.sidebar-tools.open {
    display: flex;
}
.sidebar-tools-toggle .sidebar-tools-chev {
    margin-inline-start: auto;
    transition: transform var(--mo-base) var(--ease-out);
    font-size: 0.7rem;
}
.sidebar-tools-toggle.open .sidebar-tools-chev {
    transform: rotate(180deg);
}

/* ============================================= */

@media (max-width: 768px) {
    /* Sidebar mobile: zero outer padding so header is full-width edge-to-edge */
    .sidebar {
        padding: 0 !important;
    }
    #mobile-drawer .bottom-actions {
        padding: 0 14px 14px !important;
    }
}

/* ============================================= */
@media (max-width: 768px) {
    /* Sidebar takes the FULL screen — bottom nav floats on top of it */
    .sidebar {
        width: 100vw !important;
        inset-inline-start: 0 !important; /* closed = translated off-screen (03-archive-view-2.css) */
        max-width: none !important;
        height: 100vh !important;
        height: 100dvh !important;
        background: var(--c-surface-2) !important;
        border: none !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 0 !important;
        display: block !important; 
    }
    .sidebar.open { inset-inline-start: 0 !important; }

    /* Make sure the sidebar itself still scrolls and absorbs touch */
    #mobile-drawer.open {
        touch-action: pan-y !important;
        overscroll-behavior: contain !important;
    }
    /* Reserve generous space at the bottom of the scrollable content so the last items
       (sign-out / extra-tools) can scroll up and clear the floating bottom nav.
       The bottom nav is ~60px + safe-area; we add ~80px extra so users can scroll
       comfortably past it instead of having items glued behind the nav. */
    #mobile-drawer .bottom-actions {
        padding-bottom: calc(140px + env(safe-area-inset-bottom, 0px)) !important;
    }
    /* Force the sidebar's intrinsic content to exceed viewport so the scroll always works,
       even when the menu list is short. The trailing pad creates "scroll room" past the nav. */
    #mobile-drawer::after {
        content: '';
        display: block;
        height: calc(80px + env(safe-area-inset-bottom, 0px));
        flex-shrink: 0;
    }
    /* Small version label at the natural end of the scrollable sidebar content.
       NOT sticky — that caused it to overlap menu items when scrolling.
       Lives OUTSIDE .bottom-actions (which is display:none on mobile).
       Bottom padding clears the floating bottom nav (~60px) + safe-area so the
       text is visible when the user scrolls to the bottom of the menu. */
    #mobile-drawer .sidebar-version,
    .sidebar-version {
        display: block !important;
        text-align: center;
        font-size: 0.7rem;
        color: var(--text-faint);
        font-weight: 600;
        letter-spacing: 0.3px;
        opacity: 0.9;
        font-family: var(--font-ui);
        padding: 18px 0 calc(90px + env(safe-area-inset-bottom, 0px));
        background: transparent;
        position: static;
        pointer-events: none;
    }
    /* Cancel the old ghost spacer — the version's bottom padding now provides
       the scroll-past-nav room, and the spacer was creating a needless gap. */
    #mobile-drawer::after { display: none !important; }

    /* Footer area background */
    .sidebar .bottom-actions {
        background: var(--c-bg) !important;
        margin-top: auto;
    }
}

/* Desktop sidebar: the same groups as a plain list with small headers */

