:root {
	--radius: 16px;
	--boxShadow1: rgba(0, 0, 0, 0.18) 0 2px 1px -1px, rgba(0, 0, 0, 0.12) 0 1px 1px 0, rgba(0, 0, 0, 0.1) 0 1px 3px 0px;
}

@media (prefers-color-scheme: light) {
	:root {
		--color4xxBackground: #ffedd1;
		--colorAccent: #0b61ec;
		--colorBackground: #fff;
		--colorComboBoxHeaderBackground: #fff;
		--colorComboBoxBackground: #eee;
		--colorHeaderBackground: #efefef;
		--colorSecondaryButtonBackground: #fcfcfc;
		--colorSecondaryActionBorder: #ddd;
		--colorSecondaryAction: #666;
		--colorDisabledMockSelector: #444;
		--colorHover: #dfefff;
		--colorLabel: #555;
		--colorLightRed: #ffe4ee;
		--colorRed: #da0f00;
		--colorText: #000;
	}
	.syntaxPunc {
		color: var(--colorSecondaryAction);
	}
	.syntaxKey, .syntaxTag {
		color: #ed206a
	}
	.syntaxVal, .syntaxAttr {
		color: #9b71e8
	}
	.syntaxStr, .syntaxAttrVal {
		color: #388E3C
	}
}
@media (prefers-color-scheme: dark) {
	:root {
		--color4xxBackground: #403630;
		--colorAccent: #2495ff;
		--colorBackground: #181818;
		--colorHeaderBackground: #111;
		--colorComboBoxBackground: #2a2a2a;
		--colorSecondaryButtonBackground: #2a2a2a;
		--colorSecondaryActionBorder: #333;
		--colorSecondaryAction: #aaa;
		--colorComboBoxHeaderBackground: #222;
		--colorDisabledMockSelector: #b9b9b9;
		--colorHover: #023661;
		--colorLabel: #aaa;
		--colorLightRed: #ffe4ee;
		--colorRed: #f41606;
		--colorText: #fff;
	}
	.syntaxPunc {
		color: var(--colorSecondaryAction);
	}
	.syntaxKey, .syntaxTag {
		color: #f92672
	}
	.syntaxVal, .syntaxAttr {
		color: #ae81ff
	}
	.syntaxStr, .syntaxAttrVal {
		color: #a6e22e
	}
}

html,
body {
	overflow: hidden;
	height: 100%;
	padding: 0;
	margin: 0;
	background: var(--colorHeaderBackground);
	font-size: 12px;
}
body {
	display: grid;
	grid-template-rows: auto 1fr;
	background: var(--colorBackground);
	color: var(--colorText);
	font-family: system-ui, sans-serif;
}

* {
	box-sizing: border-box;
	padding: 0;
	border: 0;
	margin: 0;
	font-family: inherit;
	font-size: 100%;
	outline: 0;
	scrollbar-width: thin;
}

select, a, input, button {
	&:focus {
		outline: 2px solid var(--colorAccent);
	}
}

a {
	text-decoration: none;
}

a,
button,
input[type=checkbox],
input[type=checkbox] + svg {
	cursor: pointer;

	&:active {
		cursor: grabbing;
	}
}

select {
	border: 1px solid transparent;
	font-size: 100%;
	color: var(--colorText);
	cursor: pointer;
	border-radius: var(--radius);
	appearance: none;
	background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23888888'><path d='M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z'/></svg>") no-repeat;
	background-size: 16px;
	background-position: calc(100% - 3px) center;

	&:enabled {
		border-color: var(--colorSecondaryActionBorder);
		background-color: var(--colorSecondaryButtonBackground);
		&:hover {
			border-color: var(--colorHover);
			cursor: pointer;
			background-color: var(--colorHover);
		}
	}
	&:disabled {
		cursor: not-allowed;
		opacity: 0.5;
	}
}

header {
	display: flex;
	width: 100vw;
	padding: 16px;
	border-bottom: 1px solid var(--colorSecondaryActionBorder);
	background: var(--colorHeaderBackground);

	> img {
		align-self: end;
		margin-right: 22px;
		margin-bottom: 5px;
	}

	> div {
		display: flex;
		width: 100%;
		flex-wrap: wrap;
		align-items: flex-end;
		gap: 16px 8px;
	}

	@media (max-width: 760px) {
		> img {
			width: 100px;
			align-self: center;
		}

		> div {
			width: 400px;
			.MenuTrigger {
				margin-left: unset;
			}
		}
	}
	@media (max-width: 424px) {
		> img {
			display: none;
		}
	}

	.Field {
		width: 116px;

		span {
			display: flex;
			align-items: center;
			margin-left: 8px;
			color: var(--colorLabel);
			font-size: 11px;
			gap: 4px;
		}

		input[type=url],
		input[type=number],
		select {
			width: 100%;
			height: 28px;
			padding: 4px 8px;
			border: 1px solid var(--colorSecondaryActionBorder);
			margin-top: 2px;
			color: var(--colorText);
			font-size: 11px;
			background-color: var(--colorComboBoxHeaderBackground);
			border-radius: var(--radius);
		}

		select:enabled:hover {
			border-color: var(--colorSecondaryActionBorder);
			background: var(--colorHover);
		}

		&.GlobalDelayField {
			width: 76px;

			input[type=number] {
				padding-right: 6px;
			}

			svg {
				width: 12px;
				height: 12px;
				border: 1px solid var(--colorLabel);
				stroke-width: 3px;
				border-radius: 50%;
			}
		}

		&.CookieSelector {
			width: 100px;
		}

		&.FallbackBackend {
			position: relative;
			width: 160px;

			.SaveProxiedCheckbox {
				position: absolute;
				top: 0;
				right: 0;
				display: flex;
				width: auto;
				min-width: unset;
				align-items: center;
				font-size: 11px;
				gap: 4px;

				input + span {
					margin: 0;
					margin-right: 4px;
				}
				input:disabled + span {
					opacity: 0.8;
				}
			}
		}
	}

	.BulkSelector {
		background-image: none;
		text-align-last: center;
	}

	.ResetButton {
		padding: 6px 12px;
		border: 1px solid var(--colorRed);
		margin-right: 8px;
		margin-left: 4px;
		outline-offset: 1px;
		background: transparent;
		color: var(--colorRed);
		border-radius: 50px;

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

	.MenuTrigger {
		width: 24px;
		height: 24px;
		flex-shrink: 0;
		align-self: end;
		margin-bottom: 2px;
		margin-left: auto;
		fill: var(--colorSecondaryAction);
		background: transparent;
		border-radius: 50%;

		&:hover {
			fill: var(--colorAccent);
		}
	}

}

.SettingsMenu {
	position: absolute;
	top: 62px;
	right: 10px;
	left: auto;
	padding: 20px;
	border: 1px solid var(--colorSecondaryActionBorder);
	text-align: left;
	color: var(--colorText);
	border-radius: var(--radius);
	box-shadow: var(--boxShadow1);
	background: var(--colorHeaderBackground);

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

	.GroupByMethod {
		display: flex;
		align-items: center;
		margin-bottom: 12px;
		gap: 6px;
	}
}


main {
	display: flex;
	min-width: 0;
	min-height: 0;

	@media (max-width: 760px) {
		flex-direction: column;

		.Resizer {
			display: none;
		}

		.leftSide {
			min-width: 100%;
			min-height: 50%;
			max-height: 50%;
			border: 0;
		}
	}

	.leftSide {
		width: 50%;
		padding: 16px;
		border-right: 1px solid var(--colorSecondaryActionBorder);
		user-select: none;
		overflow-y: auto;
		box-shadow: var(--boxShadow1);
	}

	.rightSide {
		position: relative;
		min-width: 100px;
		min-height: 0;
		flex: 1;

		.Resizer {
			position: absolute;
			top: 0;
			left: 0;
			width: 8px;
			height: 100%;
			border-left: 3px solid transparent;
			cursor: col-resize;

			&:active {
				border-color: var(--colorSecondaryActionBorder);
			}
		}

	}
}

table {
	border-collapse: collapse;

	th {
		padding-bottom: 2px;
		padding-left: 4px;
		border-top: 20px solid transparent;
		text-align: left;
	}

	> tr:first-child > th {
		border-top: 0;
	}
}

.empty {
	margin-top: 80px;
}

.Method {
	padding-right: 8px;
	color: var(--colorSecondaryAction);
	text-align: center;
	font-size: 11px;
}

.PreviewLink {
	position: relative;
	left: -8px;
	display: inline-block;
	width: 100%;
	min-width: 140px;
	padding: 6px 8px;
	margin-left: 4px;
	border-radius: var(--radius);
	color: var(--colorAccent);
	word-break: break-word;

	&:hover {
		background: var(--colorHover);
	}
	&.chosen {
		color: white;
		background: var(--colorAccent);
	}
}

.MockSelector {
	height: 24px;
	padding-right: 20px;
	padding-left: 8px;
	text-overflow: ellipsis;
	font-size: 12px;

	&.nonDefault {
		font-weight: bold;
		font-size: 0.92rem;
	}
	&.status4xx {
		background: var(--color4xxBackground);
	}
	&:disabled {
		padding-right: 4px;
		border-color: transparent;
		appearance: none;
		background: transparent;
		cursor: default;
		color: var(--colorDisabledMockSelector);
		opacity: 0.8;
	}
}

.DelayToggler,
.ProxyToggler {
	display: flex;

	> input {
		/* For click drag target */
		position: absolute;
		width: 22px;
		height: 22px;
		opacity: 0;

		&:focus {
			outline: 0;
			& + svg {
				outline: 2px solid var(--colorAccent)
			}
		}
	}

	> svg {
		vertical-align: bottom;
		fill: none;
		stroke: var(--colorSecondaryAction);
	}
}

.DelayToggler {
	> input {
		&:checked + svg {
			border-color: var(--colorAccent);
			fill: var(--colorAccent);
			background: var(--colorAccent);
			stroke: var(--colorBackground);
		}

		&:enabled:hover:not(:checked) + svg {
			border-color: var(--colorHover);
			background: var(--colorHover);
			stroke: var(--colorText);
		}
	}

	> svg {
		width: 22px;
		height: 22px;
		border: 1px solid var(--colorSecondaryActionBorder);
		stroke-width: 2.5px;
		border-radius: 50%;
	}
}

.ProxyToggler {
	border: 1px solid var(--colorSecondaryActionBorder);
	margin-right: 8px;
	border-radius: var(--radius);

	&:has(input:checked),
	&:has(input:disabled) {
		background: transparent;
		box-shadow: none;
	}

	> input {
		&:checked + svg {
			fill: var(--colorAccent);
			stroke: var(--colorAccent);

			path:last-of-type { /* inner cloud curve */
				stroke: var(--colorBackground);
			}
			transform: scale(1.1);
		}

		&:enabled:hover:not(:checked) + svg {
			fill: var(--colorHover);
			stroke: var(--colorText);
		}

		&:disabled + svg {
			stroke-opacity: 0.4;
			cursor: not-allowed;
			box-shadow: none;
			fill: transparent;

			path:last-of-type {
				stroke-opacity: 0;
				stroke: transparent;
			}
		}
	}

	> svg {
		width: 26px;
		padding: 1px 4px;
		stroke-width: 2px;
		border-radius: var(--radius);
	}
}

.InternalServerErrorToggler,
.NotFoundToggler {
	display: flex;
	margin-right: 10px;
	margin-left: 8px;
	cursor: pointer;

	> input {
		appearance: none;

		&:focus {
			outline: 0;
			& + span {
				outline: 2px solid var(--colorAccent)
			}
		}

		&:checked + span {
			border-color: var(--colorRed);
			color: white;
			background: var(--colorRed);
		}
	}

	> span {
		padding: 4px;
		border: 1px solid var(--colorSecondaryActionBorder);
		font-size: 10px;
		font-weight: bold;
		color: var(--colorSecondaryAction);
		border-radius: var(--radius);

		&:hover {
			border-color: var(--colorLightRed);
			background: var(--colorLightRed);
			color: var(--colorRed);
		}
	}
}


.StaticFileLink {
	display: inline-block;
	padding: 6px 0;
	margin-left: 4px;
	border-radius: var(--radius);
	color: var(--colorAccent);
}


.PayloadViewer {
	display: flex;
	height: 100%;
	flex-direction: column;
	padding-top: 16px;

	h2 {
		padding-bottom: 4px;
		padding-left: 16px;
	}

	pre {
		overflow: auto;
		height: 100%;
		padding: 16px;
		padding-top: 12px;
		font-family: monospace;

		code {
			white-space: pre;
			tab-size: 2;

			.json {
				color: var(--colorSecondaryAction);
			}
		}
	}
}

.ProgressBar {
	position: relative;
	top: -4px;
	width: 100%;
	height: 2px;
	background: var(--colorComboBoxHeaderBackground);

	> div {
		position: absolute;
		top: 0;
		left: 0;
		width: 0;
		height: 100%;
		background: var(--colorAccent);
		animation-name: _kfProgress;
		animation-timing-function: linear;
		/* duration in JavaScript */
	}
}
@keyframes _kfProgress {
	to {
		width: 100%;
	}
}

.red {
	color: var(--colorRed);
}

.dittoDir {
	opacity: 0.6;
}

.ErrorToast {
	position: fixed;
	z-index: 9999;
	bottom: 12px;
	left: 12px;
	padding: 12px 16px;
	cursor: pointer;
	background: var(--colorRed);
	color: white;
	border-radius: var(--radius);
	box-shadow: var(--boxShadow1);
	opacity: 0;
	transform: translateY(20px);
	animation: _kfToastIn 240ms forwards;

	&:hover::after {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		text-align: center;
		content: '×';
		font-size: 28px;
		line-height: 34px;
		border-radius: var(--radius);
		background: rgba(0, 0, 0, 0.5);
	}
}

@keyframes _kfToastIn {
	to {
		opacity: 1;
		transform: translateY(0);
	}
}
