:root {
    --read-shell-bottom-clearance: calc(var(--mobile-bottom-nav-height) + env(safe-area-inset-bottom, 0px) + 80px);
    --reader-controls-offset: calc(72px + env(safe-area-inset-bottom, 0px) - 8px);
}

body.tab-read-active {
    --mobile-bottom-clearance: var(--read-shell-bottom-clearance);
}

.amp-narrator-status {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    opacity: 0.9;
}

.amp-narrator-status.narrating {
    color: var(--accent-dark);
}

@media (max-width: 900px) {
    body.tab-read-active #tabRead .sidebar-content {
        padding-bottom: var(--read-shell-bottom-clearance) !important;
        scroll-padding-bottom: var(--read-shell-bottom-clearance) !important;
    }

    body.tab-read-active #tabRead .one-year-sidebar {
        padding-bottom: var(--read-shell-bottom-clearance) !important;
        scroll-padding-bottom: var(--read-shell-bottom-clearance) !important;
    }

    body.tab-read-active #sidebarContent > #canonicalBooks,
    body.tab-read-active #sidebarContent > #chronoBooks,
    body.tab-read-active #sidebarContent > #azBooks,
    body.tab-read-active #sidebarContent > #drillPanel {
        padding-bottom: calc(var(--read-shell-bottom-clearance) + 24px) !important;
    }

    /* Sidebar-about (copyright/disclaimer) is irrelevant in chapter drill mode */
    body.tab-read-active #tabRead .sidebar-content.drilled-in .sidebar-about {
        display: none !important;
    }

    /* Grid default has 132px bottom padding; reduce to just spacing */
    body.tab-read-active #tabRead .drill-chapter-grid {
        padding: 16px 20px 24px !important;
    }

    body.reader-open #tabRead .reader {
        padding: 28px 20px calc(var(--read-shell-bottom-clearance) + 44px) !important;
    }

    body.reader-open .autoscroll-bar {
        left: 14px !important;
        right: 14px !important;
        bottom: var(--reader-controls-offset) !important;
        justify-content: center;
        gap: 8px !important;
        padding: 10px 12px !important;
    }

    body.reader-open .font-size-ctrl {
        flex: 0 0 auto;
    }

    body.reader-open .scroll-play,
    body.reader-open .narrator-btn {
        width: 42px !important;
        height: 42px !important;
        min-width: 42px !important;
    }

    body.reader-open .speed-buttons {
        flex: 1 1 auto;
        min-width: 0;
    }
}


@media (max-width: 900px) {
    body.tab-read-active .ios-tab-wrapper {
        overflow-y: hidden !important;
        height: 100dvh !important;
    }

    body.tab-read-active #tabRead {
        height: calc(100dvh - var(--mobile-bottom-clearance)) !important;
        min-height: calc(100dvh - var(--mobile-bottom-clearance)) !important;
        overflow: hidden !important;
        padding-bottom: 0 !important;
    }

    body.tab-read-active #tabRead #sidebar {
        position: relative !important;
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }

    body.tab-read-active #tabRead #sidebarContent {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        height: auto !important;
        max-height: none !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    body.tab-read-active #tabRead .sidebar-footer {
        flex: 0 0 auto !important;
    }
}


@media (max-width: 900px) {
    body.tab-read-active.mode-condensed #tabRead .sidebar-footer,
    body.tab-read-active.mode-condensed #tabRead .sidebar-about {
        display: none !important;
    }
}


@media (max-width: 900px) {
    body.tab-read-active #tabRead .sidebar-header {
        padding: calc(env(safe-area-inset-top, 0px) + 24px) 18px 12px !important;
        border-bottom: 0 !important;
    }

    body.tab-read-active #tabRead .sidebar-search {
        padding: 4px 12px 2px !important;
    }

    body.tab-read-active #tabRead .sidebar-top-controls {
        margin-top: 8px !important;
    }

    body.tab-read-active #tabRead .header-mode-toggle,
    body.tab-read-active #tabRead .mode-pill-toggle {
        margin: 8px auto 10px auto !important;
    }

    body.tab-read-active #tabRead .view-toggle {
        margin: 0 12px 8px !important;
    }

    body.tab-read-active #tabRead .view-description {
        margin: 0 16px 4px !important;
        min-height: 0 !important;
    }

    body.tab-read-active #tabRead #sidebarContent {
        padding-top: 0 !important;
    }
}


@media (max-width: 900px) {
    body.tab-read-active.mode-condensed #tabRead .view-description {
        display: block !important;
        min-height: 18px !important;
        height: auto !important;
        margin: 0 16px 6px !important;
        font-size: 0.68rem !important;
        line-height: 1.35 !important;
        letter-spacing: 0.01em !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        opacity: 0.82 !important;
    }
}
