/* Native dialogs stay in the viewport rather than inheriting the page reset. */
body dialog{
  position:fixed!important;
  inset:0!important;
  margin:auto!important;
  transform:none!important;
  box-sizing:border-box!important;
  width:min(860px,calc(100vw - 32px));
  max-width:calc(100vw - 32px)!important;
  height:fit-content;
  max-height:calc(100vh - 32px)!important;
  max-height:calc(100dvh - 32px)!important;
  overflow:auto;
  overscroll-behavior:contain;
}
body dialog.small-dialog{width:min(620px,calc(100vw - 32px))}
body #minute-editor{width:min(920px,calc(100vw - 32px))}
body #pdf-preview{
  width:min(1120px,calc(100vw - 32px));
  height:calc(100vh - 32px);
  height:calc(100dvh - 32px);
  overflow:hidden;
}
body #pdf-preview[open]{display:flex;flex-direction:column}
body #pdf-preview :is(.modal-header,.modal-footer,.pdf-controls){flex:0 0 auto;min-width:0}
body #pdf-preview .pdf-controls{flex-wrap:wrap}
body #pdf-preview .pdf-viewer{flex:1 1 0;min-height:0;min-width:0;overflow:auto;box-sizing:border-box}
body dialog :is(.modal-header,.modal-footer){min-width:0;box-sizing:border-box}
body dialog .modal-header>div{min-width:0}
body dialog :is(h2,.field-card){overflow-wrap:anywhere}
@media(max-width:720px){
 body dialog{max-width:calc(100vw - 20px)!important;max-height:calc(100vh - 20px)!important;max-height:calc(100dvh - 20px)!important;width:calc(100vw - 20px)}
 body #pdf-preview{width:calc(100vw - 20px);height:calc(100vh - 20px);height:calc(100dvh - 20px)}
 body dialog .modal-header{padding:16px;gap:12px}
 body dialog .modal-footer{padding:12px 16px;flex-wrap:wrap;gap:10px}
 body #pdf-preview .modal-footer span{flex:1 1 180px}
}

/* All form dialogs receive the same breathing room as document previews. */
body dialog form>header{display:flex;align-items:center;justify-content:space-between;gap:20px;padding:20px 24px;box-sizing:border-box;position:sticky;top:0;background:var(--lino);z-index:3;border-bottom:1px solid var(--linea)}
body dialog form>header>div{min-width:0}body dialog form>header h2{margin:5px 0 0;overflow-wrap:anywhere}
body dialog form>footer{display:flex;align-items:center;justify-content:flex-end;gap:12px;flex-wrap:wrap;padding:18px 24px;position:sticky;bottom:0;background:var(--lino);border-top:1px solid var(--linea);z-index:3;box-sizing:border-box}
body dialog form fieldset{padding:20px 24px;margin:0;min-width:0;box-sizing:border-box}body dialog form legend{padding:0 6px;font-weight:700}
@media(max-width:720px){body dialog form>header,body dialog form>footer,body dialog form fieldset{padding:18px}}
