*, *::before, *::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
	font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI',
				Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans',
				'Helvetica Neue', sans-serif;
	font-size: 1rem;
	-webkit-tap-highlight-color: transparent;
}

:root {
	--color-light: #ffffff;
	--color-light-gray: #6b6b6b;
	--color-mid-gray: #5c5c5c;
	--color-gray: #232323;
	--color-dark: #111111;

	--color-changed: #b87000;
	--color-error: #db5461;
	--color-dim-error: #bc4551;
	--color-success: #54db68;
	--color-dark-border: rgba(152, 152, 152, 0.08);
	--color-light-border: rgba(255, 255, 255, 0.08);

	--global-font-size: 15px;
	--header-height: 3.25rem;
	--nav-width: 15rem;
	--nav-show-speed: 300ms;
	--nav-button-spacing: .5rem;
	--scrollbar-width: 10px;
	--dialog-header-height: 3.2rem;

	--window-slide-duration: 500ms;
	--dyn-spacing: clamp(.5rem, 2vw, 1rem);
	--playful-curve: cubic-bezier(0.87, 0, 0.13, 1);
	--default-shadow:
		0 1px 2px 0 rgb(0 0 0 / 60%),
		0 2px 6px 2px rgb(0 0 0 / 30%);
}

/*  */
/* Default styling */
/*  */
html {
	font-size: var(--global-font-size);
}

dialog {
	margin: auto;
	overscroll-behavior: contain;
}

img {
	width: 100%;
}

button,
label {
	border: 0;
}

button:hover,
label:hover {
	cursor: pointer;
}

input::placeholder,
textarea::placeholder {
	color: var(--color-light-gray);
}

input[type="datetime-local"] {
	color-scheme: dark;
}

svg {
	fill: var(--color-light);
}

a {
	color: var(--color-light);
}

a[target="_blank"]::after {
	content: "_↗"
}

table {
	border-spacing: 0px;
}

::-webkit-scrollbar {
	/* For vertical scrollbars */
	width: var(--scrollbar-width);
	/* For horizontal scrollbars */
	height: var(--scrollbar-width);
	background-color: var(--color-dark);
}

::-webkit-scrollbar-thumb {
	-webkit-border-radius: 6px;
	background-color: var(--color-gray);
}

::-webkit-scrollbar-thumb:hover {
	background-color: var(--color-light-gray);
}

@keyframes appear-dialog {
	from {
		opacity: 0;
		translate: 0 -5%;
	}
	to {
		opacity: 1;
		translate: 0 0;
	}
}

@keyframes vanish-dialog {
	from {
		display: block;
		opacity: 1;
		translate: 0 0;
	}
	to {
		display: none;
		opacity: 0;
		translate: 0 -5%;
	}
}

@keyframes appear-dialog-bg {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

dialog {
	--ani-duration: 100ms;
	--max-height: 23rem;
	--max-width: 40rem;

	width: min(100%, var(--max-width));
	height: min(100%, var(--max-height));

	border-radius: 6px;
	border: 4px solid var(--color-gray);
	background-color: var(--color-dark);
	color: var(--color-light);

	box-shadow: 0px 0px 20px 5px rgba(0 0 0 / 0.8);

	animation: vanish-dialog var(--ani-duration);
}

dialog[open] {
	animation: appear-dialog var(--ani-duration);
}

dialog::backdrop {
	backdrop-filter: blur(3px);
}

dialog[open]::backdrop {
	animation: appear-dialog-bg var(--ani-duration);
}

/*  */
/* Utility classes */
/*  */
.hidden {
	display: none !important;
}

.error {
	color: var(--color-error) !important;
	font-size: 1rem !important;
}

.error-input {
	border: 2px solid var(--color-error) !important;
}

.success {
	color: var(--color-success) !important;
	font-size: 1rem !important;
}

button.spinning svg,
svg.spinning {
	animation: spin-element 2.5s linear infinite forwards;
}

@keyframes spin-element {
	from { transform: rotate(0deg) }
	to { transform: rotate(360deg) }
}

:where(input, textarea, select, button, div, label).input-style {
	height: 2.7rem;
	width: 100%;

	border: 2px solid var(--color-gray);
	border-radius: 4px;
	outline: 0;
	background-color: var(--color-dark);
	color: var(--color-light);

	box-shadow: var(--default-shadow);
	transition: background-color 150ms ease-in-out;

	font-size: 1rem;

	&:focus-within {
		border-color: var(--color-light-gray);
	}
}

:where(input, textarea, select, button, label).input-style,
div.input-style > :where(input, p) {
	padding: .5rem;
}

button:has(> svg).input-style {
	display: flex;
	justify-content: center;
	align-items: center;
}

button.input-style > svg {
	height: 1.3rem;
	aspect-ratio: 1/1;
}

div.input-style {
	width: fit-content;
	display: flex;
	align-items: center;

	& > input {
		width: 100%;
		height: 100%;

		border: 0;
		outline: 0;
		background-color: var(--color-dark);
		color: var(--color-light);
	}
}

button.input-style:hover {
	background-color: var(--color-gray);
}

div.input-style > input[type="number"],
input[type="number"].input-style {
	max-width: 6rem;
}

div.input-style > input[type="file"],
input[type="file"].input-style {
	max-width: 20rem;
}

div.input-style > :where(input[type="text"], select),
:where(input[type="text"], select).input-style {
	max-width: 16rem;
}

button.input-style {
	max-width: 16rem;
}

:where(input, textarea, select, button).long-input-style,
div.long-input-style > input {
	max-width: 25rem;
}

.checked-input-container {
	position: relative;
	height: 100%;
	max-height: 2.7rem;
	width: 100%;
	max-width: 16rem;

	transition: max-height 50ms ease-in-out,
				border-color 50ms ease-in-out;
}

.checked-input-container.error-input-container {
	max-height: 4.1rem;
}

.checked-input-container.error-input-container input {
	border-color: var(--color-error);
}

.checked-input-container :where(input, textarea) {
	position: relative;
	z-index: 1;
}

.checked-input-container p {
	position: absolute;
	bottom: 0;
	height: 1.9rem;
	width: 100%;

	border-bottom-left-radius: 4px;
	border-bottom-right-radius: 4px;
	border: 2px solid var(--color-error);
	padding: .6rem .65rem .3rem .65rem;
	background-color: var(--color-dim-error);
	color: var(--color-light);

	font-size: .7rem;
}

.test-button {
	display: flex;
	gap: 1rem;

	overflow-x: hidden;

	& > div {
		margin-block: auto;

		width: 100%;
		flex: 0 0 auto;

		font-size: inherit;

		transition: transform 100ms linear;
	}

	&.show-sent > div {
		transform: translateX(calc(-100% - 1rem));
	}
}

.table-container {
	width: 100%;
	overflow: auto;
}

.entries-table {
	--inline-padding: 1.5rem;

	position: relative;

	padding-inline: var(--inline-padding);
}

.entries-table::before {
	content: "";
	position: absolute;
	inset: 0 auto 0 var(--inline-padding);

	width: 1.4rem;
	background: linear-gradient(90deg, var(--color-dark), transparent);
}

.entries-table::after {
	content: "";
	position: absolute;
	inset: 0 var(--inline-padding) 0 auto;

	width: 1.4rem;
	background: linear-gradient(270deg, var(--color-dark), transparent);
}

.entries-table > tbody > tr {
	transition: background-color 200ms ease-in-out;

	&:hover {
		background-color: var(--color-gray);
	}
}

.entries-table :where(th, td) {
	height: 2.65rem;
	padding: .25rem .5rem;
	text-align: left;
}

.entries-table td {
	border-top: 1px solid var(--color-gray);
}

.entries-table :where(th, td):first-child {
	padding-left: 2rem;
}

.entries-table :where(th, td):last-child {
	padding-right: 2rem;
}

.entries-table td:last-child:has(button) {
	display: flex;
	align-items: center;
	gap: .75rem;
}

.entries-table td:last-child button {
	height: 1.25rem;
	background-color: transparent;
}

.entries-table svg {
	aspect-ratio: 1/1;
	height: 100%;
	width: auto;
}

.collapse-table {
	--min-width: 20rem;
	--max-width: 55rem;
	--header-width: 50%;
	--min-data-width: 25rem;

	width: clamp(var(--min-width), 100%, var(--max-width));

	padding-inline: 1rem;
}

.collapse-table tr:first-of-type :where(th, td) {
	padding-top: 1rem;
}

.collapse-table :where(th, td) {
	--middle-spacing: .75rem;
	padding-bottom: 1rem;
	vertical-align: top;

	&:first-child {
		width: var(--header-width);
		padding-right: var(--middle-spacing);
		text-align: right;

		& > label {
			display: flex;
			justify-content: flex-end;
			height: 2.7rem;
		}
	}

	&:last-child {
		min-width: var(--min-data-width);
		padding-left: var(--middle-spacing);
	}

	& > p {
		margin-top: .25rem;

		color: var(--color-light-gray);

		font-size: .9rem;
	}
}

.collapse-table tr:not(:has(input[type=checkbox])) > th > label {
	align-items: center;
}

.dialog-container {
	height: 100%;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
}

.dialog-header, .dialog-footer {
	height: var(--dialog-header-height);

	display: flex;
	align-items: center;
	gap: 1rem;
	flex: 0 0 auto;

	padding: .4rem .75rem;

	&.dialog-header {
		justify-content: flex-start;
		border-bottom: 2px solid var(--color-gray);
	}

	&.dialog-footer {
		justify-content: flex-end;
		border-top: 2px solid var(--color-gray);
	}
}

.dialog-header h2 {
	padding: 0;
	border-bottom: 0;
}

.dialog-footer button,
.confirm-container > button {
	width: 5rem;
	height: 2.3rem;
	padding: 0;

	&:first-of-type:where(:hover, :focus-within) {
		background-color: var(--color-dim-error);
	}

	&:last-of-type:where(:hover, :focus-within) {
		background-color: var(--color-success);
	}
}

.dialog-content {
	flex-grow: 1;

	display: flex;
	flex-direction: column;
	justify-content: space-around;
	align-items: center;
	gap: 1rem;
}

.dialog-container:has(.dialog-header, .dialog-footer) .dialog-content {
	height: calc(100% - var(--dialog-header-height) * 2);
	overflow-y: auto;
}

.confirm-container {
	display: flex;
	flex-direction: row-reverse;
	gap: 1rem;
}

.confirm-container > button {
	width: 6rem;

	&:first-of-type:where(:hover, :focus-within) {
		background-color: var(--color-success);
	}

	&:last-of-type:where(:hover, :focus-within) {
		background-color: var(--color-dim-error);
	}
}

.popover {
	position: absolute;
	bottom: anchor(top);
	justify-self: anchor-center;

	margin-bottom: .5rem;
	margin-inline: .5rem;

	padding: .25rem .5rem;
	border-radius: 6px;
	background-color: var(--color-error);

	box-shadow: var(--default-shadow);
}

.popover::after {
	content: "";

	position: absolute;
	inset: 100% auto auto calc(50% - .5rem);
	/* Bug in Chrome makes anchor positioning of pseudo elements
	not work correctly. Currently shows arrow centered below popover.
	Should show arrow centered above anchor. */
	/* left: anchor(center); */
	top: 100%;

	border-top: .5rem solid var(--color-error);
	border-inline: .5rem solid transparent;
}

/*  */
/* General styling */
/*  */
body {
	height: 100dvh;
	overflow-x: hidden;

	display: flex;
	flex-direction: column;

	background-color: var(--color-dark);
	color: var(--color-light);
}

noscript {
	display: block;
	max-width: 95%;
	margin-inline: 1rem;
	margin-bottom: 1rem;

	border-radius: 4px;
	padding: 1rem;
	background-color: var(--color-error);
	color: var(--color-light);

	text-align: center;
}

header {
	width: 100%;
	height: var(--header-height);
	flex: 0 0 auto;

	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 1rem;

	padding: .25rem var(--dyn-spacing);
	border-bottom-left-radius: 6px;
	border-bottom-right-radius: 6px;
	border-bottom: 1px solid var(--color-light-border);
	background-color: var(--color-gray);

	box-shadow: var(--default-shadow);
}

header > div:first-child {
	display: flex;
	align-items: center;
	gap: 1rem;
}

header > div > img {
	height: calc(var(--header-height) * 0.6);
	width: fit-content;
	cursor: pointer;
}

header h1 {
	font-size: 1.5rem;
	text-align: center;
}

@media (prefers-reduced-motion) {
	* {
		animation-duration: 0ms !important;
		transition-duration: 0ms !important;
	}
}

@media (max-width: 34rem) {
	:root {
		--window-slide-duration: 200ms;
		--scrollbar-width: 4px;
	}
}

@media (max-width: 29rem) {
	.collapse-table tbody {
		display: flex;
		flex-direction: column;
	}

	.collapse-table tr {
		display: inline-flex;
		flex-direction: column;
		padding-left: .5rem;
	}

	.collapse-table tr:first-of-type > td {
		padding-top: 0rem;
	}

	.collapse-table :where(th, td) {
		width: 100%;

		&:first-child {
			width: 100%;
			text-align: left;

			& > label {
				justify-content: flex-start;
			}
		}

		&:last-child {
			min-width: unset;
		}
	}

	dialog {
		margin: 0;
		width: 100%;
		height: 100%;
		max-width: 100vw;
		max-height: 100vh;

		border-radius: 0;
		border: 0;
	}

	@keyframes appear-dialog {
		from {
			opacity: 0;
		}
		to {
			opacity: 1;
		}
	}

	@keyframes vanish-dialog {
		from {
			display: block;
			opacity: 1;
		}
		to {
			display: none;
			opacity: 0;
		}
	}
}
