/* Keep native keyboard handling and add room only while an editable field is active. */
@media(any-pointer:coarse){input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=range]):not([type=button]):not([type=submit]),textarea,select{font-size:16px!important}}
html[data-jp-editing] body::after,html[data-jp-keyboard] body::after{content:"";display:block;clear:both;height:var(--jp-focus-space,0px);width:1px;pointer-events:none}
html[data-jp-keyboard] :is(input,textarea,[contenteditable=true]){scroll-margin-block:24px}
html[data-jp-editing] .jp-keyboard-composer,html[data-jp-keyboard] .jp-keyboard-composer{position:relative!important;inset-block-end:auto!important;bottom:auto!important}
html[data-jp-keyboard] .jp-keyboard-composer textarea{max-height:max(48px,min(120px,calc(var(--jp-visible-height) * .3)))!important}
html[data-jp-keyboard] dialog[open][data-jp-keyboard-dialog]{position:fixed!important;top:calc(var(--jp-visible-top,0px) + 12px)!important;bottom:auto!important;margin-block:0!important;min-height:0!important;max-height:calc(var(--jp-visible-height) - 24px)!important;overflow-y:auto!important;overscroll-behavior-y:contain;scroll-padding-block:20px;box-sizing:border-box}

html[data-jp-keyboard] body::after{height:max(var(--jp-keyboard-space,0px),var(--jp-focus-space,0px))}

/* A keyboard-sized viewport needs a smaller, independently scrolling history. */
@media(max-width:700px){
 html[data-jp-editing] #jp-teacher .jp-window .jp-teacher-threads,
 html[data-jp-keyboard] #jp-teacher .jp-window .jp-teacher-threads{height:clamp(80px,calc(var(--jp-visible-height) * .32),220px)!important;min-height:0!important;max-height:220px!important;overflow-y:auto;overflow-anchor:none}
 html[data-jp-editing] #jp-teacher .jp-window .jp-teacher-form,
 html[data-jp-keyboard] #jp-teacher .jp-window .jp-teacher-form{scroll-margin-block:20px}
 html[data-jp-editing] #jp-teacher .jp-window .jp-teacher-form textarea{box-sizing:border-box;overflow-y:auto;resize:none;max-height:120px!important}
 html[data-jp-editing] #jp-teacher .jp-window .jp-teacher-form>.jp-primary{max-width:110px;min-width:66px;white-space:normal;font-size:14px}
}
