/* Floating Reader menu: the chapter actions live here instead of the header row. */
.reader-header-inner--menu {
    grid-template-columns: auto minmax(0, 1fr) auto;
}

.reader-header-inner--menu .reader-header-actions {
    grid-column: 1;
}

.reader-header-inner--menu .reader-title {
    grid-column: 2;
}

.reader-header-inner--menu .reader-brand {
    grid-column: 3;
}

.reader-menu-toggle {
    position: fixed;
    top: auto;
    right: auto;
    bottom: calc(70px + env(safe-area-inset-bottom, 0px));
    left: 16px;
    z-index: 120;
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    padding: 0;
    border: 1px solid rgba(169, 81, 232, .38);
    border-radius: 50%;
    background: rgba(15, 17, 25, .92);
    box-shadow: 0 10px 28px rgba(0, 0, 0, .38), inset 0 1px 0 rgba(255, 255, 255, .06);
    color: #e8d8f7;
    font: inherit;
    font-size: 17px;
    cursor: pointer;
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    transition: background .2s ease, border-color .2s ease, color .2s ease, transform .2s ease;
}

.reader-menu-toggle:hover,
.reader-menu-toggle.is-open {
    border-color: rgba(190, 143, 240, .72);
    background: rgba(39, 24, 54, .96);
    color: #fff;
}

.reader-menu-toggle:active {
    transform: scale(.96);
}

.reader-menu-toggle:focus-visible {
    outline: 2px solid #c58af7;
    outline-offset: 3px;
}

.reader-action-menu {
    position: fixed;
    top: auto;
    right: auto;
    bottom: calc(70px + 40px + 12px + env(safe-area-inset-bottom, 0px));
    left: 16px;
    z-index: 119;
    display: flex;
    width: min(300px, calc(100vw - 32px));
    max-height: calc(100vh - 132px - env(safe-area-inset-bottom, 0px));
    flex-direction: column;
    gap: 6px;
    overflow: auto;
    overscroll-behavior: contain;
    padding: 10px;
    border: 1px solid rgba(169, 81, 232, .28);
    border-radius: 15px;
    background: rgba(12, 15, 22, .97);
    box-shadow: 0 20px 55px rgba(0, 0, 0, .58), inset 0 1px 0 rgba(255, 255, 255, .045);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(7px) scale(.985);
    transform-origin: bottom left;
    transition: opacity .18s ease, visibility .18s ease, transform .18s ease;
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
}

.reader-action-menu.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.reader-action-menu__heading {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 36px;
    padding: 0 10px 7px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    color: #e8dcf5;
    font-size: 12px;
    font-weight: 700;
}

.reader-action-menu__heading i {
    color: #b77be7;
    font-size: 14px;
}

.reader-action-menu__divider {
    height: 1px;
    margin: 3px 5px;
    background: rgba(255, 255, 255, .075);
}

.reader-action-menu .reader-menu-item {
    display: flex;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    align-items: center;
    justify-content: flex-start;
    gap: 11px;
    padding: 0 12px;
    border: 1px solid rgba(255, 255, 255, .075);
    border-radius: 10px;
    background: rgba(255, 255, 255, .025);
    color: #e3e3e9;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
    text-align: right;
    text-decoration: none;
    cursor: pointer;
    transition: border-color .18s ease, background .18s ease, color .18s ease, transform .18s ease;
}

.reader-action-menu .reader-menu-item:hover,
.reader-action-menu .reader-menu-item:focus-visible {
    border-color: rgba(169, 81, 232, .48);
    background: rgba(169, 81, 232, .12);
    color: #fff;
}

.reader-action-menu .reader-menu-item:active {
    transform: scale(.985);
}

.reader-action-menu .reader-menu-item:focus-visible {
    outline: 2px solid rgba(197, 138, 247, .72);
    outline-offset: 2px;
}

.reader-action-menu .reader-menu-item i {
    display: inline-flex;
    flex: 0 0 18px;
    align-items: center;
    justify-content: center;
    color: #b77be7;
    font-size: 14px;
}

.reader-action-menu .reader-menu-item.reader-report-button i {
    color: #e58371;
}

.reader-action-menu .reader-menu-item span:not(.reader-plus-badge) {
    display: inline;
}

.reader-action-menu .reader-menu-item .reader-plus-badge {
    position: static;
    flex: 0 0 auto;
    height: 18px;
    margin-inline-start: auto;
    margin-inline-end: 0;
    padding: 0 7px;
}

@media (max-width: 700px) {
    .reader-header-inner--menu {
        width: calc(100% - 20px);
        grid-template-columns: auto minmax(0, 1fr) 36px;
        gap: 7px;
    }

    .reader-action-menu .reader-menu-item--desktop-only {
        display: none;
    }

    .reader-menu-toggle {
        top: auto;
        right: auto;
        bottom: calc(56px + env(safe-area-inset-bottom, 0px));
        left: 8px;
        width: 34px;
        height: 34px;
        border-radius: 50%;
    }

    .reader-action-menu {
        top: auto;
        right: auto;
        bottom: calc(56px + 34px + 10px + env(safe-area-inset-bottom, 0px));
        left: 8px;
        width: min(300px, calc(100vw - 16px));
        max-height: calc(100dvh - 110px - env(safe-area-inset-bottom, 0px));
    }
}

@media (hover: none) and (pointer: coarse) {
    .reader-action-menu .reader-menu-item--desktop-only {
        display: none;
    }
}

/* Compact settings panel opened from the Reader menu. */
#readerControls.reader-controls {
    width: min(620px, calc(100vw - 32px));
    max-height: min(66vh, 500px);
    padding: 12px 16px;
}

#readerControls .reader-reading-mode-control,
#readerControls .reader-auto-control,
#readerControls .reader-night-control {
    gap: 10px;
    margin-top: 12px;
    padding-top: 12px;
}

#readerControls .reader-mode-group {
    gap: 7px;
}

@media (max-width: 700px), (hover: none) and (pointer: coarse) {
    #readerControls.reader-controls {
        width: min(340px, calc(100vw - 24px));
        max-height: min(48vh, 360px);
        max-height: min(48dvh, 360px);
        padding: 10px 12px;
    }

    #readerControls .reader-width-control {
        display: none;
    }

    #readerControls .reader-reading-mode-control,
    #readerControls .reader-auto-control,
    #readerControls .reader-night-control {
        gap: 9px;
        margin-top: 10px;
        padding-top: 10px;
    }

    #readerControls .reader-mode-options {
        gap: 6px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .reader-menu-toggle,
    .reader-action-menu,
    .reader-action-menu .reader-menu-item {
        transition: none;
    }
}
