There is not good answer to this question. But I must declare that I have, for a long time, now, regarded the so-called ‘gerund’ a weed that has spread unchecked through the language over the last 40 years.
Nevertheless, that does not prevent your example from being grammatically correct. The (so-called gerund phrase stands in apposition to the impersonal ‘it’, which is the subject of the sentence.
I don’t like it, because to me it is awkward and unnecessary. If the phrase is in apposition to the subject, why not place it in the subject position in the first place?
Reading such stories before sleeping is not advisable.
I should also prefer to avoid two gerunds in the same short sentence. I also agree with your second dictionary that in the sentence in question the preferable version is
It is not advisable to read such stories before sleeping.
But this alternative is preferable as a matter of style, not of grammar. It is simpler and clearer. It starts in the logical order: 1) topic (what the sentence is about - the ‘subject’); 2) predicate (what we have to say about it).
The order you ask about would work in a context like this. Charley is reading a horror story to little Maisie. Phil enters the room, looks shocked and seizes the book from Charley.
Charley - What do you think you’re doing?
Phil - It’s not advisable, reading such stories at bedtime.
This is OK because both Charley and Phil know the context. It is obvious the Phil is explaining his/her action. The ‘it’ of “It is not advisable” is obvious to both of them before the grammatical subject is mentioned. It just completes the sentence with the added inclusion of the (in the context) derogatory “such”).
But if the sentence were part of a list of do’s and don’ts with children it would be odd or at least clumsy )not incorrect) to use the gerund in this way.