Copyright prescribes when something is created and when it is a derivative work 17 U.S. Code § 101:
A work is “created” when it is fixed in a copy or phonorecord for the first time; where a work is prepared over a period of time, the portion of it that has been fixed at any particular time constitutes the work as of that time, and where the work has been prepared in different versions, each version constitutes a separate work.
A “derivative work” is a work based upon one or more preexisting works, such as a translation, musical arrangement, dramatization, fictionalization, motion picture version, sound recording, art reproduction, abridgment, condensation, or any other form in which a work may be recast, transformed, or adapted. A work consisting of editorial revisions, annotations, elaborations, or other modifications which, as a whole, represent an original work of authorship, is a “derivative work”.
A work is “fixed” in a tangible medium of expression when its embodiment in a copy or phonorecord, by or under the authority of the author, is sufficiently permanent or stable to permit it to be perceived, reproduced, or otherwise communicated for a period of more than transitory duration. A work consisting of sounds, images, or both, that are being transmitted, is “fixed” for purposes of this title if a fixation of the work is being made simultaneously with its transmission.
The owner of a copyright has special rights under 17 U.S. Code $106, among them:
Subject to sections 107 through 122, the owner of copyright under this title has the exclusive rights to do and to authorize any of the following:
(2)to prepare derivative works based upon the copyrighted work;
So, where is the edge between a derivative work and an idea? Let's explore OP's examples:
- Harry Potter has a whole slew of background and stuff. Stories set in the Harry Potter Universe transform or adapt the given work and so are derivative works. Filmographic adaptions are, by the very definition in 17USC101, Derivative Works. And Ms. Rowling is known to litigate a lot to keep the number of unlicensed, notable derivative works down.
- Star Trek, analogous to Harry Potter, does create a world of fiction. Adapting it for a fanfiction is, technically, creating a derivative work. So technically the 5 paragraph story "A Trekkie's Tale" by Paula Smith in Menagerie #2 is a derivative work. However, unlike Ms. Rowling, ViacomCBS isn't the harshest litigator and they seem to have only rarely taken action against fanzines.
- James Bond, even if in the public in CANADA, it is still under copyright in the US till 2034 and after that is still under a Trademark that won't expire. Also, Ian Fleming Publications has lots of copyright on the films left and can claim with lots of details that something is derivative of the film, not the book. And they do litigate easily.
Now, back to the other example. The "Man-Kzin Wars" and lots of words from their language. Are they an expression of an idea or are they an unprotectable scene a fair? First of all, they are words without a meaning in normal English. Then, the wars is the title of a book series by Larry Niven. As such, the title and words imply strongly, that you want to write a derivative work of the Known Space universe, so you might want to try to acquire a license from Mr. Niven - he is very much still alive and has all copyright and the right to deny you writing in his universe. Only if you make our work never refer to anything from Niven's work, you'd get far enough and end in scenes a fair: for example, an intergalactic war between humans and a feline species (as the Kzinti from Niven's work are) is also the basis in WingCommander (humans vs. Kilrathi), and in general, a feline anthropomorphic species is pretty much scene a fair: StarTrek features Caitians as feline aliens, StarWars has about 25 feline species, some of them embroiled in the different wars and there are tons of others out there, and even putting them in direct conflict with the humans is scene a fair. However, the details of the war are the expression of this idea.