Kogi (also referred to as Kugi) is the term used for "official authority" in the middle and early modern ages.
Originally, the word "Kuge" meant "Oyake" or the Imperial Court and the Emperor, but after the establishment of the "Buke", or military administration and the new official authority that arose through private management in the manorial system, the word "Kogi" was used to differentiate from the "Buke", the bakufu (Japanese feudal government headed by a shogun) and seii taishogun (literally, "great general who subdues the barbarians").
Eventually, in the period of the Northern and Southern Courts (Japan), due to the conflict between the Muromachi bakufu (buke) which supported the Northern Court and the Yoshino Court (kuge), both sides called their official authority "Kogi", which led to the use of Kogi towards the bakufu and shogun as well.
Kogi became the general term for official authority in the period of governmental instability in towards the end of the Toyotomi administration, and in the Edo Period, Kogi started to indicate the Edo bakufu which was the only unified authority that mediated the power struggles among the feudal lords. However, the tradition to call the local landlord, or clan as Kogi remained and to recognize the bakufu as 'the kogi of kogi', it was especially called O-kogi (great official authority) after the Kanei Era. However, the relationship between public and private was ambiguous at that time, and although the upper authorities were Kogi from the viewpoint of the common people and lower authorities, the upper authorities viewed the common people and lower authorities as Watakushi (private) and as the landlord, connected by private dominance. Seken (the world) was a place where Oyake (higher rank) and Watakushi (lower rank) mixed and in some cases it was also called Kogi (because it included the upper authorities). Even now, the use of Kogi to mean 'Seken (the world)' or 'Sekentei (decency)' is a vestige of such usage.