For years I wanted a parent selector, and :has() is the answer.
label:has(input:checked) { background: #e6f4ea; }
.card:has(img) { grid-template-columns: 8rem 1fr; }
form:has(:invalid) button { opacity: .5; }
:has() matches an element when something inside it, or next to it, matches the selector list in the brackets. The first line highlights a label whose checkbox is ticked, the second changes a card layout only when it contains an image. It works in all current browsers (Firefox since version 121). Keep the inner selector narrow: a broad pattern like body:has(.x) forces the browser to re-check a lot of the page on every change.
Further reading: MDN: :has()