@media (min-width: 901px) {
    /* Pane state is restored before the desktop shell is built. Keep pane
       visibility changes instant so a saved closed pane cannot animate from
       its default onscreen position during a new chapter load. */
    .desktop-sidebar {
        transition: none !important;
    }

    .desktop-pane-reopen {
        position: fixed;
        z-index: 4200;
        padding: 0;
        border: 1px solid var(--reader-border);
        background: var(--reader-surface);
        color: var(--reader-text);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
    }

    .desktop-pane-reopen:hover,
    .desktop-pane-reopen:focus-visible {
        background: var(--reader-hover);
        border-color: var(--reader-accent, var(--reader-border));
        outline: none;
    }

    /* Keep the original Back button in the main header layout at all times so
       the chapter/version stays centered. It is visible only when Books is
       closed; while Books is open the pane has its own Back control. */
    body.desktop-workspace-enabled .phase1-back-button {
        position: relative !important;
        left: auto !important;
        right: auto !important;
        margin: 0 !important;
        transform: none !important;
        z-index: 4300 !important;
    }

    body.desktop-workspace-enabled:not(.desktop-books-pane-closed) .phase1-back-button {
        visibility: hidden !important;
        pointer-events: none !important;
    }

    body.desktop-workspace-enabled.desktop-books-pane-closed .phase1-back-button {
        visibility: visible !important;
        pointer-events: auto !important;
    }

    /* Books-open header: Back -> centered Books title -> Close. */
    .desktop-books-pane .desktop-pane-header {
        display: grid;
        grid-template-columns: 40px minmax(0, 1fr) 40px;
        align-items: center;
        gap: 4px;
        padding: 0 10px;
    }

    .desktop-books-pane .desktop-pane-header > strong {
        text-align: center;
    }

    .desktop-books-title-link {
        justify-self: center;
        padding: 6px 10px;
        border-radius: 7px;
        cursor: pointer;
        user-select: none;
    }

    .desktop-books-title-link:hover,
    .desktop-books-title-link:focus-visible {
        background: var(--reader-hover);
        outline: none;
    }

    #desktop-books-pane-back {
        width: 40px;
        height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        border: 0;
        border-radius: 7px;
        background: transparent;
        color: var(--reader-text);
        font: inherit;
        font-size: 21px;
        cursor: pointer;
    }

    #desktop-books-pane-back:hover,
    #desktop-books-pane-back:focus-visible {
        background: var(--reader-hover);
        outline: none;
    }

    /* When Books is closed, its reopen icon occupies the next header slot
       immediately to the right of the main Back button. */
    #desktop-books-pane-reopen {
        top: calc(var(--desktop-menu-height, 38px) + ((var(--desktop-header-height, 58px) - 40px) / 2));
        left: 52px;
        width: 40px;
        height: 40px;
        border: 0;
        border-radius: 7px;
        background: transparent;
        box-shadow: none;
        font-size: 21px;
    }

    /* Study keeps its separate upper-edge reopen tab, away from chapter nav. */
    #desktop-study-pane-reopen {
        top: calc(var(--desktop-menu-height, 38px) + var(--desktop-header-height, 58px) + 72px);
        right: 0;
        width: 34px;
        height: 48px;
        border-right: 0;
        border-radius: 10px 0 0 10px;
        box-shadow: 0 4px 14px rgba(0, 0, 0, .16);
    }

    .desktop-pane-reopen[hidden] {
        display: none !important;
    }
}

@media (max-width: 900px) {
    .desktop-pane-reopen,
    #desktop-books-pane-back {
        display: none !important;
    }
}
