#controls {
	--border-color: #434;
	--row-sep-color: #424;
	--controls-bg: #171717;
	--header-bg: #292929;
	--main-header-bg: hsl(from var(--header-bg) h s calc(l * 0.75));

	--input-bg: #333;
	--checkbox-border: #646;

	--slider-track: #735;
	--slider-thumb: #dfb1ff;
}

.controls-wrapper {
	position: absolute;
	top: 0;
	right: 0;

	width: 293px;
	border: 1px solid var(--border-color);

	font-size: 0.9em;
	font-family: var(--font-title), serif;
	text-align: left;
}

/* folders */

.controls-folder {
	background: var(--controls-bg);
}
.controls-folder .body {
	display: none;
}
.controls-folder.open > .body {
	display: block;
}

.controls-folder .head {
	cursor: pointer;
	border-bottom: 1px solid var(--border-color);
	padding: 0.15em 0.25em 0.15em 0.5em;
	background: var(--header-bg);
	display: flex;
	flex-direction: row;
}
.controls-main > .head {
	background: var(--main-header-bg);
}
.controls-main:not(.open) > .head {
	border-bottom: 0;
}

.controls-folder .head h4 {
	font-size: 1em;
	font-weight: normal;
	flex-grow: 1;
}
.controls-folder > .head > h4::before {
	content: "▸";
	padding-right: 0.5em;
}
.controls-folder.open > .head > h4::before {
	content: "▾";
}
.controls-folder .head .help-button {
	font-size: 0.7em;
	width: 2em;
	height: 2em;
	background: #446;
}

/* module rows */

.controls-folder-row {
	display: flex;
	border-bottom: 1px solid var(--row-sep-color);
	align-items: center;
}
.controls-folder-row > label:first-child {
	flex-shrink: 0;
	width: 7em;
	display: inline-block;
	padding: 0.3em 0.4em 0.2em 0.4em;

	font-size: 0.9em;
	font-family: var(--font-square), serif;
	letter-spacing: 0.01em;
	align-self: start;
}
.controls-folder-row > div {
	display: inline-flex;
	width: 100%;
	gap: 0.3em;
	margin-right: 0.3em;
}

/* inputs */

.controls input,
.controls select {
	background: var(--input-bg);
}

.controls input[type="number"],
.controls input[type="color"],
.controls input[type="text"],
.controls select {
	border: 1px solid #423;
	font-size: 0.8em;
	color: #fff;
	padding: 0.25em 0.25em;
}

.controls select {
	flex-grow: 1;
}

.controls input[type="submit"],
.controls button {
	border: 1px solid #534;
	font-size: 0.8em;
	color: #fff;
	padding: 0.25em 0.25em;
	background: #667;
	border-radius: 3px;
	cursor: pointer;
}
.controls button.square {
	width: 2em;
}

/* checkboxes */

.controls-folder-row > * label.checkbox {
	margin-right: 10px;
	font-size: 0.8em;
}
.controls label.checkbox input {
	margin-right: 3px;
}

.controls input[type="checkbox"] {
	-webkit-appearance: none;
	appearance: none;
	border: 1px solid var(--checkbox-border);
	font-size: 1.3em;
	width: 1em;
	height: 1em;
	display: inline-grid;
	place-content: center;
	vertical-align: center;
}
.controls input[type="checkbox"]::before {
	content: "";
	width: 0.6em;
	height: 0.6em;
	transform: scale(0);
	transition: 30ms transform ease-in;
	box-shadow: inset 1em 1em #cbd;
}
.controls input[type="checkbox"]:checked::before {
	transform: scale(1);
}

.controls .mark {
	position: relative;
	left: -2em;
	top: -0.4em;
	font-size: 0.7em;
	width: 0;
	height: 0;
	overflow: visible;
	text-wrap: nowrap;
}

/* sliders */

.controls-slider-row {
	display: flex;
	column-gap: 5px;
	flex-grow: 1;
}

.controls-slider-row input[type="range"] {
	flex-grow: 2;
	width: 6em; /* give it a small min width to let flex do its work */
}
.controls-slider-row input[type="number"] {
	width: 6em;
}
.controls input[type="range"] {
	background: transparent;
}
.controls input[type="range"]::-moz-range-track {
	width: 100%;
	height: 3px;
	cursor: pointer;
	background: var(--slider-track);
	border-radius: 1px;
	border: 0;
}
.controls input[type="range"]::-moz-range-thumb {
	border: 1px solid #000000;
	border-radius: 3px;
	height: 17px;
	width: 6px;
	background: var(--slider-thumb);
	cursor: pointer;
}

.controls .controls-vertical-sliders {
	padding: 0.5em 0;
	flex-direction: row !important;
}
.controls-vertical-sliders input {
	writing-mode: vertical-lr;
	direction: rtl;
	appearance: slider-vertical;
	width: 13px;
	vertical-align: bottom;
	height: 6em;
}
.controls-vertical-sliders input[type="range"]::-moz-range-track {
	width: 3px;
	height: 100%;
}
.controls-vertical-sliders input[type="range"]::-moz-range-thumb {
	height: 4px;
	width: 10px;
}

/* color picker */

.color-picker input[type="color"] {
	padding: 0;
	height: 2em;
}
.color-picker input[type="text"] {
	width: 6em;
	height: 2em;
	margin-left: 0.5em;
	font-family: monospace;
	font-size: 1em;
}

/* inputs : misc */

.controls input:focus {
	/* at the end to override things */
	border: 1px solid #84e;
}

.controls .help {
	font-size: 0.7em;
	font-weight: bold;
	padding: 0 0.3em 0.25em 0.3em;
	vertical-align: super;
	line-height: 100%;
	color: #eef;
}

.controls .modeselektor {
	display: flex;
	align-items: center;
}
.controls .modeselektor + div:not(:empty) {
	margin-top: 0.25em;
	display: flex;
	flex-direction: column;
}
.controls .modeselektor label {
	align-items: center;
}

.row-slider {
	display: flex;
	gap: 0.25em;
}
.row-slider number {
	margin-right: 0;
}

/* help book */

.hb {
	display: none;
	position: absolute;
	inset: 0;
	align-items: center;
	justify-content: center;
}
.hb-overlay {
	inset: 0;
	position: absolute;
	background: #00000060;
	z-index: 200000;
}
.hb-window {
	width: 60em;
	height: 80vh;
	min-height: 20em;
	border: 1px solid #999;
	z-index: 200010;
	display: flex;
	flex-direction: row;
}
.hb-menu {
	font-size: 0.8em;
	background: #333;
	width: 11em;
	border-right: 1px solid #666;
	flex-grow: 0;
	flex-shrink: 0;
	font-family: var(--font-square), serif;
}
.hb-menu label {
	width: 100%;
	display: block;
	text-align: left;
	border-bottom: 1px solid #444;
}
.hb-menu label span {
	padding: 0.4em 0.5em 0.3em 0.5em;
	display: block;
	cursor: pointer;
	line-height: 110%;
}
.hb-menu label input {
	display: none;
}
.hb-menu input:checked + span {
	background: #555;
}
.hb-main {
	display: flex;
	flex-direction: column;
	width: 100%;
}
.hb-title {
	display: flex;
	background: #1e1e1e;
	border-bottom: 1px solid #666;
}
.hb-title h2 {
	margin: 0.5em 2em;
	flex-grow: 1;
	text-align: left;
}
.hb-title .close {
	width: 1.2em;
	height: 1.2em;
	line-height: 1;
	background: transparent;
	color: #ccc;
	border: 0;
	font-size: 2em;
	cursor: pointer;
}
.hb-content {
	flex-grow: 1;
	background: #222;
	padding: 0.5em 1em;
	text-align: left;
	overflow: auto;
	line-height: 130%;
}
.hb-content p {
	margin: 0.75em 0;
}
.hb-content a {
	color: #aae;
}
.hb-content h2 {
	color: #eae;
	font-size: 1.5em;
	margin: 0 0 1em 0;
}
.hb-content h3 {
	color: #eae;
	font-size: 1.2em;
	margin: 1em 0 0.25em 0;
	border-bottom: 1px dotted #a9a;
}
.hb-content code {
	color: #c8c;
	font-family: monospace;
}
.hb-content code::before {
	content: " « ";
	color: #a9a;
	font-family: monospace;
}
.hb-content code::after {
	content: " » ";
	color: #a9a;
	font-family: monospace;
}
.hb-content em {
	color: #ebb;
	font-weight: bold;
	font-size: 1.03em;
}

/* misc */

canvas.debug {
	display: none;
	position: fixed;
	bottom: 0;
	left: 0;
	z-index: 10000;
	image-rendering: pixelated;
}
