/* The tablet toolbar wraps its right-hand controls to a second 40px row. */
@media (min-width: 761px) and (max-width: 920px) {
    body.ec-reader-body .ec-reader {
        --reader-bar: 82px !important;
    }
    body.ec-reader-body .ec-reader-toolbar {
        height: var(--reader-bar) !important;
        grid-template-rows: 40px 40px !important;
    }
}
/* Dock learning panels without covering the lesson. Fixed toolbar/footer retain their reserved rows. */
body.ec-reader-body .ec-reader.has-reader-side-panel {
    --reader-side-panel-width: clamp(280px, 32vw, 420px);
    display: grid !important;
    grid-template-columns: var(--reader-side-panel-width) minmax(0, 1fr);
    grid-template-rows: var(--reader-bar) minmax(0, 1fr) var(--reader-bottom);
}
body.ec-reader-body .ec-reader.has-reader-side-panel > .ec-reader-content {
    grid-column: 2;
    grid-row: 2;
    position: relative !important;
    inset: auto !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: 100% !important;
    margin: 0 !important;
    padding: 24px clamp(20px, 4vw, 64px) 40px !important;
    overflow: auto !important;
    overscroll-behavior: contain;
}
body.ec-reader-body .ec-reader.has-reader-side-panel:has(.ec-reader-buy) > .ec-reader-content {
    padding-top: 76px !important;
}
body.ec-reader-body .ec-reader.has-reader-side-panel > [data-lesson-panel="notes"].is-open,
body.ec-reader-body .ec-reader.has-reader-side-panel > [data-lesson-panel="forum"].is-open,
body.ec-reader-body .ec-reader.has-reader-side-panel > [data-lesson-panel="curriculum"].is-open {
    grid-column: 1;
    grid-row: 2;
    position: relative !important;
    inset: auto !important;
    transform: none !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: 100% !important;
    margin: 0 !important;
    border-right: 1px solid #c7d8df;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow: auto !important;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}
body.ec-reader-body .ec-reader.has-reader-side-panel > [data-lesson-panel="curriculum"].is-open .ec-reader-curriculum__head {
    position: sticky;
    top: 0;
    z-index: 1;
}
body.ec-reader-body .ec-reader.has-reader-side-panel > [data-lesson-panel="notes"].is-open,
body.ec-reader-body .ec-reader.has-reader-side-panel > [data-lesson-panel="forum"].is-open {
    display: flex !important;
    flex-direction: column;
    overflow: hidden !important;
}
body.ec-reader-body .ec-reader.has-reader-side-panel > [data-lesson-panel].is-open > [data-annotation-panel] {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}
body.ec-reader-body .ec-reader.has-reader-side-panel > [data-lesson-panel].is-open > .ec-reader-panel-actions {
    display: flex;
    flex: 0 0 auto;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 10px;
    padding-top: 9px;
    border-top: 1px solid #cadbe1;
}
body.ec-reader-body .ec-reader.has-reader-side-panel .ec-reader-panel-actions > button {
    min-height: 36px;
    height: 36px;
    padding: 6px 12px;
    border-radius: 6px;
    font: 700 12px/1.3 Arial, Helvetica, sans-serif;
}
body.ec-reader-body .ec-reader.has-reader-side-panel > .ec-reader-content :is(img, video, canvas) {
    max-width: 100% !important;
    height: auto !important;
}
body.ec-reader-body .ec-reader.has-reader-side-panel > .ec-reader-content :is(iframe, audio, .ec-lesson-file, .ec-lesson-file__viewport) {
    max-width: 100% !important;
    min-width: 0 !important;
}
body.ec-reader-body .ec-reader.has-reader-side-panel > .ec-reader-content iframe {
    width: 100% !important;
}
body.ec-reader-body .ec-reader.has-reader-side-panel .ec-reader-content__body :is(table, pre) {
    display: block;
    max-width: 100%;
    min-width: 0 !important;
    overflow: auto;
}
body.ec-reader-body .ec-reader.is-dark.has-reader-side-panel > [data-lesson-panel].is-open {
    border-color: #3b5864;
}
body.ec-reader-body .ec-reader .ec-reader-other-courses {
    top: calc(var(--reader-bar) + 8px) !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    width: min(520px, calc(100vw - 32px)) !important;
    min-height: 0 !important;
    max-height: calc(100dvh - var(--reader-bar) - var(--reader-bottom) - 16px) !important;
    margin: 0;
    padding: 20px !important;
    border: 1px solid #cbdbe3;
    border-radius: 12px;
    background: #fff !important;
    color: #223a50;
    overflow: auto !important;
    overscroll-behavior: contain;
    font: 400 14px/1.5 Arial, Helvetica, sans-serif;
}
body.ec-reader-body .ec-reader .ec-reader-other-courses h2 {
    margin: 0 0 14px;
    font: 700 18px/1.4 Arial, Helvetica, sans-serif;
}
.ec-reader-other-courses__list { display: grid; gap: 8px; min-width: 0; margin: 0; padding: 0; list-style: none; }
.ec-reader-other-courses__list > li { margin: 0; padding: 0; }
body.ec-reader-body .ec-reader .ec-reader-other-courses__list > li > a {
    display: grid;
    gap: 4px;
    min-height: 50px;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid #d5e1e8;
    border-radius: 8px;
    background: #f8fbfd;
    color: #233f57;
    text-decoration: none;
    overflow-wrap: anywhere;
    text-shadow: none;
}
body.ec-reader-body .ec-reader .ec-reader-other-courses__list > li > a::before,
body.ec-reader-body .ec-reader a.ec-reader-other-courses__footer::before { display: none; }
.ec-reader-other-courses__list > li > a:hover { border-color: #8abfb6 !important; background: #eef8f4 !important; }
.ec-reader-other-courses__list strong { font: 700 14px/1.4 Arial, Helvetica, sans-serif; }
.ec-reader-other-courses__list small { color: #647b90; font: 400 12px/1.4 Arial, Helvetica, sans-serif; }
.ec-reader-other-courses__footer { margin-top: 14px; padding-top: 12px; border-top: 1px solid #d4e0e7; }
body.ec-reader-body .ec-reader a.ec-reader-other-courses__footer { display: flex; align-items: center; min-height: 44px; margin: 14px 0 0; padding: 12px 0 0; color: #11756c; text-shadow: none; font: 700 13px/1.4 Arial, Helvetica, sans-serif; }
.ec-reader-other-courses__empty { margin: 0; padding: 12px; border: 1px solid #d9e3e9; border-radius: 8px; background: #f7fafc; color: #62778b; font: 400 13px/1.5 Arial, Helvetica, sans-serif; }
body.ec-reader-body .ec-reader.is-dark .ec-reader-other-courses { border-color: #3d5c68; background: #19333e !important; color: #dce9ef; }
body.ec-reader-body .ec-reader.is-dark .ec-reader-other-courses__list > li > a { border-color: #44616c; background: #213f4a; color: #dfedf2; }
body.ec-reader-body .ec-reader.is-dark .ec-reader-other-courses__list small { color: #bad0dc; }
body.ec-reader-body .ec-reader.is-dark a.ec-reader-other-courses__footer { color: #8bd6c4; }
body.ec-reader-body .ec-reader.is-dark .ec-reader-other-courses__empty { border-color: #45636e; background: #233d47; color: #bfd2dd; }
@media (max-width: 900px) {
    body.ec-reader-body .ec-reader.has-reader-side-panel {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: var(--reader-bar) minmax(0, 1.1fr) minmax(0, 1fr) var(--reader-bottom);
    }
    body.ec-reader-body .ec-reader.has-reader-side-panel > .ec-reader-content {
        grid-column: 1;
        grid-row: 2;
        padding: 18px 20px 26px !important;
    }
    body.ec-reader-body .ec-reader.has-reader-side-panel > [data-lesson-panel="notes"].is-open,
    body.ec-reader-body .ec-reader.has-reader-side-panel > [data-lesson-panel="forum"].is-open,
    body.ec-reader-body .ec-reader.has-reader-side-panel > [data-lesson-panel="curriculum"].is-open {
        grid-column: 1;
        grid-row: 3;
        padding: 16px 18px !important;
        border-top: 1px solid #b9d1d8;
        border-right: 0;
    }
    body.ec-reader-body .ec-reader.has-reader-side-panel > [data-lesson-panel="notes"].is-open > :is(.ec-reader-breadcrumb, p, hr),
    body.ec-reader-body .ec-reader.has-reader-side-panel > [data-lesson-panel="forum"].is-open > :is(.ec-reader-breadcrumb, p, hr) {
        display: none;
    }
    body.ec-reader-body .ec-reader.has-reader-side-panel .ec-reader-panel-actions > button {
        min-height: 44px;
        height: 44px;
        padding: 8px 14px;
    }
    body.ec-reader-body .ec-reader .ec-reader-other-courses {
        width: calc(100vw - 24px) !important;
        padding: 16px !important;
    }
}
/* Short landscape screens need the full reading height for both panes. */
@media (min-width: 600px) and (max-width: 900px) and (max-height: 500px) {
    body.ec-reader-body .ec-reader.has-reader-side-panel {
        --reader-side-panel-width: clamp(240px, 32vw, 320px);
        grid-template-columns: var(--reader-side-panel-width) minmax(0, 1fr);
        grid-template-rows: var(--reader-bar) minmax(0, 1fr) var(--reader-bottom);
    }
    body.ec-reader-body .ec-reader.has-reader-side-panel > .ec-reader-content {
        grid-column: 2;
        grid-row: 2;
    }
    body.ec-reader-body .ec-reader.has-reader-side-panel > [data-lesson-panel="notes"].is-open,
    body.ec-reader-body .ec-reader.has-reader-side-panel > [data-lesson-panel="forum"].is-open,
    body.ec-reader-body .ec-reader.has-reader-side-panel > [data-lesson-panel="curriculum"].is-open {
        grid-column: 1;
        grid-row: 2;
        border-top: 0;
        border-right: 1px solid #b9d1d8;
    }
}
