End the specificity wars — layer order beats selector weight
Four layers each style the same button with different colors. Use ▲▼ to reorder — the last layer always wins, regardless of selector specificity. Then flip on the unlayered rule and watch it beat everything.
button { } rule outside any layer defeats every layered rule, no matter the layer or specificity. This is by design (it enables incremental migration) but it's the top source of "my Tailwind v4 utilities stopped working" bugs — one unlayered reset in globals.css silently overrides utilities living inside layers.
With normal declarations, later layers win. Add !important and the entire order flips: earlier layers win. This is the spec's genius — it lets low-priority layers (like resets) protect critical declarations — and the biggest mind-bender in the feature.
reset layer can mark accessibility-critical declarations !important — and nothing above it, not even unlayered app styles, can casually override them. The layer that yields by default becomes the layer that protects on demand. Rule of thumb: in a layered codebase, !important means "protect this", not "force this".
The patterns running real 2026 codebases — including how Tailwind v4 is built entirely on @layer.
Declare order once, then fill layers anywhere in any file — even out of order. Gotcha: the FIRST declaration wins; a later @layer utilities, components; can't reorder them. Put the master declaration at the very top of your entry stylesheet.
The killer use case: a framework's .container .row .card p monster selectors can never beat your simple .content p again — your layer outranks theirs.
The #1 Tailwind v4 bug report: unlayered rules in globals.css silently defeating utility classes. DevTools clue: the winning rule shows no layer attribution — a bare selector. Fix: layer everything.
Sub-layers scope a vendor's internal ordering without polluting your top-level stack. The outer layer's position decides against your layers; inner order is the vendor's business.
revert-layer rolls a property back to whatever lower layers computed — surgical un-styling without knowing or repeating the lower layer's value.
Because unlayered beats layered, migration is safe by default: layer the vendor CSS first (instant specificity-war victory), then migrate your own files gradually. Watch for legacy internal specificity wars shifting winners when wrapped — test per file. Zero runtime cost: layers resolve at parse time.