* {
	box-sizing: border-box;
	position: relative;
	margin: 0;
	padding: 0;
}

:root {
	--font: sans-serif;
	--title-font: serif;

	--black: #111;
	--white: #eee;
	--blue: blue;

	--background: var(--white);
	--text-color: var(--black);
}

html {
	font-size: 16px;
	font-family: var(--font);
}
body {
	background: var(--background);
	color: var(--text-color);
}

/* -------------------- */
/* Home */
/* -------------------- */

.feed {
	padding-block: 2rem;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
	gap: 1rem;
}
.snippet {
	padding: 1rem;

	display: flex;
	flex-direction: column;
	align-items: flex-start;

	border: 1px solid var(--text-color);
	border-radius: 2px;
}

/* -------------------- */
/* Editor */
/* -------------------- */

.editor-page {
	--border-color: var(--text-color);

	width: 100%;
	height: 100vh;

	display: grid;
	grid-template-columns: 3fr 1fr;
	overflow: hidden;
}
.editor-container, .editor-sidebar {
	> div:not(:last-child) {
		border-bottom: 1px solid var(--border-color);
	}
}
.editor-container {
	height: 100%;

	display: flex;
	flex-direction: column;

	border-right: 1px solid var(--border-color);

	#editor-wrapper {
		flex: 1 0 auto;
		display: flex;
		flex-direction: column;

		.CodeMirror {
			flex: 1 0 auto;
		}
	}
}
.editor-sidebar {
	min-width: 300px;

	display: flex;
	flex-direction: column;

	.comments {
		padding: .5rem;

		display: flex;
		flex-direction: column;
		gap: .5rem;
		overflow-y: scroll;

		#comments-list {
			display: flex;
			flex-direction: column;
		}
	}

	#editor-problems {
		padding: .5rem;
		min-height: 50%;

		display: flex;
		flex-direction: column;

		.info {
			animation: info-fade both 3s;
		}
		.error { color: #fb4934; }
		.note { city: 1; color: #8ec07c; }
	}
}
@keyframes info-fade {
	0%, 80% { opacity: 1; }
	100% { opacity: .25; }
}

#display-window {
	padding: .5rem;

	position: fixed;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: .5rem;
	z-index: 2;

	background: var(--background);
	border: 1px solid var(--border-color);
	border-radius: 2px;
	outline: none;

	canvas {
		outline: 1px solid var(--border-color);
		image-rendering: pixelated;
		cursor: none;
	}
	.display-stats {
		display: flex;
		align-items: center;
		user-select: none;
		line-height: 80%;
	}

	&:focus {
		border-color: var(--blue);
	}
}

.statusbar {
	min-height: 38px;
	padding: .25rem .75rem;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	text-wrap: nowrap;

	form {
		display: flex;
		align-items: center;
		gap: .25rem;
	}
	button {
		padding: .1em .5em;
		&[type=submit] { margin-left: .5rem; }
	}
	input { width: 220px; padding: .1em 0; }
}
.stats {
	font-family: monospace;
	font-size: .8rem;
	opacity: .5;
}

.CodeMirror {
	--selection: var(--blue);

	font-size: 1.1rem;

	.CodeMirror-lines {
		padding: 1rem;
		padding-bottom: 50vh;
	}
	.CodeMirror-vscrollbar {
		z-index: 1;
		visibility: visible !important;
	}
	.CodeMirror-sizer {
		min-width: unset !important;
	}
}
.CodeMirror, .CodeMirror-gutters {
	background: var(--background);
	color: var(--text-color);
}
.CodeMirror-gutters     { border-right: none; }
.CodeMirror-linenumber  { color: rgba(0,0,0,.5); }
.CodeMirror-cursor      { border-left: 2px solid var(--selection); }
div.CodeMirror-selected { background: var(--selection) !important; }
.cm-tab {
	background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAMCAYAAAC5tzfZAAAAAXNSR0IB2cksfwAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAAuIwAALiMBeKU/dgAAAAd0SU1FB+oDCBYoEKFeoXcAAAAbSURBVCjPY2AYFuA/xRoZyTCJkaZO/M8wzAEAjfkE/pkJeVwAAAAASUVORK5CYII=);
	background-position: left;
	background-repeat: no-repeat;
	opacity: .5;
}
.cm-trailingspace {
	background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAACCAYAAAB/qH1jAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3QUXCToH00Y1UgAAACFJREFUCNdjPMDBUc/AwNDAAAFMTAwMDA0OP34wQgX/AQBYgwYEx4f9lQAAAABJRU5ErkJggg==);
	background-position: bottom left;
	background-repeat: repeat-x;
}

/* -------------------- */
/* Global */
/* -------------------- */

.container {
	width: 100%;
	max-width: 800px;
	padding: 0 10px;
	padding-top: 3rem;

	display: flex;
	flex-direction: column;
	margin: 0 auto;
}

#loader {
	width: 100%;
	height: 100%;

	z-index: 10;
	position: fixed;
	left: 0;
	top: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	text-align: center;

	background: var(--background);

	transition: .1s;

	&.hidden {
		opacity: 0;
		pointer-events: none;
	}
}

h1, h2, h3, h4 {
	font-family: var(--title-font);
}

a {
	text-decoration: none;
	color: blue;
	&:hover { text-decoration: underline; }
}

hr {
	width: 100%;
	height: 1px;
	border: none;
	background: var(--text-color);
	opacity: .5;
}

.form {
	width: 100%;

	display: flex;
	flex-direction: column;
	gap: .5rem;

	button[type=submit] {
		width: 100%;
		margin-top: auto;
	}
}
form.htmx-request button[type=submit] {
	opacity: .5;
	pointer-events: none;
}
input {
	width: 100%;
	padding: .4em 0;

	font-family: var(--font);
	font-size: 1rem;
	background: transparent;
	color: var(--text-color);
	border: none;
	border-bottom: 1px dotted var(--text-color);
	outline: none;

	&::placeholder {
		color: rgba(0, 0, 0, .5);
	}

	&:focus {
		border-bottom-style: solid;
	}
}
.button {
	padding: .25em .5em;

	font-family: var(--font);
	font-size: 1rem;
	background: var(--black);
	border: none;
	color: var(--white);
	border-radius: 2px;
	font-weight: 500;

	cursor: pointer;

	&:active {
		translate: 0 1px;
	}
	&.active {
		background: blue;
	}

	&.htmx-request {
		pointer-events: none;
		opacity: 0.5;
	}
}
button {
	text-wrap: nowrap;
}
textarea {
	width: 100%;
	padding: .5em;

	font-family: var(--font);
	font-size: 1rem;
	border: 1px solid rgba(0,0,0,.5);
	background: white;
	color: var(--text-color);
	resize: vertical;
	border-radius: 2px;
	outline: none;

	&:focus {
		border-color: var(--text-color);
	}
}
label > span {
	opacity: .5;
	font-size: .8rem;
}

.link-ish {
	cursor: pointer;
	color: inherit;
	&:hover { text-decoration: underline; }
}
button.link-ish {
	padding: 0;

	font-family: var(--font);
	font-size: 1rem;
	border: none;
	background: transparent;
}

.text-muted {
	opacity: .5;
}

/* -------------------- */
/* Utils */
/* -------------------- */

.flex {
	display: flex;
}
.flex-column {
	display: flex;
	flex-direction: column;
}
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.gap-4 { gap: 2rem; }
.gap-5 { gap: 2.5rem; }
.gap-6 { gap: 3rem; }
.width-fill { width: 100%; }
.height-fill { height: 100%; }
