:root {
	--accent: #3e5763;
	--accent-text: #ffffff;
	--background: whitesmoke;
	--panel: #ffffff;
	--text: #000000;
	--muted: #666666;
	--border: #d0d0d0;
	--warn: #fff8e1;
	--warn-text: #6b4e00;
	--error: #fdecea;
	--error-text: #9b1c1c;
	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	:root {
		--accent: #2b3d45;
		--accent-text: #e6eef2;
		--background: #1e1e1e;
		--panel: #282c34;
		--text: #e6e6e6;
		--muted: #9a9a9a;
		--border: #3a3f4b;
		--warn: #3b3220;
		--warn-text: #f0d68a;
		--error: #3f2424;
		--error-text: #ffb4ab;
		color-scheme: dark;
	}
}

* {
	box-sizing: border-box;
}

html,
body {
	height: 100%;
	margin: 0;
}

body {
	display: flex;
	flex-direction: column;
	background: var(--background);
	color: var(--text);
	font-family: system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
	font-size: 15px;
}

header {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 14px;
	padding: 8px 14px;
	background: var(--accent);
	color: var(--accent-text);
}

h1 {
	margin: 0;
	font-size: 1.25em;
	font-weight: 600;
}

header a {
	color: inherit;
}

h1 a {
	text-decoration: none;
}

.examples {
	display: flex;
	align-items: center;
	gap: 6px;
}

select,
button {
	font: inherit;
	padding: 4px 10px;
	border-radius: 4px;
	border: 1px solid var(--border);
	background: var(--panel);
	color: var(--text);
}

button {
	cursor: pointer;
}

button:disabled {
	cursor: default;
	opacity: 0.5;
}

#console button.location {
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	text-decoration: underline;
}

#run {
	font-weight: 600;
	background: #e3f1e6;
	color: #1d4d2b;
	border-color: #9cc9a7;
}

@media (prefers-color-scheme: dark) {
	#run {
		background: #24452e;
		color: #d6f2dc;
		border-color: #3f7050;
	}
}

#status {
	color: var(--accent-text);
	opacity: 0.85;
}

.docs {
	margin-left: auto;
}

main {
	flex: 1;
	min-height: 0;
	display: grid;
	grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
}

.editor {
	min-height: 0;
	border-right: 1px solid var(--border);
}

#editor,
#editor .cm-editor {
	height: 100%;
}

#editor .cm-editor {
	font-size: 14px;
}

#editor .cm-scroller {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.output {
	display: grid;
	grid-template-rows: auto minmax(80px, 2fr) auto minmax(80px, 3fr);
	min-height: 0;
}

.output h2 {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin: 0;
	padding: 4px 10px;
	font-size: 0.8em;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--muted);
	border-bottom: 1px solid var(--border);
}

.output h2 button {
	padding: 1px 8px;
	font-size: 0.95em;
	text-transform: none;
	letter-spacing: 0;
}

#frame-container {
	min-height: 0;
	background: #ffffff;
	border-bottom: 1px solid var(--border);
}

#frame-container iframe {
	display: block;
	width: 100%;
	height: 100%;
	border: 0;
}

#console {
	min-height: 0;
	overflow: auto;
	margin: 0;
	padding: 0;
	list-style: none;
	background: var(--panel);
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 13px;
}

#console li {
	margin: 0;
	padding: 4px 10px;
	border-bottom: 1px solid var(--border);
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

#console li.warn {
	background: var(--warn);
	color: var(--warn-text);
}

#console li.error {
	background: var(--error);
	color: var(--error-text);
}

#console li.info {
	color: var(--muted);
	font-style: italic;
}

@media (max-width: 800px) {
	main {
		grid-template-columns: 1fr;
		grid-template-rows: minmax(300px, 1fr) minmax(400px, 1fr);
	}

	.editor {
		border-right: 0;
		border-bottom: 1px solid var(--border);
	}

	.docs {
		margin-left: 0;
	}
}
