.ek-right-panel__resize {
    position: absolute;
    /* Place the guide over the panel's 1px border, not beside it. */
    inset: 0 auto 0 -1px;
    z-index: 6;
    width: 8px;
    cursor: ew-resize;
    touch-action: none;
    background: transparent;
}

/* The legacy Fish/Slides slide-out transform must not enlarge the page's scroll area. */
#fish-main-container.right-sidebar-collapsed {
    overflow-x: clip;
}

/* In drawer mode the canvas can become narrower than its empty-state text.
   Clip that underlying content at the workspace edge instead of letting it
   print one letter per line across the WBS boundary. */
.fish-main-container:has(.right-sidebar.ek-right-panel--drawer) {
    overflow-x: clip;
}

.ek-right-panel__resize::before {
    position: absolute;
    inset: 0 auto 0 0;
    width: 1px;
    background: transparent;
    content: '';
}

/* Word and PDF keep their resize target on the same pixel as the panel edge. */
.editor-sidebar.ek-right-panel {
    border-left: 1px solid var(--border-primary);
}

.ek-right-panel__resize:hover::before,
.ek-right-panel__resize:focus-visible::before,
.ek-right-panel--resizing .ek-right-panel__resize::before {
    width: 1px;
    background: var(--text-tertiary);
}

/* Recolor the existing panel border on interaction without drawing another
   full-height line inside its resize target. */
.editor-sidebar.ek-right-panel > .ek-right-panel__resize::before {
    background: transparent;
}

/* Bordered panels recolor their existing edge instead of painting beside it. */
.ek-right-panel:has(> .ek-right-panel__resize:hover),
.ek-right-panel:has(> .ek-right-panel__resize:focus-visible),
.ek-right-panel--resizing {
    border-left-color: var(--text-tertiary);
}

.ek-right-panel__resize:focus-visible {
    outline: none;
}

/* Available workspace width, not only viewport width, can force drawer mode
   when the WBS and communication dock are both open. */
.right-sidebar.ek-right-panel--drawer {
    width: 100%;
}

/* Word and PDF use the same width-based drawer state. Above 768px their legacy
   media rules no longer position the page list over the canvas, even when the
   communication dock has reduced the editor to a narrow workspace. */
.editor-main:has(> .editor-sidebar.ek-right-panel--drawer) {
    position: relative;
}

.editor-sidebar.ek-right-panel--drawer {
    position: absolute;
    inset: 0 0 0 auto;
    width: 100%;
    height: auto;
    z-index: 100;
}

.ek-right-panel--drawer > .ek-right-panel__resize {
    display: none;
}

.ek-right-panel__toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-lg);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    box-shadow: none;
}

.ek-right-panel__toggle[hidden] {
    display: none;
}

.ek-right-panel__toggle:hover,
.ek-right-panel__toggle.active {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.ek-right-panel__toggle:focus-visible {
    outline: 1px solid var(--border-hover);
    outline-offset: -1px;
    box-shadow: none;
}

.ek-right-panel__toggle svg {
    display: block;
    width: 20px;
    height: 20px;
    flex: none;
}

.fish-toolbar > .ek-right-panel__toggle {
    position: sticky;
    top: auto;
    right: 0;
    z-index: 1;
    margin-left: auto;
    transform: none !important;
    transition:
        background-color var(--transition-fast),
        color var(--transition-fast);
}

.ek-right-panel__split-host,
body > .fish-toolbar.ek-right-panel__split-host {
    overflow: hidden;
}

.ek-right-panel__commands {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    gap: inherit;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.ek-right-panel__commands::-webkit-scrollbar {
    display: none;
}

.fish-toolbar.ek-right-panel__split-host > .ek-right-panel__toggle {
    position: static;
    z-index: auto;
    margin-left: 0;
}

.im-topbar > .ek-right-panel__toggle {
    position: static;
    z-index: 4;
    flex: 0 0 34px;
    margin-left: 0;
    background: var(--bg-primary);
}

@media (width <= 768px) {
    .ek-right-panel__resize {
        display: none;
    }

    .editor-sidebar.ek-right-panel {
        width: 100%;
    }

    .right-sidebar.ek-right-panel {
        width: 100%;
    }
}
