/* Full viewport workspaces. Screen-only rules preserve document/export layouts. */
@media screen {
  html { -webkit-text-size-adjust:100%; text-size-adjust:100%; }
  body :is(dialog, .overlay, .exit-overlay, .excuse-modal, .medical-page-preview) {
    box-sizing:border-box;
    position:fixed!important; inset:0!important; margin:0!important;
    width:100%!important; max-width:none!important;
    height:100vh!important; height:100dvh!important; max-height:none!important;
    border:0!important; border-radius:0!important;
    overscroll-behavior:contain; -webkit-overflow-scrolling:touch;
  }
  body dialog {
    --workspace-pad:16px;
    padding:max(var(--workspace-pad),env(safe-area-inset-top)) max(var(--workspace-pad),env(safe-area-inset-right)) max(24px,env(safe-area-inset-bottom)) max(var(--workspace-pad),env(safe-area-inset-left))!important;
    overflow:auto!important;
  }
  body :is(.overlay,.exit-overlay,.excuse-modal) {
    padding:0!important; background:#fffdfa; overflow:hidden!important;
    align-items:stretch!important; justify-content:stretch!important; place-items:stretch!important;
  }
  body :is(.overlay>.dialog,.exit-overlay>.exit-dialog,.excuse-modal>.ao-document) {
    box-sizing:border-box; width:100%!important; max-width:none!important;
    height:100%!important; max-height:none!important; margin:0!important;
    border:0!important; border-radius:0!important; overflow:auto!important;
    padding:max(16px,env(safe-area-inset-top)) max(16px,env(safe-area-inset-right)) max(24px,env(safe-area-inset-bottom)) max(16px,env(safe-area-inset-left));
    overscroll-behavior:contain; background:#fffdfa;
  }
  body .exit-overlay>.exit-dialog { padding:0; }
  body .medical-page-preview { background:#f4f0ea; overflow:auto; }
  body :is(.st-dialog-head,.aw-dialog>header,.dialog>.heading) {
    position:sticky; top:-16px; z-index:5; background:#fffdfa;
    display:flex; align-items:center; justify-content:space-between;
    gap:12px; flex-wrap:wrap; padding-block:12px; margin-top:-12px;
    max-width:none;
  }
  body :is(dialog,.dialog,.exit-dialog,.excuse-modal) :is(h2,h3,button,input,select,textarea) { max-width:100%; overflow-wrap:anywhere; }
  body :is(dialog,.dialog,.exit-dialog,.excuse-modal) button { min-height:48px; }
  body :is(dialog,.dialog,.exit-dialog,.excuse-modal) :is(.table-wrap,.st-table-wrap) { max-width:100%; overflow-x:auto; }
  html:has(dialog[open],.overlay,.exit-overlay,.excuse-modal,.medical-page-preview),
  body:has(dialog[open],.overlay,.exit-overlay,.excuse-modal,.medical-page-preview) { overflow:hidden; }
}
@media screen and (max-width:640px) {
  body :is(dialog,.dialog,.excuse-modal) :is(input,select,textarea) { font-size:16px!important; }
}
@media screen {
  body:has(#statistics:not([hidden]),#recognition:not([hidden])) .hp-top { display:none!important; }
  body :is(#statistics,#recognition):not([hidden]) {
    box-sizing:border-box; width:100%!important; max-width:none!important;
    min-height:100vh; min-height:100dvh; margin:0!important;
    padding:12px max(12px,env(safe-area-inset-right)) 24px max(12px,env(safe-area-inset-left))!important;
  }
  body :is(#statistics,#recognition)>.hp-back { position:sticky; top:0; z-index:10; background:#f7f4ef; min-height:48px; padding:10px 16px; border:1px solid #d7c8cd; border-radius:10px; }
}
