:root {
	--ink: #1b1b1b;
	--muted: #6b6b6b;
	--line: #e5e0da;
	--bg: #f6f5f3;
	--card: #ffffff;
	--brand: #c8102e;
	--brand-dark: #9c0c23;
	--accent: #c8102e;
	--pass: #1f7a45;
	--pass-bg: #e9f6ee;
	--fail: #a31520;
	--fail-bg: #fbeaea;
	--warn: #8a5300;
	--warn-bg: #fdf3e2;
	--radius: 14px;
	--shadow-xs: 0 1px 2px rgba(27, 27, 27, .06);
	--shadow-sm: 0 1px 2px rgba(27, 27, 27, .05), 0 3px 8px rgba(27, 27, 27, .05);
	--shadow: 0 1px 2px rgba(27, 27, 27, .05), 0 12px 30px rgba(27, 27, 27, .08);
	--shadow-lg: 0 2px 4px rgba(27, 27, 27, .04), 0 20px 48px rgba(27, 27, 27, .11);
	--shadow-brand: 0 6px 18px rgba(200, 16, 46, .28);
}

* {
	box-sizing: border-box;
}

html {
	-webkit-text-size-adjust: 100%;
}

body {
	margin: 0;
	background: linear-gradient(180deg, #faf9f7 0%, var(--bg) 240px, var(--bg) 100%);
	color: var(--ink);
	font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	-webkit-font-smoothing: antialiased;
}

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

.wrap {
	width: 100%;
	max-width: 900px;
	margin: 0 auto;
	padding: 0 20px;
}

.site-header {
	background: #fff;
	border-top: 5px solid var(--brand);
	border-bottom: 1px solid var(--line);
	box-shadow: 0 1px 3px rgba(27, 27, 27, .05), 0 8px 24px rgba(27, 27, 27, .05);
}

.site-header .wrap {
	display: flex;
	flex-wrap: nowrap;
	align-items: center;
	gap: 16px;
	padding-top: 12px;
	padding-bottom: 12px;
}

.brand {
	display: inline-flex;
	flex: 0 0 auto;
}

.brand-logo {
	display: block;
	height: 54px;
	width: auto;
}

.brand-divider {
	flex: 0 0 auto;
	width: 1px;
	height: 38px;
	background: var(--line);
}

.site-header .course {
	min-width: 0;
	font-size: 15px;
	font-weight: 600;
	color: var(--ink);
	letter-spacing: .01em;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.site-header .course::before {
	content: "";
	display: inline-block;
	width: 7px;
	height: 7px;
	margin-right: 9px;
	border-radius: 50%;
	background: var(--brand);
	vertical-align: 1px;
}

main.wrap {
	padding-top: 28px;
	padding-bottom: 56px;
}

.site-footer {
	border-top: 1px solid var(--line);
	background: #fff;
	color: var(--muted);
	font-size: 13px;
}

.site-footer .wrap {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 8px;
	padding-top: 16px;
	padding-bottom: 16px;
}

h1 {
	margin: 0 0 10px;
	font-size: 32px;
	line-height: 1.2;
	letter-spacing: -.01em;
}

h2 {
	margin: 0 0 14px;
	font-size: 20px;
	line-height: 1.3;
}

p {
	margin: 0 0 12px;
}

.eyebrow {
	margin: 0 0 6px;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: .12em;
	text-transform: uppercase;
	color: var(--accent);
}

.lede {
	font-size: 17px;
	color: var(--muted);
	max-width: 60ch;
}

.muted {
	color: var(--muted);
}

.small {
	font-size: 13px;
}

code {
	background: #f2efec;
	border-radius: 5px;
	padding: 1px 5px;
	font-size: .9em;
}

.hero {
	padding: 8px 0 24px;
}

.start-grid {
	display: grid;
	grid-template-columns: 1fr 1.15fr;
	gap: 22px;
	align-items: start;
}

.card {
	background: var(--card);
	border: 1px solid var(--line);
	border-radius: 16px;
	box-shadow: var(--shadow);
	padding: 26px;
}

.checklist {
	margin: 0;
	padding: 0;
	list-style: none;
}

.checklist li {
	position: relative;
	padding: 0 0 12px 26px;
	color: var(--muted);
}

.checklist li::before {
	content: "";
	position: absolute;
	left: 0;
	top: 7px;
	width: 14px;
	height: 14px;
	border: 2px solid var(--accent);
	border-radius: 4px;
}

.checklist li strong {
	color: var(--ink);
}

.alert {
	border-radius: 12px;
	padding: 12px 15px;
	margin-bottom: 16px;
	font-size: 14px;
	box-shadow: var(--shadow-xs);
}

.alert a {
	font-weight: 600;
}

.home-alert {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 10px 16px;
	padding: 12px 14px 12px 18px;
}

.alert-error {
	background: var(--fail-bg);
	border: 1px solid #f3c3bf;
	color: var(--fail);
}

.alert-info {
	background: var(--pass-bg);
	border: 1px solid #bfe0cc;
	color: var(--pass);
}

.field {
	margin-bottom: 15px;
}

.field-row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 14px;
}

.field label {
	display: block;
	margin-bottom: 6px;
	font-size: 13.5px;
	font-weight: 600;
	color: #33302d;
}

.field input,
.field select {
	width: 100%;
	min-height: 46px;
	padding: 11px 14px;
	border: 1px solid #dcd6cf;
	border-radius: 11px;
	background: #fff;
	color: var(--ink);
	font: inherit;
	box-shadow: var(--shadow-xs);
	transition: border-color .15s ease, box-shadow .15s ease;
}

.field input:hover,
.field select:hover {
	border-color: #c8c0b7;
}

.field input:focus,
.field select:focus {
	outline: none;
	border-color: var(--accent);
	box-shadow: 0 0 0 4px rgba(200, 16, 46, .12), var(--shadow-sm);
}

.field input::placeholder {
	color: #a9a29a;
}

.hp {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 11px 20px;
	border: 1px solid #d8d2cc;
	border-radius: 999px;
	background: #fff;
	color: var(--ink);
	font: inherit;
	font-weight: 600;
	text-decoration: none;
	cursor: pointer;
	box-shadow: var(--shadow-xs);
	transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .1s ease;
}

.btn:hover {
	border-color: #bdb5ad;
	background: #fbfaf9;
	box-shadow: var(--shadow-sm);
	transform: translateY(-1px);
}

.btn:active {
	transform: translateY(0);
	box-shadow: var(--shadow-xs);
}

.btn:disabled {
	opacity: .5;
	cursor: not-allowed;
	box-shadow: none;
	transform: none;
}

.btn-primary {
	background: var(--brand);
	border-color: var(--brand);
	color: #fff;
	box-shadow: var(--shadow-brand);
}

.btn-primary:hover {
	background: var(--brand-dark);
	border-color: var(--brand-dark);
	box-shadow: 0 8px 22px rgba(200, 16, 46, .34);
}

.btn-lg {
	padding: 14px 26px;
	font-size: 17px;
}

.btn-block {
	width: 100%;
}

/* Exam */

.exam-intro h1 {
	margin-bottom: 4px;
	font-size: 26px;
}

.exam-intro p {
	color: var(--muted);
	font-size: 14px;
}

.exam-meta {
	position: sticky;
	top: 0;
	z-index: 20;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 10px 20px;
	margin: 0 -8px 20px;
	padding: 12px 16px;
	background: rgba(255, 255, 255, .94);
	backdrop-filter: blur(6px);
	border: 1px solid var(--line);
	border-radius: 12px;
	box-shadow: 0 4px 16px rgba(27, 27, 27, .07);
}

.exam-progress {
	display: flex;
	align-items: center;
	gap: 12px;
	flex: 1 1 260px;
}

.progress-track {
	flex: 1;
	height: 8px;
	background: #ece8e3;
	border-radius: 999px;
	overflow: hidden;
}

.progress-fill {
	display: block;
	width: 0;
	height: 100%;
	border-radius: inherit;
	background: linear-gradient(90deg, var(--accent), #e8606f);
	transition: width .2s ease;
}

.progress-label {
	font-size: 13px;
	color: var(--muted);
	white-space: nowrap;
}

.progress-label strong {
	color: var(--ink);
}

.exam-timer {
	font-variant-numeric: tabular-nums;
	font-weight: 700;
	font-size: 15px;
	padding: 5px 12px;
	border-radius: 999px;
	background: #fdeef0;
	color: var(--brand);
}

.exam-timer.timer-low {
	background: var(--fail-bg);
	color: var(--fail);
}

.questions {
	margin: 0;
	padding: 0;
	list-style: none;
	counter-reset: none;
}

.question {
	background: var(--card);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 20px 22px;
	margin-bottom: 16px;
}

.q-text {
	margin: 0 0 14px;
	font-size: 16.5px;
	font-weight: 600;
	line-height: 1.5;
}

.q-number {
	color: var(--accent);
	font-weight: 700;
	margin-right: 4px;
}

.options {
	display: grid;
	gap: 8px;
}

.option {
	position: relative;
	display: flex;
	align-items: flex-start;
	gap: 11px;
	padding: 11px 14px;
	border: 1px solid #e0dad3;
	border-radius: 11px;
	background: #fff;
	box-shadow: var(--shadow-xs);
	cursor: pointer;
	transition: border-color .12s ease, background .12s ease, box-shadow .12s ease;
}

.option:hover {
	border-color: #c8c0b7;
	background: #fbfaf9;
	box-shadow: var(--shadow-sm);
}

.option input {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

.option-letter {
	flex: 0 0 auto;
	width: 24px;
	height: 24px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: #f2efec;
	color: var(--muted);
	font-size: 12.5px;
	font-weight: 700;
}

.option-text {
	padding-top: 1px;
}

.option:has(input:checked) {
	border-color: var(--accent);
	background: #fdf2f3;
	box-shadow: 0 0 0 1px var(--accent), var(--shadow-sm);
}

.option:has(input:checked) .option-letter {
	background: var(--accent);
	color: #fff;
}

.option input:focus-visible + .option-letter {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

.submit-box {
	margin-top: 26px;
	padding: 22px;
	text-align: center;
	background: #fff;
	border: 1px dashed #d8d2cc;
	border-radius: var(--radius);
}

.submit-box p {
	margin-bottom: 14px;
	font-size: 14px;
}

/* Result */

.result-hero {
	padding: 10px 0 26px;
	text-align: center;
}

.result-hero h1 {
	margin: 18px 0 6px;
	font-size: 26px;
}

.result-hero .lede {
	margin: 0 auto;
}

.result-hero.is-pass .eyebrow {
	color: var(--pass);
}

.result-hero.is-fail .eyebrow {
	color: var(--fail);
}

.score-ring {
	width: 148px;
	height: 148px;
	margin: 0 auto;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	border: 8px solid var(--line);
}

.is-pass .score-ring {
	border-color: var(--pass);
	background: var(--pass-bg);
}

.is-fail .score-ring {
	border-color: var(--fail);
	background: var(--fail-bg);
}

.score-percent {
	font-size: 40px;
	font-weight: 800;
	line-height: 1;
	letter-spacing: -.02em;
}

.score-percent small {
	font-size: 20px;
	font-weight: 700;
}

.score-fraction {
	margin-top: 8px;
	font-size: 12px;
	color: var(--muted);
}

.stats-grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 12px;
	margin-bottom: 24px;
}

.stat {
	background: var(--card);
	border: 1px solid var(--line);
	border-radius: 12px;
	box-shadow: var(--shadow-xs);
	padding: 14px 16px;
}

.stat-label {
	display: block;
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: .08em;
	color: var(--muted);
	margin-bottom: 4px;
}

.stat-value {
	font-size: 20px;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

.review {
	margin-bottom: 24px;
}

.review-list {
	margin: 16px 0 0;
	padding: 0;
	list-style: none;
}

.review-list li {
	padding: 14px 0;
	border-top: 1px solid var(--line);
}

.review-question {
	margin: 0 0 6px;
	font-weight: 600;
	font-size: 15px;
}

.review-answer {
	margin: 0;
	font-size: 14px;
	color: var(--muted);
}

.tag {
	display: inline-block;
	border-radius: 999px;
	padding: 2px 10px;
	font-size: 12px;
	font-weight: 600;
}

.tag-blank {
	background: var(--warn-bg);
	color: var(--warn);
}

.tag-wrong {
	background: var(--fail-bg);
	color: var(--fail);
}

.result-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-bottom: 18px;
}

.result-note {
	font-size: 13px;
}

/* Admin */

.admin-login {
	max-width: 420px;
	margin: 40px auto;
}

.admin-login h1 {
	font-size: 24px;
}

.admin-head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 20px;
}

.admin-head h1 {
	margin: 0;
	font-size: 26px;
}

.admin-actions {
	display: flex;
	gap: 10px;
}

.admin-actions form {
	margin: 0;
}

.table-wrap {
	overflow-x: auto;
	background: #fff;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	box-shadow: var(--shadow-sm);
}

.results-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 14px;
	white-space: nowrap;
}

.results-table th,
.results-table td {
	padding: 11px 14px;
	text-align: left;
	border-bottom: 1px solid var(--line);
}

.results-table th {
	background: #faf9f7;
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: .06em;
	color: var(--muted);
}

.results-table tbody tr:last-child td {
	border-bottom: 0;
}

.results-table tbody tr:hover {
	background: #fbfaf9;
}

.pill {
	display: inline-block;
	border-radius: 999px;
	padding: 2px 10px;
	font-size: 12px;
	font-weight: 700;
}

.pill-pass {
	background: var(--pass-bg);
	color: var(--pass);
}

.pill-fail {
	background: var(--fail-bg);
	color: var(--fail);
}

@media (max-width: 720px) {
	.start-grid {
		grid-template-columns: 1fr;
	}

	.stats-grid {
		grid-template-columns: repeat(2, 1fr);
	}

	h1 {
		font-size: 26px;
	}

	.card {
		padding: 20px;
	}

	.question {
		padding: 16px;
	}
}

@media (max-width: 480px) {
	.wrap {
		padding: 0 14px;
	}

	.brand-logo {
		height: 42px;
	}

	.brand-divider {
		height: 30px;
	}

	.site-header .wrap {
		gap: 11px;
	}

	.site-header .course {
		font-size: 13px;
	}

	main.wrap {
		padding-top: 18px;
	}

	.field-row {
		grid-template-columns: 1fr;
		gap: 0;
	}

	.exam-meta {
		margin-left: -2px;
		margin-right: -2px;
	}

	.exam-progress {
		flex-basis: 100%;
	}

	.option {
		padding: 10px 11px;
	}

	.admin-head {
		align-items: flex-start;
	}
}

/* Admin extras */

.admin-nav {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px 18px;
	margin: -10px 0 22px;
	padding: 10px 2px;
	border-bottom: 1px solid var(--line);
	font-size: 14px;
}

.admin-nav a {
	color: var(--muted);
	text-decoration: none;
	font-weight: 600;
	padding: 4px 2px;
}

.admin-nav a:hover {
	color: var(--brand);
}

.admin-nav .nav-right {
	margin-left: auto;
	color: var(--fail);
}

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

.back-link a {
	text-decoration: none;
}

.two-col {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 22px;
	align-items: start;
	margin-bottom: 22px;
}

.two-col .card {
	margin-bottom: 0;
}

.card + .card {
	margin-top: 22px;
}

.check {
	display: flex;
	align-items: flex-start;
	gap: 9px;
	font-size: 14px;
	cursor: pointer;
}

.check input {
	margin-top: 3px;
	width: 16px;
	height: 16px;
	accent-color: var(--brand);
}

.field-hint {
	display: block;
	margin-top: 5px;
	font-size: 12.5px;
	color: var(--muted);
}

select {
	width: 100%;
	min-height: 44px;
	padding: 10px 13px;
	border: 1px solid #dcd6cf;
	border-radius: 11px;
	background: #fff;
	color: var(--ink);
	font: inherit;
	box-shadow: var(--shadow-xs);
	transition: border-color .15s ease, box-shadow .15s ease;
}

select:hover {
	border-color: #c8c0b7;
}

select:focus {
	outline: none;
	border-color: var(--accent);
	box-shadow: 0 0 0 4px rgba(200, 16, 46, .12), var(--shadow-sm);
}

input[type="file"] {
	font-size: 14px;
}

.link-box {
	display: flex;
	gap: 8px;
	align-items: stretch;
	flex-wrap: wrap;
}

.link-box input {
	flex: 1 1 260px;
	padding: 10px 13px;
	border: 1px solid #dcd6cf;
	border-radius: 11px;
	background: #faf9f7;
	color: var(--ink);
	font: inherit;
	font-size: 13.5px;
	box-shadow: inset 0 1px 2px rgba(27, 27, 27, .04);
}

.inline-form {
	margin-top: 10px;
}

.btn-sm {
	padding: 7px 14px;
	font-size: 13.5px;
}

.toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px 18px;
	margin: 4px 0 16px;
}

.status-list {
	display: grid;
	gap: 8px;
	margin-bottom: 18px;
	padding: 14px 16px;
	background: #faf9f7;
	border: 1px solid var(--line);
	border-radius: 10px;
	font-size: 14px;
}

.status-list > div {
	display: flex;
	justify-content: space-between;
	gap: 14px;
}

.logbox {
	margin: 0;
	padding: 14px;
	background: #1b1b1b;
	color: #d8e0ef;
	border-radius: 10px;
	font-size: 12.5px;
	line-height: 1.6;
	white-space: pre-wrap;
	word-break: break-word;
	overflow-x: auto;
}

details.key-editor > summary {
	cursor: pointer;
	font-size: 18px;
	font-weight: 700;
	color: var(--ink);
}

details.key-editor[open] > summary {
	margin-bottom: 14px;
}

.table-wrap.flat {
	box-shadow: none;
	border-radius: 10px;
}

.key-table select {
	min-width: 240px;
	max-width: 460px;
	padding: 7px 10px;
	font-size: 13.5px;
}

.key-table .key-question {
	white-space: normal;
	min-width: 260px;
	font-size: 13.5px;
}

.key-table tr.needs-key td {
	background: #fff7ed;
}

.key-table tr.needs-key td:first-child {
	box-shadow: inset 3px 0 0 #f59e0b;
}

.link-cell {
	max-width: 280px;
	overflow: hidden;
	text-overflow: ellipsis;
}

.quiz-table td {
	vertical-align: middle;
}

@media (max-width: 720px) {
	.two-col {
		grid-template-columns: 1fr;
	}

	.key-table select {
		min-width: 160px;
	}
}

@media print {
	body {
		background: #fff;
	}

	.site-header,
	.site-footer,
	.result-actions,
	.exam-meta,
	.submit-box {
		display: none !important;
	}

	main.wrap {
		padding: 0;
	}

	.card,
	.question,
	.stat {
		box-shadow: none;
		border-color: #bbb;
	}

	.result-hero {
		padding-top: 0;
	}
}

/* Question management */

textarea {
	width: 100%;
	padding: 11px 14px;
	border: 1px solid #dcd6cf;
	border-radius: 11px;
	background: #fff;
	color: var(--ink);
	font: inherit;
	resize: vertical;
	box-shadow: var(--shadow-xs);
	transition: border-color .15s ease, box-shadow .15s ease;
}

textarea:hover {
	border-color: #c8c0b7;
}

textarea:focus {
	outline: none;
	border-color: var(--accent);
	box-shadow: 0 0 0 4px rgba(200, 16, 46, .12), var(--shadow-sm);
}

.btn-danger {
	border-color: #e7c3c6;
	background: #fff;
	color: var(--fail);
}

.btn-danger:hover {
	border-color: var(--fail);
	background: var(--fail-bg);
}

.inline-delete {
	display: none;
}

/* Home / exam chooser */

.home-hero {
	max-width: 620px;
	padding: 12px 0 26px;
}

.home-hero h1 {
	font-size: 38px;
	letter-spacing: -.02em;
}

.exam-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(265px, 1fr));
	gap: 18px;
	margin-bottom: 8px;
}

.exam-card {
	position: relative;
	display: flex;
	flex-direction: column;
	padding: 23px 22px 18px;
	background: var(--card);
	border: 1px solid var(--line);
	border-radius: 16px;
	box-shadow: var(--shadow);
	color: var(--ink);
	text-decoration: none;
	overflow: hidden;
	transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.exam-card::before {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 4px;
	background: linear-gradient(90deg, var(--brand), #e8606f);
}

.exam-card:hover {
	transform: translateY(-3px);
	box-shadow: var(--shadow-lg);
	border-color: #d6cec5;
}

.exam-card:focus-visible {
	outline: 3px solid rgba(200, 16, 46, .35);
	outline-offset: 3px;
}

.exam-card-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-top: 2px;
}

.exam-threshold {
	display: inline-block;
	padding: 3px 10px;
	border-radius: 999px;
	background: #fdeef0;
	color: var(--brand);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: .02em;
}

.exam-card h2 {
	margin: 12px 0 4px;
	font-size: 19px;
	line-height: 1.35;
}

.exam-course {
	margin: 0 0 14px;
	color: var(--muted);
	font-size: 14px;
}

.exam-facts {
	display: flex;
	flex-wrap: wrap;
	gap: 6px 16px;
	margin: 0 0 18px;
	padding: 13px 0 0;
	border-top: 1px solid var(--line);
	list-style: none;
	font-size: 13px;
	color: var(--muted);
}

.exam-facts strong {
	color: var(--ink);
}

.exam-cta {
	margin-top: auto;
	display: inline-flex;
	align-items: center;
	gap: 7px;
	font-size: 14px;
	font-weight: 700;
	color: var(--brand);
}

.exam-cta span {
	transition: transform .18s ease;
}

.exam-card:hover .exam-cta span {
	transform: translateX(3px);
}

.exam-card.is-inactive {
	opacity: .7;
}

.exam-card.is-inactive::before {
	background: #b9b2aa;
}

.empty-state {
	max-width: 560px;
	margin: 0 auto;
	text-align: center;
}

.empty-state p {
	color: var(--muted);
}

@media (max-width: 720px) {
	.home-hero h1 {
		font-size: 30px;
	}

	.exam-grid {
		grid-template-columns: 1fr;
	}
}
