I found the @screen directive, that solves this question:
https://tailwindcss.com/docs/functions-and-directives/#screen
as easy as
@screen md {
// whatever
}
Update. As mentioned in the comment, Taliwind 3.2.7 has different notation:
@media screen(sm) {
/* ... */
}