/* Active only while a software keyboard reduces the visible viewport.
   New native dialogs work by default; custom panels opt in with one attribute. */
:root{--keyboard-viewport-height:100dvh;--keyboard-viewport-top:0px;--keyboard-viewport-bottom:100dvh}
[data-keyboard-active]{
  --keyboard-surface-height:min(var(--keyboard-max-height,100dvh),calc(var(--keyboard-viewport-height) - env(safe-area-inset-top,0px) - 12px));
  box-sizing:border-box;
  animation:none!important;
  transition:none!important;
}
[data-keyboard-active="sheet"]{
  position:fixed!important;top:var(--keyboard-viewport-bottom)!important;bottom:auto!important;
  max-height:var(--keyboard-surface-height)!important;
  margin-top:0!important;margin-bottom:0!important;transform:translateY(-100%)!important;
}
[data-keyboard-active="full"]{
  position:fixed!important;top:var(--keyboard-viewport-top)!important;bottom:auto!important;
  height:var(--keyboard-viewport-height)!important;max-height:var(--keyboard-viewport-height)!important;
  margin-top:0!important;margin-bottom:0!important;
}
[data-keyboard-active="popover"]{
  position:fixed!important;top:calc(var(--keyboard-viewport-top) + env(safe-area-inset-top,0px) + 12px)!important;bottom:auto!important;
  max-height:var(--keyboard-surface-height)!important;overflow-y:auto!important;
  margin-top:0!important;margin-bottom:0!important;transform:none!important;
}
dialog[data-keyboard-active]:not([data-keyboard-surface]){overflow-y:auto}
[data-keyboard-scroll]{min-height:0;overscroll-behavior:contain;scroll-padding-block:12px}
:root[data-keyboard-open="true"] textarea:not([data-keyboard-owner="chat"]){max-height:max(64px,min(180px,45dvh))!important}
/* Leave room to scroll the final field on normal, non-fixed pages. */
:root[data-keyboard-document] body::after{content:"";display:block;height:var(--keyboard-covered-height);pointer-events:none}
.login[data-keyboard-active]{justify-content:flex-start;overflow-y:auto}
.login[data-keyboard-active]>*{flex-shrink:0}
.terminal-log,.profile-scroll{min-height:0}
.terminal-panel[data-keyboard-active] .terminal-form{padding-bottom:10px}
.modal[data-keyboard-active]>.sheet{max-height:100%;min-height:0}
.coread-study [data-keyboard-active]{overflow-y:auto!important}
/* Prevent focus zoom from creating a second, unrelated viewport change. */
@media(pointer:coarse){
  input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]),textarea,select{font-size:16px!important}
}
