True, there are limitations. I withdraw my class names suggestion
On third look, only very few inline styles are set (e.g. width for grid-item). As to class + data attribute selector, it'd be easy to use higher specificity, try: .grid .grid-item { border-radius: 50%; } or .grid .grid-item img { object-fit: contain; }. And there are a bunch of possible declarations that need not even override anything (e.g. filter, border, box-shadow).