:root{
	--midgray: #777777;
}
html,body{
	padding: 0;
	margin: 0;
	width: 100%;
	height: 100vh;
	background-color: var(--bg);
}
*{
	font-family: monospace;
	font-size: 16px;
	color: var(--fg);
}
a{
	color: #238dc1;
}
input, textarea, select, datalist{
	-moz-appearance: none;
	-webkit-appearance: none;
	appearance: none;
}
input, textarea, select, label[for=fileupload], .forCheckbox{
	padding: initial;
	border: 2px solid var(--border);
	background-color: var(--bg);
	padding: 7px;
	border-radius: 4px;
	display: inline-block;
	position: relative;
	margin: 0 2px;
	line-height: 24px;
}
input[type="checkbox"]{
	display: none;
}
input[type=checkbox] + .forCheckbox {
	color: var(--bg);
	height: 24px;
	width: 25px;
	font-size: 28px;
	padding: 2px;
	margin: 0;
	line-height: 25px;
}
input[type=checkbox]:checked + .forCheckbox {
	color: var(--fg);
}
input[type=checkbox] + .forCheckbox::after {
	content: " ";
}
input[type=checkbox]:checked + .forCheckbox::after {
	content: "✓";
}
input[type=submit]{
	cursor: pointer;
}
select{
	padding-right: 30px;
	background-image: var(--dropdown-arrow);
	background-repeat: no-repeat;
	background-position: 95% 50%;
	background-size: 11px 7px;
}
input[type=file]{
	letter-spacing: -1px;
	width: 270px;
}
input[type=file]::file-selector-button, input[type=file]::-webkit-file-upload-button {
	letter-spacing: -1px;
	background-color: var(--bg);
	color: var(--fg);
	border: 1px solid var(--fg);
	border-radius: 3px;
	font-family: monospace;
}
input[type=file]::file-selector-button:hover, input[type=file]::-webkit-file-upload-button:hover {
	background-color: var(--fg);
	color: var(--bg);
}
label[for=fileupload]{
	width: auto;
}
#uploadsubmit {
	display: flex;
	width: 385px;
}
#uploadsubmit > input[type=submit] {
	width: auto;
}
#uploadsubmit > label {
	width: 50%;
}
#uploadsubmit > input[type="submit"]:focus + label {
	display: none;
}
#uploadsubmit > input[type="submit"] {
	content: "Upload"
}
#uploadsubmit > input[type="submit"]:focus {
	width: 100%;
	content: "Uploading...";
	transition: .4s ease all!important;
}
/* For chrome/chromium browsers only */
input[type=file]{
	padding: 5px;
}
@-moz-document url-prefix() { /* Firefox doesn't show an arrow (nor the list by default) */
	.combolist{
		padding-right: 30px;
	}
	.combolist:hover, .combolist:active, .combolist:focus{
		background-image: var(--dropdown-arrow);
		background-repeat: no-repeat;
		background-position: 95% 50%;
		background-size: 11px 7px;
	}
	input[type=file]{
		padding: 7px;
	}
}
form {
	line-height: 50px;
	display: flex;
	gap: 5px;
}

iframe{
	padding: 0;
	border: 0;
	background: transparent;
}
code {
	padding: 3px;
	background-color: var(--code);
	border-radius: 3px;
}
#motd{
	padding: 1em;
	max-width: 53em;
}

/* Settings */

iframe#settings-frame {
	z-index: 2;
	position: fixed;
	bottom: 0;
	height: 310px;
	width: 185px;
	right: 0;
}
#settings {
	position: absolute;
	text-align: right;
	z-index: 1;
	right: 0;
	bottom: 0;
	border: 0;
	line-height: initial;
}

#settings_options, #checkshow{
	display:none;
}

#checkshow, #checkshow + label{
	cursor: pointer;
}
#checkshow + label{
	margin-right: 25px;
	font-size: 50px;
}
#checkshow + label:before {
	content:" ";
}
#checkshow + label:after {
	content:"≡";
}

#checkshow:checked + label {
	background-color: transparent;
	font-size: inherit;
	line-height: 55px;
}
#checkshow:checked + label:before {
	content:" ";
	color: var(--close);
}
#checkshow:checked + label:after {
	content:"Close";
	color: var(--close);
	font-size: 16px;
}

#checkshow:checked + label + #settings_options {
	display: grid;
	padding: 11px 8px;
	grid-gap: 5px;
	grid-template-columns: 100px 1fr;
	align-items: center;
	background: var(--settings);
	border-top: 2px solid var(--border);
	border-left: 2px solid var(--border);
	border-top-left-radius: 3px;
}

#settings-save {
	grid-column: span 2;
}

/* Page-specific styles */

/* Login page */

#logo{
	z-index: 1;
	position: absolute;
	bottom: 0.7rem;
	left: 1rem;
	display: grid;
	justify-content: center;
	align-items: center;
	gap: 0.5rem;
	text-decoration: none !important;
	padding: 5px;
	grid-auto-flow: column;
}
#logo img{
	height: 2rem;
	filter: invert(1) brightness(0.5);
}
#logo span{
	font-size: 0.8rem;
	color: var(--midgray);
}
#login {
	display: flex;
	flex-direction: column;
	justify-content: space-evenly;
	align-items: center;
	height: 100vh;
	padding: 0px;
	line-height: 1.75em;
}
#loginform{
	display: grid;
	gap: 5px;
	grid-auto-flow: column;
	grid-template-columns: auto;
	grid-template-rows: 20px auto;
	justify-items: left;
	align-items: center;
}
.corners{
	padding: 1rem;
	background: var(--bg);
	display: grid;
	justify-content: space-between;
	align-items: center;
	gap: 30px;
	grid-auto-flow: column;
	grid-auto-columns: 33% 33% 33%;
	border-top: 1px solid #00000020;
}
.corners > :first-child {
	text-decoration: none;
	display: grid;
	justify-content: center;
	align-items: center;
	grid-auto-flow: column;
	gap: 12px;
}
.subtle{
	opacity: 0.6;
}
label[for=room]{
	grid-column-start: 3;
	grid-column-end: 5;
}

/* Message posting page */
iframe#post-frame{
	z-index: 1;
	position: relative;
	height: 60px;
	width: 100%;
	margin: 0 auto;
}
#post{
	display: flex;
	align-items: center;
	height: 100%;
	width: calc( 300px + 50vw );
	max-width: calc( 100% - 20px );
	margin: 0 auto;
	left: -8px;
	position: relative;
}
#upload{
	margin: 0 auto;
	display: flex;
	justify-content: center;
	align-items: center;
	height: 100%;
}


/* Chat messages page */

iframe#chat-frame{
	height: 100vh;
	width: 100%;
	position: absolute;
	left: 0;
	top: 0;
}

#chat{
	width: calc( 300px + 50vw );
	max-width: calc( 100% - 20px );
	margin: 60px auto 10px auto;
	display: flex;
	flex-direction: column-reverse;
}

.message {
	padding: 8px 5px;
	border-top: 1px solid var(--message-separator);
	display: flex;
}

.message.self > .message-text {
	opacity: 0.85;
	word-wrap: break-word;
}

.message-text {
	overflow-wrap: anywhere;
}

.message span {
	margin-right: 10px;
}

.tripcode {
	opacity: 0.4;
}

.message:not(.self) > .handle{
	color: var(--handle-color);
}

.message.self > .handle{
	color: var(--self-color)
}
.message:hover{
	background-color: var(--bg-alt);
}

.filedownload{
	display: grid;
	grid-auto-flow: row;
	justify-content: center;
	padding: 0px;
}

.message .filedownload > span {
	margin: 0 0 -7px 0;
	min-width: 0px;
	position: absolute;
	opacity: 0;
	font-size: 14px;
}
.message .filedownload:target > span {
	position: fixed;
	margin-bottom: 0px;
	color: white;
	z-index: 1;
	width: 100%;
	height: initial;
	left: 0;
	bottom: 9px;
	text-align: center;
	opacity: 1;
	transition: 0.3s ease all;
}

.message .filedownload > a > img, .message .filedownload video {
	/* margin-top: 5px; */
	max-width: 20rem;
	max-height: 20rem;
}

.message .filedownload img,.message .filedownload video,.message .filedownload audio {
	border-radius: 4px;
}
.message .filedownload img {
	cursor: pointer;
}
@keyframes popIn {
	from {
		max-width: 0;
		max-height: 0;
		opacity: 0;
	}
	to {}
}
.message .filedownload:target a.previewOpen img {
	max-width: calc(100vw - 130px);
	max-height: calc(100vh - 130px);
	position: fixed;
	margin: 0;
	display: block;
	left: 50%;
	top: calc(50% + 30px);
	transform: translate(-50%,-50%);
	cursor: initial;
	border-radius: 0px;
	animation: 0.3s popIn ease 1;
	/* animation-timing-function: cubic-bezier(0.25,0.1,0.25,1.5); */
}
.message .filedownload a.previewClose {
	pointer-events: none;
	cursor: unset;
	display: none;
	position: fixed;
	margin: 0;
	background: rgba(0,0,0,0.45);
	transition: 0.2s;
	width: 100vw;
	height: 100vh;
	top: 0;
	left: 0;
	transition: 0.2s ease opacity;
	opacity: 0;
	min-width: 100vw;
	min-height: 100vh;
}
@keyframes fadeIn {
	from {opacity: 0;}
	to {opacity: 1;}
}
.message .filedownload:target a.previewClose {
	pointer-events: initial;
	display: block;
	opacity: 1;
	animation: fadeIn 0.2s 1;
}
.message .filedownload:target {
	z-index: 1;
}
.message > div {
	display: flex;
	flex-direction: column;
	flex-grow: 0;
}

.message.system .message-text {
	color: var(--system-color);
}

.filedownload + .message-text {
	margin-top: 10px;
}

.error-message {
	display: flex;
	justify-content: center;
	align-items: center;
	height: 100%;
}

#messagebox{
	width: 100%;
	float: left;
}

@media only screen and (max-width: 1200px) {
	form {
		gap: 0px;
	}
	#loginform > label {
		padding-top: 15px;
		padding-left: 2px;
	}
	#loginform > input {
		width: 230px;
	}
	#loginform > input[type="submit"] {
		width: 252px;
	}
	#loginform {
		display: grid;
		gap: 15px;
		grid-auto-flow: column;
		grid-template-columns: auto;
		grid-template-rows: 10px auto 10px auto 10px auto auto;
		justify-items: left;
		align-items: center;
	}
	label[for="room"]{
		grid-column-start: initial;
		grid-column-end: initial;
	}
	.combolist {
		padding-right: 10px;
		width: 140px;
	}
	.corners{
		gap: 20px;
	}
	.corners > :first-child {
		text-decoration: none;
		display: inline-block;
	}
	.corners > a > img{
		width: 15px;
	}
	.chat{
		font-size: 14px;
	}
	input[type=file]{
		height: 24px;
		padding: 7px 0 7px 5px;
		width: 100%;
        text-overflow: unset;
	}
	@supports (font: -apple-system-body){
		input[type=file]{
			line-height: 58px;
		}
	}
	input[type=file]::file-selector-button, input[type=file]::-webkit-file-upload-button {
		display: none;
	}
	#uploadsubmit {
		display: flex;
		width: 240px;
	}
	@-moz-document url-prefix() { /* Firefox doesn't show an arrow (nor the list by default) */
		#uploadsubmit {
			width: 155px;
		}
	}
	form#post * {
		font-size: 14px;
	}
}

/* Smaller text for smaller screen */
@media only screen and (max-width: 600px) {
	*{
		font-size: 14px;
	}
	div#post-frame-parent{
		grid-template-columns: calc(100% - 210px) 130px;
	}
	.message {
		padding: 7px 5px;
	}
	.message .filedownload > :nth-child(2) {
		max-width: 100%;
		max-height: 100%;
	}
}

