:root {
	--bg: #fafafa;
	--fg: #1a1a1a;
	--fg-muted: #6b7280;
	--surface: #ffffff;
	--border: #e5e7eb;
	--accent: #2563eb;
	--accent-hover: #1d4ed8;
	--error: #dc2626;
	--error-bg: #fef2f2;
	--success: #16a34a;
	--success-bg: #f0fdf4;
	--mono: 'SF Mono', 'Cascadia Code', 'Fira Code', Consolas, monospace;
	--sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	--radius: 4px;
}

*,
*::before,
*::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

html {
	font-family: var(--sans);
	color: var(--fg);
	background: var(--bg);
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
}

body {
	min-height: 100dvh;
}

a {
	color: var(--accent);
	text-decoration: none;
}

a:hover {
	text-decoration: underline;
}

.site-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	border-bottom: 1px solid var(--border);
	padding: 12px 24px;
	background: var(--surface);
}

.logo {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-weight: 600;
	font-size: 15px;
	color: var(--fg);
	text-decoration: none;
}

.logo-mark {
	width: 28px;
	height: 28px;
	display: block;
	flex: none;
}

.logo:hover {
	text-decoration: none;
}

nav {
	display: flex;
	align-items: center;
	gap: 12px;
	font-size: 14px;
}

nav a {
	font-weight: 500;
}

nav a[aria-current] {
	color: var(--fg);
}

main {
	max-width: 720px;
	margin: 0 auto;
	padding: 32px 24px 64px;
}

h1 {
	font-size: 20px;
	font-weight: 600;
}

h2 {
	font-size: 13px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--fg-muted);
	margin-bottom: 8px;
}

button {
	font-family: inherit;
	font-size: inherit;
	cursor: pointer;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
	color: var(--fg);
	padding: 6px 14px;
	transition:
		background 0.1s,
		border-color 0.1s;
}

button:hover {
	border-color: var(--fg-muted);
}

button.primary {
	background: var(--accent);
	color: #fff;
	border-color: var(--accent);
}

button.primary:hover:not(:disabled) {
	background: var(--accent-hover);
	border-color: var(--accent-hover);
}

button:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

input[type='text'] {
	font-family: var(--mono);
	font-size: 14px;
	line-height: 1.5;
	color: var(--fg);
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 9px 10px;
	width: 100%;
}

input[type='text']:focus,
button:focus-visible,
a:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

[hidden] {
	display: none !important;
}

.exercise-page h1 {
	margin-bottom: 20px;
}

.exercise-list {
	list-style: none;
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.exercise-list li {
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 14px 16px;
	background: var(--surface);
}

.exercise-list a,
.unavailable-title {
	font-weight: 500;
	font-size: 15px;
}

.unavailable-title {
	color: var(--fg-muted);
}

.exercise-list p {
	font-size: 14px;
	color: var(--fg-muted);
	margin-top: 4px;
}

.configuration-error {
	font-size: 14px;
	color: var(--error);
	background: var(--error-bg);
	border-radius: var(--radius);
	padding: 8px 12px;
	margin-bottom: 16px;
}

.not-found {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 12px;
}

.not-found .configuration-error {
	margin: 0;
}

.workspace {
	display: flex;
	flex-direction: column;
	gap: 28px;
}

.workspace section {
	display: flex;
	flex-direction: column;
}

.workspace-intro {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 8px;
}

.back-link {
	font-size: 13px;
	margin-bottom: 8px;
}

.prompt {
	font-size: 15px;
	color: var(--fg-muted);
}

.kind-row {
	display: flex;
	gap: 12px;
	margin-bottom: 8px;
}

.kind-option {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
}

.kind-option input {
	accent-color: var(--accent);
}

/* The gutter and editor share font metrics so their lines stay aligned. */
.editor-wrap {
	display: flex;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
	overflow: hidden;
}

.editor-wrap:focus-within {
	outline: 2px solid var(--accent);
	outline-offset: 1px;
}

.editor-wrap textarea {
	margin: 0;
	padding: 12px 0;
	border: none;
	border-radius: 0;
	outline: none;
	resize: none;
	font-family: var(--mono);
	font-size: 14px;
	line-height: 1.5;
	color: var(--fg);
	white-space: pre;
	tab-size: 4;
}

.editor-wrap .line-numbers {
	flex: 0 0 2.25rem;
	padding-left: 0.35rem;
	padding-right: 0.4rem;
	text-align: right;
	color: var(--fg-muted);
	background: #f3f4f6;
	border-right: 1px solid var(--border);
	overflow: hidden;
	pointer-events: none;
}

.editor-wrap [data-role='editor'] {
	flex: 1 1 auto;
	min-width: 0;
	min-height: 220px;
	padding-left: 12px;
	padding-right: 12px;
	resize: vertical;
	overflow: auto;
	background: var(--surface);
}

.errors {
	list-style: none;
	margin-top: 8px;
	font-size: 13px;
	color: var(--error);
	background: var(--error-bg);
	border-radius: var(--radius);
	padding: 8px 12px;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.diagram {
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
	padding: 12px;
	min-height: 120px;
	overflow: auto;
	display: flex;
	justify-content: center;
	align-items: center;
}

.diagram .hint,
.diagram .err {
	font-size: 13px;
	color: var(--fg-muted);
}

.diagram .err {
	color: var(--error);
}

.diagram svg {
	max-width: 100%;
	height: auto;
}

.input-label {
	font-size: 13px;
	font-weight: 500;
	color: var(--fg-muted);
	margin-bottom: 4px;
}

.test-row {
	display: flex;
	gap: 6px;
}

.test-row input {
	flex: 1;
}

.error {
	margin-top: 8px;
	font-size: 13px;
	color: var(--error);
}

.test-result {
	margin-top: 8px;
	font-size: 13px;
	padding: 8px 12px;
	border-radius: var(--radius);
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.test-result.accepted {
	background: var(--success-bg);
	color: var(--success);
}

.test-result.rejected {
	background: var(--error-bg);
	color: var(--error);
}

.verdict,
.grading-message {
	font-weight: 600;
}

.trace {
	font-size: 13px;
	color: var(--fg);
	word-break: break-all;
}

.check-button {
	align-self: flex-start;
}

.grading-result-area:not(:empty) {
	margin-top: 10px;
}

.grading-feedback {
	font-size: 14px;
	padding: 10px 14px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.grading-success {
	border-color: var(--success);
	background: var(--success-bg);
}

.grading-error {
	color: var(--error);
	background: var(--error-bg);
	border-color: var(--error);
}

.grading-feedback code {
	font-family: var(--mono);
	font-size: 13px;
	color: var(--fg);
	background: var(--bg);
	padding: 1px 5px;
	border-radius: 3px;
	border: 1px solid var(--border);
}

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

@media (max-width: 520px) {
	.site-header {
		padding-inline: 16px;
	}

	main {
		padding-inline: 16px;
	}

	.test-row {
		align-items: stretch;
	}
}
