/**
 * Easy Padhai responsive safety layer.
 *
 * Loaded after every feature stylesheet. All rules are restricted to plugin
 * surfaces so the active WordPress theme and unrelated pages remain untouched.
 */

:where(
    .ai-study-app,
    .ai-study-dashboard,
    .ai-study-auth-shell,
    .ai-study-teacher-dashboard,
    .ai-study-voice-pro,
    .ai-study-ncert-library,
    .ai-prep-panel,
    .ai-live-avatar-tutor,
    .ai-live-avatar-shell,
    .ep-seo-feature-page,
    .ep-course-app,
    .ep-course-directory,
    .ep-course-experience,
    .ep-course-showcase,
    .ep-home-course-showcase,
    .ep-quiz-player,
    .ep-parent-access,
    .ep-parent-portal,
    .ep-kids-world,
    .ep-touch-learn,
    .ep-avatar-app,
    .ep-math-teacher,
    .ep-sp-wrap,
    .ep-smart-filter-shell,
    .ep-mobile-answer-viewer
) {
    max-width: 100%;
    min-width: 0;
}

:where(
    .ai-study-app,
    .ai-study-dashboard,
    .ai-study-auth-shell,
    .ai-study-teacher-dashboard,
    .ai-study-voice-pro,
    .ai-study-ncert-library,
    .ai-prep-panel,
    .ai-live-avatar-tutor,
    .ep-seo-feature-page,
    .ep-course-app,
    .ep-course-directory,
    .ep-course-experience,
    .ep-course-showcase,
    .ep-home-course-showcase,
    .ep-quiz-player,
    .ep-parent-access,
    .ep-parent-portal,
    .ep-kids-world,
    .ep-touch-learn,
    .ep-avatar-app,
    .ep-math-teacher,
    .ep-sp-wrap,
    .ep-smart-filter-shell,
    .ep-mobile-answer-viewer,
    .ep-magic-modal,
    .ep-kids-player,
    .ep-kids-modal,
    .ai-fs-scanner
),
:where(
    .ai-study-app,
    .ai-study-dashboard,
    .ai-study-auth-shell,
    .ai-study-teacher-dashboard,
    .ai-study-voice-pro,
    .ai-study-ncert-library,
    .ai-prep-panel,
    .ai-live-avatar-tutor,
    .ep-seo-feature-page,
    .ep-course-app,
    .ep-course-directory,
    .ep-course-experience,
    .ep-course-showcase,
    .ep-home-course-showcase,
    .ep-quiz-player,
    .ep-parent-access,
    .ep-parent-portal,
    .ep-kids-world,
    .ep-touch-learn,
    .ep-avatar-app,
    .ep-math-teacher,
    .ep-sp-wrap,
    .ep-smart-filter-shell,
    .ep-mobile-answer-viewer,
    .ep-magic-modal,
    .ep-kids-player,
    .ep-kids-modal,
    .ai-fs-scanner
) * {
    box-sizing: border-box;
}

:where(
    .ai-study-app,
    .ai-study-dashboard,
    .ai-study-auth-shell,
    .ai-study-teacher-dashboard,
    .ai-study-voice-pro,
    .ai-study-ncert-library,
    .ai-prep-panel,
    .ai-live-avatar-tutor,
    .ep-seo-feature-page,
    .ep-course-app,
    .ep-course-directory,
    .ep-course-experience,
    .ep-course-showcase,
    .ep-home-course-showcase,
    .ep-quiz-player,
    .ep-parent-access,
    .ep-parent-portal,
    .ep-kids-world,
    .ep-touch-learn,
    .ep-avatar-app,
    .ep-math-teacher,
    .ep-sp-wrap,
    .ep-smart-filter-shell,
    .ep-mobile-answer-viewer
) :where(img, svg) {
    max-width: 100%;
    height: auto;
}

:where(
    .ai-study-app,
    .ai-study-dashboard,
    .ai-study-auth-shell,
    .ai-study-teacher-dashboard,
    .ai-study-voice-pro,
    .ai-study-ncert-library,
    .ai-prep-panel,
    .ai-live-avatar-tutor,
    .ep-seo-feature-page,
    .ep-course-app,
    .ep-course-directory,
    .ep-course-experience,
    .ep-course-showcase,
    .ep-home-course-showcase,
    .ep-quiz-player,
    .ep-parent-access,
    .ep-parent-portal,
    .ep-kids-world,
    .ep-touch-learn,
    .ep-avatar-app,
    .ep-math-teacher,
    .ep-sp-wrap,
    .ep-smart-filter-shell,
    .ep-mobile-answer-viewer
) :where(input, select, textarea) {
    max-width: 100%;
    min-width: 0;
}

:where(
    .ai-study-app,
    .ai-study-dashboard,
    .ai-study-auth-shell,
    .ai-study-teacher-dashboard,
    .ai-study-voice-pro,
    .ai-study-ncert-library,
    .ai-prep-panel,
    .ai-live-avatar-tutor,
    .ep-seo-feature-page,
    .ep-course-app,
    .ep-course-directory,
    .ep-course-experience,
    .ep-course-showcase,
    .ep-home-course-showcase,
    .ep-quiz-player,
    .ep-parent-access,
    .ep-parent-portal,
    .ep-kids-world,
    .ep-touch-learn,
    .ep-avatar-app,
    .ep-math-teacher,
    .ep-sp-wrap,
    .ep-smart-filter-shell,
    .ep-mobile-answer-viewer
) :where(h1, h2, h3, h4, p, li, label, legend, summary, strong, small, a, button) {
    overflow-wrap: anywhere;
}

/* Tablet: remove fixed-column pressure without changing desktop composition. */
@media (max-width: 1024px) {
    :where(
        .ai-study-app,
        .ai-study-dashboard,
        .ai-study-auth-shell,
        .ai-study-teacher-dashboard,
        .ai-study-voice-pro,
        .ai-study-ncert-library,
        .ai-prep-panel,
        .ai-live-avatar-tutor,
        .ep-seo-feature-page,
        .ep-course-app,
        .ep-course-directory,
        .ep-course-experience,
        .ep-course-showcase,
        .ep-home-course-showcase,
        .ep-quiz-player,
        .ep-parent-access,
        .ep-parent-portal,
        .ep-kids-world,
        .ep-touch-learn,
        .ep-avatar-app,
        .ep-math-teacher,
        .ep-sp-wrap,
        .ep-smart-filter-shell,
        .ep-mobile-answer-viewer
    ) > * {
        max-width: 100%;
        min-width: 0;
    }

    .ai-study-dashboard :where(.ai-study-main, .ai-study-panel, .ai-study-card),
    .ai-study-teacher-dashboard :where(.ai-study-main, .ai-study-panel, .ai-study-card),
    .ep-course-app :where(.ep-course-card, .ep-course-lesson, .ep-course-content-block),
    .ep-course-directory :where(.ep-course-card, .ep-course-grid),
    .ep-course-showcase :where(.ep-showcase-card, .ep-showcase-course-grid),
    .ep-parent-portal :where(.ep-parent-card, .ep-parent-panel),
    .ep-math-teacher :where(.ep-math-teacher-layout, .ep-math-teacher-workspace),
    .ai-live-avatar-tutor :where(.ai-live-avatar-main, .ai-live-avatar-control-panel) {
        max-width: 100%;
        min-width: 0;
    }
}

/* Mobile: shared full-width and overflow protection for every plugin surface. */
@media (max-width: 782px) {
    :where(
        .ai-study-app,
        .ai-study-dashboard,
        .ai-study-auth-shell,
        .ai-study-teacher-dashboard,
        .ai-study-voice-pro,
        .ai-study-ncert-library,
        .ai-prep-panel,
        .ai-live-avatar-tutor,
        .ep-seo-feature-page,
        .ep-course-app,
        .ep-course-directory,
        .ep-course-experience,
        .ep-course-showcase,
        .ep-home-course-showcase,
        .ep-quiz-player,
        .ep-parent-access,
        .ep-parent-portal,
        .ep-kids-world,
        .ep-touch-learn,
        .ep-avatar-app,
        .ep-math-teacher,
        .ep-sp-wrap,
        .ep-smart-filter-shell,
        .ep-mobile-answer-viewer
    ) {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    :where(
        .ai-study-app,
        .ai-study-dashboard,
        .ai-study-auth-shell,
        .ai-study-teacher-dashboard,
        .ai-study-voice-pro,
        .ai-study-ncert-library,
        .ai-prep-panel,
        .ai-live-avatar-tutor,
        .ep-seo-feature-page,
        .ep-course-app,
        .ep-course-directory,
        .ep-course-experience,
        .ep-course-showcase,
        .ep-home-course-showcase,
        .ep-quiz-player,
        .ep-parent-access,
        .ep-parent-portal,
        .ep-kids-world,
        .ep-touch-learn,
        .ep-avatar-app,
        .ep-math-teacher,
        .ep-sp-wrap,
        .ep-smart-filter-shell,
        .ep-mobile-answer-viewer
    ) * {
        min-width: 0;
    }

    :where(
        .ai-study-app,
        .ai-study-dashboard,
        .ai-study-auth-shell,
        .ai-study-teacher-dashboard,
        .ai-study-voice-pro,
        .ai-study-ncert-library,
        .ai-prep-panel,
        .ai-live-avatar-tutor,
        .ep-seo-feature-page,
        .ep-course-app,
        .ep-course-directory,
        .ep-course-experience,
        .ep-course-showcase,
        .ep-home-course-showcase,
        .ep-quiz-player,
        .ep-parent-access,
        .ep-parent-portal,
        .ep-kids-world,
        .ep-touch-learn,
        .ep-avatar-app,
        .ep-math-teacher,
        .ep-sp-wrap,
        .ep-smart-filter-shell,
        .ep-mobile-answer-viewer
    ) :where(input, select, textarea) {
        width: 100%;
        font-size: 16px;
    }

    :where(
        .ai-study-app,
        .ai-study-dashboard,
        .ai-study-teacher-dashboard,
        .ai-study-voice-pro,
        .ai-prep-panel,
        .ep-course-app,
        .ep-course-directory,
        .ep-course-experience,
        .ep-course-showcase,
        .ep-parent-portal,
        .ep-math-teacher
    ) :where(
        .ai-study-grid,
        .ai-study-advanced-grid,
        .ai-study-answer-layout,
        .ai-study-camera-grid,
        .ai-study-form-grid,
        .ai-study-voice-conv-grid,
        .ep-course-grid,
        .ep-course-filters,
        .ep-showcase-course-grid,
        .ep-parent-access__grid,
        .ep-parent-dashboard__grid,
        .ep-math-teacher-layout
    ) {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    :where(
        .ai-study-app,
        .ai-study-dashboard,
        .ai-study-teacher-dashboard,
        .ai-study-voice-pro,
        .ai-prep-panel,
        .ep-course-app,
        .ep-course-directory,
        .ep-course-experience,
        .ep-course-showcase,
        .ep-parent-portal,
        .ep-math-teacher
    ) :where(.ai-study-table-wrap, .ai-study-history-table, .ep-course-table, .ep-parent-table) {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .ai-study-teacher-dashboard .ai-study-shell {
        grid-template-columns: minmax(0, 1fr) !important;
        grid-template-areas: "teacher-sidebar" "teacher-main" !important;
    }

    .ai-study-teacher-dashboard .ai-study-teacher-nav,
    .ai-study-dashboard :where(.ai-study-tabs, .ai-study-chip-row, .ai-study-toolbar),
    .ai-study-voice-pro :where(.ai-study-voice-pro__btn-row, .ai-study-voice-pro__mode-tabs),
    .ep-course-app :where(.ep-course-nav, .ep-course-actions),
    .ep-course-showcase :where(.ep-showcase-actions, .ep-showcase-chip-grid) {
        max-width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
    }
}

/* Kids World: compact two-column cards where they fit, no right-edge clipping. */
@media (max-width: 820px) {
    .ep-kids-world {
        padding-inline: clamp(7px, 2.5vw, 14px) !important;
        overflow-x: clip;
    }

    .ep-kids-world :where(
        .ep-kids-hero,
        .ep-kids-profile-strip,
        .ep-kids-mood,
        .ep-kids-highlight-grid,
        .ep-kids-games,
        .ep-kids-explore,
        .ep-kids-create,
        .ep-kids-rewards,
        .ep-kids-family,
        .ep-kids-story-grid,
        .ep-kids-gallery,
        .ep-kids-reward-grid,
        .ep-kids-parent-controls,
        .ep-kids-game-picker,
        .ep-kids-game-stage
    ) {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .ep-kids-highlight-grid,
    .ep-kids-gallery,
    .ep-kids-reward-grid,
    .ep-kids-game-picker {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 9px !important;
    }

    .ep-kids-feature-card,
    .ep-kids-gallery article,
    .ep-kids-reward-grid article {
        min-width: 0;
        min-height: 0;
        padding: 14px !important;
    }

    .ep-kids-feature-card {
        grid-template-columns: minmax(0, 1fr) !important;
        align-content: start;
        gap: 8px !important;
    }

    .ep-kids-feature-icon {
        width: 44px !important;
        height: 44px !important;
        border-radius: 13px !important;
        font-size: 23px !important;
    }

    .ep-kids-feature-card h2,
    .ep-kids-feature-card p {
        min-height: 0 !important;
    }

    .ep-kids-feature-card h2 {
        font-size: clamp(15px, 4.2vw, 19px) !important;
    }

    .ep-kids-feature-card p {
        display: -webkit-box;
        overflow: hidden;
        margin: 7px 0 10px !important;
        font-size: 12px !important;
        line-height: 1.45 !important;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 3;
    }

    .ep-kids-feature-card .ep-kids-btn {
        width: 100%;
        min-height: 38px;
        padding: 7px 8px;
        font-size: 11px;
    }

    .ep-kids-feature-card--weekly {
        grid-column: auto !important;
    }

    .ep-kids-highlight-grid > :last-child:nth-child(odd) {
        grid-column: 1 / -1 !important;
    }

    .ep-kids-story-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 9px !important;
    }

    .ep-kids-story-card {
        grid-template-columns: minmax(0, 1fr) !important;
        align-content: start;
        gap: 8px !important;
        min-height: 0 !important;
        padding: 11px !important;
    }

    .ep-kids-story-card__icon,
    .ep-kids-story-card__picture {
        width: 100% !important;
        height: 92px !important;
        max-width: none !important;
        border-radius: 15px !important;
        font-size: 42px !important;
        letter-spacing: 4px !important;
    }

    .ep-kids-story-card__body {
        min-width: 0;
    }

    .ep-kids-story-card h3 {
        font-size: clamp(14px, 4vw, 17px) !important;
    }

    .ep-kids-story-card p {
        display: -webkit-box;
        overflow: hidden;
        font-size: 12px !important;
        line-height: 1.45 !important;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 3;
    }

    .ep-kids-section-nav {
        position: sticky;
        width: 100%;
        max-width: 100%;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        overflow-x: hidden !important;
    }

    .ep-kids-filter-row {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .ep-kids-filter-row :where(select, button) {
        width: 100% !important;
        min-width: 0 !important;
    }

    .ep-kids-game-picker > button {
        min-width: 0;
        padding: 11px 6px !important;
    }

    .ep-kids-letter-bank,
    .ep-kids-picture-options,
    .ep-kids-memory-grid {
        width: 100%;
        max-width: 100%;
        grid-template-columns: repeat(auto-fit, minmax(58px, 1fr)) !important;
        gap: 7px !important;
    }

    .ep-kids-player,
    .ep-kids-player__shell {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }

    .ep-kids-player__shell {
        height: 100vh;
        height: 100svh;
        height: 100dvh;
        min-height: 0;
        overflow: hidden;
    }

    .ep-kids-player__header {
        min-height: 58px !important;
        padding:
            max(7px, env(safe-area-inset-top))
            max(8px, env(safe-area-inset-right))
            7px
            max(9px, env(safe-area-inset-left)) !important;
    }

    .ep-kids-player__header h2 {
        max-width: 100%;
        font-size: 17px !important;
    }

    .ep-kids-player__header-actions {
        flex: 0 0 auto;
        gap: 5px !important;
    }

    .ep-kids-player__progress {
        grid-template-columns: auto minmax(0, 1fr) !important;
        padding: 6px 10px !important;
    }

    .ep-kids-player__body {
        min-height: 0;
        padding: 8px !important;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }

    .ep-kids-story-stage,
    .ep-kids-scene,
    .ep-kids-ending {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .ep-kids-scene,
    .ep-kids-ending {
        padding: 13px !important;
    }

    .ep-kids-scene__visual {
        width: 100% !important;
        max-width: 100% !important;
        min-height: 150px !important;
        padding: 12px !important;
    }

    .ep-kids-choice-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 7px !important;
    }

    .ep-kids-choice,
    .ep-kids-choice:last-child:nth-child(odd) {
        width: 100% !important;
        min-width: 0 !important;
        min-height: 116px !important;
        grid-column: auto !important;
        padding: 9px 6px !important;
    }

    .ep-kids-choice__picture {
        width: 58px !important;
        height: 58px !important;
        font-size: 31px !important;
    }

    .ep-kids-choice strong {
        font-size: 12px !important;
    }

    .ep-kids-player__tools {
        width: 100%;
        max-width: 100%;
        padding:
            6px
            max(7px, env(safe-area-inset-right))
            max(6px, env(safe-area-inset-bottom))
            max(7px, env(safe-area-inset-left)) !important;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
    }

    .ep-kids-player__tools > button,
    .ep-kids-player__more {
        flex: 0 0 auto;
    }

    .ep-kids-player__status {
        padding:
            5px
            max(8px, env(safe-area-inset-right))
            max(5px, env(safe-area-inset-bottom))
            max(8px, env(safe-area-inset-left)) !important;
    }

    .ep-kids-modal {
        padding: 0 !important;
    }

    .ep-kids-modal__dialog {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        padding:
            max(12px, env(safe-area-inset-top))
            max(12px, env(safe-area-inset-right))
            max(12px, env(safe-area-inset-bottom))
            max(12px, env(safe-area-inset-left)) !important;
        border-radius: 0 !important;
    }
}

/* Touch & Learn remains usable down to narrow phones without horizontal drift. */
@media (max-width: 640px) {
    .ep-touch-learn {
        padding-inline: 7px !important;
        overflow-x: clip;
    }

    .ep-touch-learn :where(
        .ep-touch-hero,
        .ep-touch-tabs,
        .ep-touch-toolbar,
        .ep-touch-mode-row,
        .ep-touch-main,
        .ep-touch-preview,
        .ep-touch-board-wrap,
        .ep-touch-grid,
        .ep-touch-footer,
        .ep-touch-parent-report,
        .ep-touch-progress-sync
    ) {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .ep-touch-preview {
        grid-template-columns: 78px minmax(0, 1fr) !important;
        gap: 9px !important;
    }

    .ep-touch-preview-visual {
        min-height: 78px !important;
        font-size: 48px !important;
    }

    .ep-touch-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        gap: 6px !important;
    }

    .ep-touch-card {
        min-width: 0 !important;
        padding-inline: 3px !important;
    }

    .ep-touch-modal {
        padding: 0 !important;
    }

    .ep-touch-modal-card {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
    }
}

/* Live English/Maths board: full safe viewport with independently scrolling controls. */
@media (max-width: 900px) {
    .ep-magic-modal {
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden !important;
    }

    .ep-magic-modal__dialog {
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        height: 100vh !important;
        height: 100svh !important;
        height: 100dvh !important;
        min-height: 0 !important;
        padding:
            max(6px, env(safe-area-inset-top))
            max(7px, env(safe-area-inset-right))
            max(6px, env(safe-area-inset-bottom))
            max(7px, env(safe-area-inset-left)) !important;
        gap: 6px !important;
    }

    .ep-magic-modal__head {
        width: 100%;
        min-height: 38px;
        gap: 7px !important;
    }

    .ep-magic-modal__head > div {
        flex: 1 1 auto;
        min-width: 0;
    }

    .ep-magic-modal__head strong {
        font-size: 16px !important;
    }

    .ep-magic-modal__head small {
        overflow: hidden;
        font-size: 10px !important;
        line-height: 1.25 !important;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .ep-magic-modal__close,
    .ep-magic-modal__head > button.ep-magic-modal__close {
        flex-basis: 38px !important;
        width: 38px !important;
        min-width: 38px !important;
        max-width: 38px !important;
        height: 38px !important;
        min-height: 38px !important;
        max-height: 38px !important;
    }

    .ep-magic-modal__close span {
        width: 34px !important;
        height: 34px !important;
        font-size: 24px !important;
        line-height: 32px !important;
    }

    .ep-board-live-teacher {
        width: 100%;
        max-width: 100%;
        grid-template-columns: 12px minmax(0, 1fr) !important;
        gap: 6px !important;
        padding: 6px !important;
    }

    .ep-board-live-teacher small {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .ep-board-live-teacher__actions {
        grid-column: 1 / -1 !important;
        display: flex !important;
        width: 100% !important;
        max-width: 100% !important;
        flex-wrap: nowrap !important;
        justify-content: flex-start !important;
        gap: 4px !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        padding-bottom: 2px;
        scrollbar-width: thin;
        -webkit-overflow-scrolling: touch;
    }

    .ep-board-live-teacher__actions button {
        flex: 0 0 auto !important;
        width: auto !important;
        min-width: 72px !important;
        min-height: 30px !important;
        padding: 5px 7px !important;
        font-size: 9px !important;
        white-space: nowrap !important;
    }

    .ep-whiteboard-tools {
        width: 100% !important;
        max-width: 100% !important;
        min-height: 36px !important;
        gap: 5px !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        padding: 2px 0 4px !important;
        scrollbar-width: thin;
        -webkit-overflow-scrolling: touch;
    }

    .ep-whiteboard-tools button {
        flex: 0 0 auto !important;
        min-height: 30px !important;
        padding: 5px 8px !important;
        font-size: 10px !important;
        white-space: nowrap !important;
    }

    .ep-whiteboard-workspace {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        min-height: 0 !important;
    }

    .ep-traditional-maths-board,
    .ep-drawing-board {
        max-width: 100% !important;
        min-width: 0 !important;
    }

    .ep-board-history-head {
        width: 100%;
        max-width: 100%;
        gap: 5px !important;
    }

    .ep-board-history-head > div {
        min-width: 0;
        gap: 4px !important;
    }

    .ep-board-history-head button {
        min-width: 0 !important;
        padding: 5px 7px !important;
        font-size: 9px !important;
    }

    .ep-board-turn,
    .ep-board-turn details,
    .ep-board-turn summary,
    .ep-board-turn__answer {
        max-width: 100%;
        min-width: 0;
    }

    .ep-board-turn summary {
        padding: 7px !important;
    }

    .ep-board-turn__answer {
        padding: 7px 8px 9px !important;
    }

    .ep-homework-dialog,
    .ep-highlights-dialog {
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    /* English is text-only: reserve the viewport for the lesson, not controls. */
    .ep-magic-modal[data-board-subject="english"] .ep-board-mobile-panel {
        flex: 0 0 auto;
        min-width: 0;
    }

    .ep-magic-modal[data-board-subject="english"] .ep-whiteboard-workspace {
        display: block !important;
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow: hidden !important;
        padding-bottom: 0 !important;
    }

    .ep-magic-modal[data-board-subject="english"] .ep-traditional-maths-board {
        width: 100% !important;
        height: 100% !important;
        min-height: 0 !important;
        max-height: none !important;
        padding: 8px !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;
    }

    .ep-magic-modal[data-board-subject="english"] .ep-board-history-head {
        flex-direction: row !important;
        align-items: center !important;
        margin-bottom: 6px !important;
    }

    .ep-magic-modal[data-board-subject="english"] .ep-board-history-head > div {
        display: flex !important;
        width: auto !important;
        flex: 0 1 auto;
        overflow-x: auto;
    }

    .ep-magic-modal[data-board-subject="english"] .ep-traditional-maths-board ol {
        padding-left: 0 !important;
        font-size: clamp(14px, 4.1vw, 17px) !important;
        line-height: 1.5 !important;
    }

    /* Maths keeps separate scrolling history and drawing areas. */
    .ep-magic-modal[data-board-subject="maths"] .ep-board-maths-input {
        width: 100%;
        max-width: 100%;
        padding: 7px !important;
    }

    .ep-magic-modal[data-board-subject="maths"] .ep-board-maths-input > div {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 5px !important;
    }

    .ep-magic-modal[data-board-subject="maths"] .ep-board-maths-input input {
        grid-column: 1 / -1 !important;
    }

    .ep-magic-modal[data-board-subject="maths"] .ep-board-maths-input button {
        min-width: 0;
        min-height: 36px;
        padding: 6px 5px;
        font-size: 10px;
    }
}

/* Very narrow devices: preserve readability instead of forcing two tiny cards. */
@media (max-width: 359px) {
    .ep-kids-highlight-grid,
    .ep-kids-story-grid,
    .ep-kids-gallery,
    .ep-kids-reward-grid {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .ep-kids-hero {
        grid-template-columns: 48px minmax(0, 1fr) !important;
        padding: 10px !important;
    }

    .ep-kids-guide {
        width: 46px !important;
        height: 46px !important;
    }

    .ep-kids-section-nav button,
    .ep-kids-game-picker > button {
        font-size: 10px !important;
    }

    .ep-touch-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .ep-magic-modal__dialog {
        padding-inline: 5px !important;
    }

    .ep-board-live-teacher__actions button {
        min-width: 66px !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ep-kids-world *,
    .ep-touch-learn *,
    .ep-magic-modal * {
        scroll-behavior: auto !important;
    }
}

/* v1.72.34 — final responsive override for plugin close controls */
.ep-glass-close,.ep-magic-modal__close,[data-ep-whiteboard-close],[data-ep-homework-close],[data-ep-highlights-close],.ep-kids-modal__close,[data-ep-kids-profile-close],.ep-touch-modal-close,[data-ai-study-modal-close],[data-ai-fs-close][aria-label],[data-ep-continue-action="close"],[data-ep-continue-action="close-mini"]{
    width:34px!important;min-width:34px!important;max-width:34px!important;height:34px!important;min-height:34px!important;max-height:34px!important;padding:0!important;margin:0!important;border-radius:50%!important;border:1px solid rgba(255,255,255,.56)!important;background:linear-gradient(145deg,rgba(255,80,92,.94),rgba(176,17,43,.9))!important;color:#fff!important;box-shadow:0 8px 18px rgba(167,20,43,.25),inset 0 1px 0 rgba(255,255,255,.5)!important;backdrop-filter:blur(12px)!important;-webkit-backdrop-filter:blur(12px)!important;font:900 22px/1 Arial,sans-serif!important;display:grid!important;place-items:center!important;cursor:pointer!important
}
.ep-magic-modal__close span{width:auto!important;height:auto!important;font:900 22px/1 Arial,sans-serif!important}
.ep-mobile-answer-viewer__close,[data-ep-full-answer-close],[data-ep-kids-player-close][aria-label]{width:34px!important;min-width:34px!important;max-width:34px!important;height:34px!important;min-height:34px!important;max-height:34px!important;padding:0!important;margin:0!important;border-radius:50%!important;border:1px solid rgba(255,255,255,.56)!important;background:linear-gradient(145deg,rgba(255,80,92,.94),rgba(176,17,43,.9))!important;color:#fff!important;box-shadow:0 8px 18px rgba(167,20,43,.25),inset 0 1px 0 rgba(255,255,255,.5)!important;backdrop-filter:blur(12px)!important;-webkit-backdrop-filter:blur(12px)!important;font:900 22px/1 Arial,sans-serif!important;display:grid!important;place-items:center!important;cursor:pointer!important}
