The central point is the evolutionary default of metaphysical realism or philosophical realism:
Those who oppose the above are anti-p-realists.Philosophical realism ... is the view that a certain kind of thing (ranging widely from abstract objects like numbers to moral statements to the physical world itself) has mind-independent existence, i.e. that it exists even in the absence of any mind perceiving it or that its existence is not just a mere appearance in the eye of the beholder.
...... realism [p] is contrasted with idealism.
https://en.wikipedia.org/wiki/Philosophical_realism
Kant is ultimately an antirealist, i.e. anti-p-realist.
While being a transcendental Idealist i.e. anti-p-realist, Kant is an empirical realist;Kant wrote:From the start, we have declared ourselves in favour of this Transcendental Idealism;
CPR-A370
Being an Empirical Realist means the empirical external world is independent of the human mind in one sense.Kant wrote:The Transcendental Idealist, on the other hand, may be an Empirical Realist CPR-A370
For example the apple on the tree out there exists independent of humans in one sense.
The oncoming train on the rail one is stepping on is not existing in the mind but external to the person's body, brain and mind.
However, Kant's empirical realism is subsumed within his ultimate transcendental Idealism [anti-p-realist].
Kant identify p-realists as Transcendental Realists which implied they are delusional in believing reality is absolute mind-independent.
Transcendental Realists believe what is reality is transcendental i.e. beyond the reach of human minds, exist regardless of humans i.e. absolutely mind-independent.
So, Kant is a Transcendental Idealist i.e. anti-p-realist while being an Empirical Realist at the same time in different contexts.