& {
	//Give the tabs/Incognito/pfp the appropriate offset
	#private-browsing-indicator-with-label,
	.private-browsing-indicator-with-label /* Fix for Firefox 133+ */,
    #gkavatar-container {
		order: -1 !important; // Force to left
	}
	.titlebar-spacer{
		&[type="pre-tabs"] {
			order: -2 !important; // Force to left of Incognito
		}
	}
	&:not([privatebrowsingmode="temporary"]) {
		#TabsToolbar-customization-target {
			margin-inline-start: var(--tab-distance-from-toolbar-edge);
		}
	}
	// Incognito can't use this^ spacing, so we need to set it separately for Incognito
	&[privatebrowsingmode="temporary"] {
		#private-browsing-indicator-with-label,
		.private-browsing-indicator-with-label /* Fix for Firefox 133+ */ {
			margin-inline-start: var(--tab-distance-from-toolbar-edge);
		}
	}
	#gkavatar-container > #gk-firefox-account-button,
	.private-browsing-indicator-icon {
		margin-inline-start: 1px !important;
		margin-inline-end: var(--tab-distance-from-pfp) !important;
	}
	// Ensure left-sided titlebuttons go before Incognito in native titlebars
	&[gktitnative="true"] {
		@media (-moz-platform: macos) or ((-moz-platform: linux) and (-moz-gtk-csd-reversed-placement)) {
			.titlebar-buttonbox-container {
				order: -3 !important;
			}
		}
	}

	// Tweaks for Profile Titlebutton
	#gkpeople-button-container {
		margin-inline-end: 6px !important;
	}

	&[gktitnative="true"] {
		// Restore Firefox's AERO menubar styling
		#main-menubar:not(:-moz-lwtheme, :-moz-window-inactive) {
			background-color: rgba(255,255,255,.5) !important;
			color: black !important;
			border-radius: 4px !important;
		}
		#main-menubar > menu {
			text-shadow: 0 1px 4px rgba(255, 255, 255, 0.8) !important;
			@media not (-moz-platform: linux) {
				-moz-default-appearance: menuitem;
				appearance: menuitem !important;
			}
		}
	}
	
	&[gktitnative="false"] {
		//Unless the Linux Pre-Alpha flag is enabled, always use the white Google logo in non-native titlebars
		&[gkbranding="chrome"]:not([geckium-chrflag-linux-pre-alpha-titlebar="true"]) {
			&[privatebrowsingmode="temporary"],
			&:not([gkpeoplestyle="titlebutton"]) {
				.titlebar-buttonbox-container::before {
					content: url("chrome://userchrome/content/assets/img/chrome-1/titlebar/windows/google-alternate.png");
					margin-block-start: 3px;
					margin-inline-end: 7px;
				}
				&[sizemode="maximized"],
				&[sizemode="fullscreen"] {
					.titlebar-buttonbox-container::before {
						content: unset !important;
					}
				}
			}
			&:not([privatebrowsingmode="temporary"]),
			&[gkpeoplestyle="titlebutton"] {
				#gkpeople-button-container::before {
					content: url("chrome://userchrome/content/assets/img/chrome-1/titlebar/windows/google-alternate.png");
					margin-block-start: 3px;
					margin-inline-end: 7px;
				}
				&[sizemode="maximized"],
				&[sizemode="fullscreen"] {
					#gkpeople-button-container::before {
						content: unset !important;
					}
				}
			}
		}

		//Shared non-native titlebar variables
		--titlebutton-border-outer: 1px solid rgb(0, 0, 0, 0.35);
		--titlebutton-corner: 3.5px;

		//Titlebar button box (force onto right side)
		.titlebar-buttonbox-container {
			order: 1000 !important;
			align-items: unset !important;
			margin-inline-end: var(--titlebar-border-radius); // right margin
		}
		//Windows quirk: See Geckium_titlebar.uc.js: getTitleBordersRemovable for more information
		@media (-moz-platform: windows) {
			.titlebar-buttonbox-container {
				margin-inline-end: 4px !important;
			}
		}
		//Linux quirk: Counteract exclusive menubar padding
		@media (-moz-platform: linux) {
			#toolbar-menubar .titlebar-buttonbox-container {
				margin-block-start: -1px; // top margin
			}
		}

		.titlebar-buttonbox {
			align-items: unset !important;
			box-shadow: 1px 1px 0px 0px rgba(255, 255, 255, 0.2);
			border-bottom-left-radius: var(--titlebutton-corner); //the box-shadow extrudes, thus automatically deducts 1px
			border-bottom-right-radius: var(--titlebutton-corner);
			// FIXME: Better way to make the buttonbox decide to be the correct height thus not offset the shadow underneath
			height: 17px;
		}
		&:-moz-locale-dir(rtl) { //Flip shadows in RTL
			.titlebar-buttonbox {
				box-shadow: -1px 1px 0px 0px rgba(255, 255, 255, 0.2);
			}
		}


		//Shared titlebar button code
		.titlebar-button {
			background: unset !important;
			background-color: transparent !important;
			border-radius: 0 !important;
			border-left: var(--titlebutton-border-outer) !important;
			border-bottom: var(--titlebutton-border-outer) !important;
			height: 17px;
			background-clip: padding-box !important;
			box-shadow: inset 1px 1px 0px 0px rgba(255, 255, 255, 0.3);
			transition: background-color 100ms linear; //hover-fade animation
			min-width: 25px;
			display: flex !important; // Really, macOS's and Windows 8-'s Mozilla Firefox?

			image { // Set the icon's opacity and hover-fade
				opacity: .6 !important;
				transition: opacity 100ms linear;
			}

			// Hover and pressed states
			&:not([disabled]):hover {
				background-color: rgba(255, 255, 255, 0.3) !important;

				&:active {
					background-color: rgba(255, 255, 255, 0.2) !important;
					transition: none;
				}

				image {
					opacity: 1 !important;
				}
			}
		}
		.titlebar-max,
		.titlebar-restore,
		.titlebar-min {
			&:active {
				box-shadow: inset 1px 1px 0px 0px rgba(0, 0, 0, 0.2);
			}
		}
		&:-moz-locale-dir(rtl) {
			.titlebar-button {
				border-left: unset !important;
				border-right: var(--titlebutton-border-outer) !important;
				box-shadow: inset -1px 1px 0px 0px rgba(255, 255, 255, 0.3);
			}

			.titlebar-max,
			.titlebar-restore,
			.titlebar-min {
				&:active {
					box-shadow: inset -1px 1px 0px 0px rgba(0, 0, 0, 0.2);
				}
			}
		}

		//Close button
		.titlebar-close {
			width: 43px;
			list-style-image: url("chrome://userchrome/content/assets/img/chrome-1/titlebar/windows/close.svg") !important; // Mozilla bias moment #idk
			border-right: var(--titlebutton-border-outer) !important;
			border-bottom-right-radius: var(--titlebutton-corner) !important; // because border-radius is !important
			order: 2 !important;

			&:not([disabled]):hover {
				background-color: rgb(217, 76, 74) !important;
			}

			&:not([disabled]):hover:active {
				background-color: rgb(213, 58, 63) !important;
			}
		}
		&:-moz-locale-dir(rtl) { //Swap sides in RTL
			.titlebar-close {
				border-left: var(--titlebutton-border-outer) !important; // right-side border is already present
				border-bottom-right-radius: unset !important;
				border-bottom-left-radius: var(--titlebutton-corner) !important;
			}
		}

		//Maximise and Restore buttons
		.titlebar-max {
			list-style-image: url("chrome://userchrome/content/assets/img/chrome-1/titlebar/windows/maximize.svg") !important;
		}
		&[sizemode="maximized"],
		&[sizemode="fullscreen"] {
			.titlebar-max {
				display: none !important;
			}
		}
		.titlebar-restore {
			list-style-image: url("chrome://userchrome/content/assets/img/chrome-1/titlebar/windows/restore.svg") !important;
			.toolbarbutton-icon {
				transform: translateX(-1px);
			}
		}
		&:-moz-locale-dir(rtl) { //Mirror glyph in RTL
			.titlebar-restore .toolbarbutton-icon {
				transform: translateX(0px) scaleX(-1);
			}
		}
		&:not([sizemode="maximized"]):not([sizemode="fullscreen"]) {
			.titlebar-restore {
				display: none !important;
			}
		}
		.titlebar-max,
		.titlebar-restore {
			order: 1 !important;
		}

		//Minimise button
		.titlebar-min {
			list-style-image: url("chrome://userchrome/content/assets/img/chrome-1/titlebar/windows/minimize.svg") !important;
			border-bottom-left-radius: var(--titlebutton-corner) !important; // because border-radius is !important
			order: 0 !important;
		}
		&:-moz-locale-dir(rtl) { //Swap sides in RTL
			.titlebar-min {
				border-bottom-left-radius: unset !important;
				border-bottom-right-radius: var(--titlebutton-corner) !important;
			}
		}

		// Glen's head
		&[geckium-chrflag-glen-is-close-button="true"] {
			//Move where the shadow is for Glen's head
			.titlebar-buttonbox {
				box-shadow: unset;
			}
			.titlebar-button::before { //Linux didn't have this until 17/18
				content: unset !important;
			}
			.titlebar-max,
			.titlebar-restore,
			.titlebar-min {
				box-shadow: inset 1px 1px 0px 0px rgba(255, 255, 255, 0.3),
					1px 1px 0px 0px rgba(255, 255, 255, 0.2);
				&:active { //Add to the existing shadow
					box-shadow: inset 1px 1px 0px 0px rgba(0, 0, 0, 0.2),
						1px 1px 0px 0px rgba(255, 255, 255, 0.2);
				}
			}
			.titlebar-max,
			.titlebar-restore {
				clip-path: inset(-1px 0px -1px -1px); //Remove the right-side shadow
			}
			// Change close to Glen's head, and make further necessary adjustments
			.titlebar-close {
				width: 24px;
				height: 32px;
				background: url("chrome://userchrome/content/assets/img/chrome-1/titlebar/linux/glen-close.png") !important; // Mozilla bias moment #idk
				background-position: center !important;
				background-repeat: no-repeat !important;
				border-bottom: unset !important;
				border-left: unset !important;
				border-right: unset !important;
				border-bottom-right-radius: 0 !important; // because border-radius is !important
				box-shadow: unset;
				list-style-image: unset !important;
	
				&:not([disabled]):hover, &:not([disabled]):hover:active {
					background-color: unset !important;
				}
			}
			.titlebar-max,
			.titlebar-restore {
				border-right: var(--titlebutton-border-outer) !important;
			}
			&:-moz-locale-dir(rtl) {
				.titlebar-max,
				.titlebar-restore,
				.titlebar-min {
					box-shadow: inset -1px 1px 0px 0px rgba(255, 255, 255, 0.3),
						-1px 1px 0px 0px rgba(255, 255, 255, 0.2);
					&:active { //Add to the existing shadow
						box-shadow: inset -1px 1px 0px 0px rgba(0, 0, 0, 0.2),
							-1px 1px 0px 0px rgba(255, 255, 255, 0.2);
					}
				}
				.titlebar-max,
				.titlebar-restore {
					clip-path: inset(-1px -1px -1px 0px); //Remove the left-side shadow
					border-left: var(--titlebutton-border-outer) !important;
				}
			}
		}
	}

	// Add spacing between caption buttons and tabs.
	&[sizemode="maximized"] .titlebar-spacer[type="post-tabs"] {
		margin-inline-end: 16px !important;
	}
	&:not([sizemode="maximized"]) .titlebar-spacer[type="post-tabs"] {
		margin-inline-end: 5px !important;
	}
}