/* WPM Typing Test: the tool (front page only). */

/* Section colours for the tool (follow the site colours unless set). */
:root {
	--t-untyped: var(--dim);
	--t-typed: var(--text);
	--t-error: var(--err);
	--caret: var(--accent);
	--timer: var(--accent);
	--live: var(--text);
	--panel-bg: var(--bg-raised);
	--opt-on: var(--accent);
	--r-number: var(--accent);
	--r-stats: var(--text);
	--r-label: var(--dim);
	--chart-line: var(--accent);
	--chart-bar: var(--accent);
	--heat: var(--err);
}

/* ---------- Focus mode: chrome fades while typing ---------- */
.fade-on-type,
.live {
	transition: opacity 450ms var(--ease);
}

body.is-typing .fade-on-type {
	opacity: var(--fade);
}

body.is-typing .live {
	opacity: 0.5;
}

/* ---------- Test view ---------- */
.tool {
	padding-block: 4px 24px;
}

.view[hidden] {
	display: none;
}

.view-test {
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 22px;
	min-height: calc(100vh - 92px);
	min-height: calc(100svh - 92px);
	padding-bottom: 8vh;
}

/* Settings: one button, options in a panel */
.settings-bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 10px 14px;
}

.settings-wrap {
	position: relative;
}

.settings-open svg {
	flex-shrink: 0;
}

.settings-summary {
	color: var(--dim);
	font-weight: 500;
	letter-spacing: 0.02em;
	text-transform: none;
}

.settings-summary::before {
	content: "/";
	margin-right: 8px;
	color: var(--line);
}

.settings {
	position: absolute;
	top: calc(100% + 8px);
	left: 0;
	z-index: 50;
	display: grid;
	gap: 20px;
	width: min(460px, calc(100vw - 2 * var(--gutter)));
	padding: 18px;
	border: 1px solid var(--line);
	border-radius: calc(var(--radius) + 2px);
	background: var(--panel-bg);
	box-shadow: var(--shadow);
	animation: wpm-panel-in 180ms var(--ease);
}

.settings[hidden] {
	display: none;
}

@keyframes wpm-panel-in {
	from {
		opacity: 0;
		transform: translateY(-6px);
	}
}

.sheet-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin: -6px -6px -6px 0;
}

.sheet-title {
	margin: 0;
	color: var(--text);
	font-size: 0.75rem;
	font-weight: 650;
	letter-spacing: 0.1em;
	text-transform: uppercase;
}

.opt-group {
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
}

.opt-group legend {
	margin-bottom: 8px;
	padding: 0;
	color: var(--dim);
	font-size: 0.7rem;
	font-weight: 650;
	letter-spacing: 0.12em;
	text-transform: uppercase;
}

.opt-row {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

label.opt {
	position: relative;
	display: inline-flex;
}

.opt input {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	opacity: 0;
	cursor: pointer;
}

.opt > span,
button.opt {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 38px;
	padding: 8px 12px;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: transparent;
	color: var(--dim);
	font: 650 0.72rem/1.2 var(--font-ui);
	letter-spacing: 0.08em;
	text-transform: uppercase;
	white-space: nowrap;
	cursor: pointer;
	transition: color var(--t), border-color var(--t), background-color var(--t);
}

label.opt:hover > span,
button.opt:hover {
	border-color: var(--dim);
	color: var(--text);
}

.opt input:checked + span,
button.opt[aria-pressed="true"] {
	border-color: var(--opt-on);
	background: var(--accent-soft);
	color: var(--opt-on);
}

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

/* Selected state shown by a mark as well as colour */
.opt > span::before,
button.opt::before {
	content: "";
	width: 10px;
	height: 10px;
	border: 1.5px solid currentColor;
	border-radius: 2px;
}

.opt > span::before {
	border-radius: 50%;
}

.opt input:checked + span::before,
button.opt[aria-pressed="true"]::before {
	background: currentColor;
	box-shadow: inset 0 0 0 2px var(--bg-raised);
}

.sheet-done {
	justify-self: end;
}

.sheet-backdrop {
	position: fixed;
	inset: 0;
	z-index: 40;
}

.sheet-backdrop[hidden] {
	display: none;
}

/* Badge and tooltip */
.badge {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 7px;
	min-width: 8.6rem;
	padding: 6px 12px 6px 10px;
	border: 1px solid currentColor;
	border-radius: 6px;
	color: var(--accent);
	font: 650 0.7rem/1.3 var(--font-ui);
	letter-spacing: 0.08em;
	text-transform: uppercase;
	white-space: nowrap;
	cursor: help;
}

.badge::before {
	content: "";
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: currentColor;
}

.badge.is-practice {
	color: var(--warn);
}

.badge.is-practice::before {
	border-radius: 1px;
	transform: rotate(45deg);
}

.tip {
	position: absolute;
	top: calc(100% + 8px);
	left: 50%;
	z-index: 30;
	width: max-content;
	max-width: min(280px, 80vw);
	padding: 8px 11px;
	border-radius: 8px;
	background: var(--text);
	color: var(--bg);
	font: 400 0.8125rem/1.45 var(--font-ui);
	letter-spacing: 0;
	text-align: left;
	text-transform: none;
	white-space: normal;
	box-shadow: var(--shadow);
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transform: translateX(-50%);
	transition: opacity var(--t), visibility 0s var(--t);
}

/* The test badge sits at the right edge: open its tooltip leftwards. */
.settings-bar .tip {
	right: 0;
	left: auto;
	transform: none;
}

.badge:hover .tip,
.badge:focus .tip {
	opacity: 1;
	visibility: visible;
	transition: opacity var(--t);
}

/* Live stats */
.live {
	display: flex;
	align-items: baseline;
	gap: 26px;
	min-height: 2rem;
	color: var(--dim);
	font: 500 0.95rem/1 var(--font-mono);
}

.live b {
	color: var(--live);
	font-weight: 600;
}

.live-time {
	min-width: 3ch;
	color: var(--timer);
	font-size: 1.6rem;
	font-weight: 650;
	font-variant-numeric: tabular-nums;
}

/* ---------- The text ---------- */
.stage {
	position: relative;
}

.tv {
	--fs: var(--test-fs, clamp(1.3rem, 0.95rem + 1.7vw, 2rem));
	--lh: 1.65;
	position: relative;
	height: calc(var(--fs) * var(--lh) * 3);
	overflow: hidden;
	color: var(--t-untyped);
	font-family: var(--font-mono);
	font-size: var(--fs);
	line-height: var(--lh);
	user-select: none;
	-webkit-user-select: none;
	transition: filter 250ms var(--ease), opacity 250ms var(--ease);
}

.tv-inner {
	position: relative;
	transition: transform 180ms var(--ease);
}

.tv-words {
	display: flex;
	flex-wrap: wrap;
	column-gap: 1ch;
}

.w {
	display: inline-block;
	white-space: pre;
}

.w .ok {
	color: var(--t-typed);
}

.w .no {
	color: var(--t-error);
	text-decoration: underline;
	text-decoration-thickness: 2px;
	text-underline-offset: 0.24em;
}

.w .ext {
	color: var(--err);
	opacity: 0.7;
	text-decoration: underline wavy;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.24em;
}

.w .miss {
	text-decoration: underline dotted var(--t-error);
	text-decoration-thickness: 2px;
	text-underline-offset: 0.24em;
}

/* Caret: a soft block with a bar underneath, gliding between characters */
.tv-caret {
	position: absolute;
	top: 0;
	left: 0;
	width: 1ch;
	height: calc(var(--fs) * var(--lh));
	pointer-events: none;
	transition: transform 95ms var(--ease);
}

.tv-caret::before,
.tv-caret::after {
	content: "";
	position: absolute;
	border-radius: 3px;
	background: var(--caret);
}

.tv-caret::before {
	inset: 17% -1px 17% -1px;
	opacity: 0.2;
}

.tv-caret::after {
	right: 0;
	bottom: 13%;
	left: 0;
	height: 3px;
}

body:not(.is-typing) .tv-test .tv-caret {
	animation: wpm-breathe 1.2s ease-in-out infinite;
}

@keyframes wpm-breathe {
	50% {
		opacity: 0.3;
	}
}

/* Hidden input that receives every keystroke (opens the on-screen keyboard) */
.type-input {
	position: absolute;
	inset: 0;
	z-index: 2;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	color: transparent;
	caret-color: transparent;
	font-size: 16px;
	opacity: 0;
	cursor: text;
}

.veil {
	position: absolute;
	inset: 0;
	z-index: 3;
	display: grid;
	place-items: center;
	pointer-events: none;
}

.veil[hidden] {
	display: none;
}

.veil p {
	margin: 0;
	padding: 10px 18px;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: var(--bg-raised);
	color: var(--text);
	font-size: 0.9375rem;
	box-shadow: var(--shadow);
}

.stage.is-blurred .tv {
	filter: blur(6px);
	opacity: 0.55;
}

/* Hints */
.hints {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-wrap: wrap;
	gap: 8px 16px;
	color: var(--dim);
	font-size: 0.8125rem;
}

.hints p {
	margin: 0;
}

.caps {
	color: var(--warn);
	font-weight: 650;
}

.caps::before {
	content: "\21EA\00a0";
}

/* ---------- Result view ---------- */
.view-result {
	padding-block: 28px 8px;
	outline: none;
}

.r-head {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 16px;
	text-align: center;
}

.r-big {
	display: flex;
	align-items: flex-start;
	justify-content: center;
	gap: 0.35em;
	margin: 0;
	line-height: 0.9;
}

.r-num {
	color: var(--r-number);
	font: 700 clamp(5.5rem, 3.5rem + 11vw, 10rem)/0.9 var(--font-mono);
	font-variant-numeric: tabular-nums;
	letter-spacing: -0.045em;
}

.r-unit {
	margin-top: 0.75em;
	color: var(--dim);
	font: 700 clamp(1rem, 0.8rem + 1vw, 1.5rem)/1 var(--font-ui);
	letter-spacing: 0.14em;
}

.r-sub {
	display: flex;
	justify-content: center;
	gap: clamp(22px, 7vw, 60px);
	margin: 4px 0 0;
}

.r-sub div {
	display: flex;
	flex-direction: column-reverse;
	align-items: center;
	gap: 4px;
}

.r-sub dt {
	color: var(--r-label);
	font-size: 0.7rem;
	font-weight: 650;
	letter-spacing: 0.14em;
	text-transform: uppercase;
}

.r-sub dd {
	margin: 0;
	color: var(--r-stats);
	font: 600 clamp(1.3rem, 1rem + 1.1vw, 1.8rem)/1.1 var(--font-mono);
}

.r-meta {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-wrap: wrap;
	gap: 8px 12px;
	margin: 0;
	color: var(--dim);
	font-size: 0.875rem;
}

.r-meta .badge {
	min-width: 0;
}

.r-pb {
	padding: 6px 11px;
	border-radius: 6px;
	background: var(--accent);
	color: var(--accent-ink);
	font-size: 0.7rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.r-pb::before {
	content: "\2191\00a0";
}

.r-pb[hidden] {
	display: none;
}

.r-verdict {
	max-width: 560px;
	margin: 0;
	color: var(--dim);
	font-size: 1.0625rem;
}

.r-verdict strong {
	color: var(--text);
	font-weight: 650;
}

.r-verdict strong::after {
	content: ".";
}

.r-actions {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 10px;
	margin: 32px 0 8px;
}

/* Ad / widget slots reserve their space so nothing shifts when an ad loads */
.ad-slot {
	display: block;
	min-height: var(--ad-min-height, 280px);
	margin: 32px auto;
	text-align: center;
}

.ad-slot-result {
	max-width: 760px;
}

/* ---------- Replay ---------- */
.replay {
	max-width: 900px;
	margin: 32px auto 8px;
	padding-top: 24px;
	border-top: 1px solid var(--line);
	outline: none;
}

.replay[hidden] {
	display: none;
}

.rp-top {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	margin-bottom: 10px;
	color: var(--dim);
	font-family: var(--font-mono);
}

.rp-top p {
	margin: 0;
}

#rp-wpm {
	color: var(--accent);
	font-size: 1.5rem;
	font-weight: 650;
}

.tv-replay {
	--fs: clamp(1.05rem, 0.9rem + 0.8vw, 1.45rem);
}

.rp-controls {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 6px 10px;
	margin-top: 14px;
}

.rp-scrub {
	flex: 1 1 160px;
	min-width: 140px;
	accent-color: var(--accent);
}

.rp-play .i-pause,
.rp-play.is-playing .i-play {
	display: none;
}

.rp-play.is-playing .i-pause {
	display: block;
}

.rp-hint {
	margin: 8px 0 0;
	color: var(--dim);
	font-size: 0.75rem;
}

/* ---------- Full analysis ---------- */
.reveal {
	display: grid;
	grid-template-rows: 0fr;
	opacity: 0;
	transition: grid-template-rows 450ms var(--ease), opacity 450ms var(--ease);
}

.reveal.is-open {
	grid-template-rows: 1fr;
	opacity: 1;
}

.reveal-inner {
	min-height: 0;
	overflow: hidden;
}

.analysis {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 44px 56px;
	padding-top: 44px;
}

.a-wide {
	grid-column: 1 / -1;
}

.a-sec h3,
.a-sec h4 {
	margin: 0 0 14px;
	color: var(--dim);
	font-size: 0.75rem;
	font-weight: 650;
	letter-spacing: 0.14em;
	text-transform: uppercase;
}

.a-sec h4 {
	margin-top: 22px;
}

.a-stats {
	display: grid;
	gap: 0;
	margin: 0;
}

.a-stats div {
	display: grid;
	grid-template-columns: 1fr auto;
	align-items: baseline;
	column-gap: 12px;
	padding: 9px 0;
	border-bottom: 1px solid var(--line);
}

.a-stats dd {
	margin: 0;
	font: 600 1.1rem/1.3 var(--font-mono);
	text-align: right;
}

.a-stats p {
	grid-column: 1 / -1;
	margin: 3px 0 0;
	color: var(--dim);
	font-size: 0.8125rem;
	line-height: 1.45;
}

.a-empty {
	margin: 0;
	color: var(--dim);
}

/* Chart */
.chart-box {
	min-height: 180px;
}

.chart {
	display: block;
	max-width: 100%;
	height: auto;
	overflow: visible;
}

.c-grid {
	stroke: var(--line);
	stroke-width: 1;
}

.c-label {
	fill: var(--dim);
	font: 11px var(--font-mono);
}

.c-area {
	fill: var(--accent);
	opacity: 0.09;
}

.c-line {
	fill: none;
	stroke: var(--chart-line);
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.c-avg {
	stroke: var(--text);
	stroke-width: 1.25;
	stroke-dasharray: 5 5;
	opacity: 0.75;
}

.c-avg-label {
	fill: var(--text);
	font: 600 11px var(--font-mono);
}

.c-err {
	stroke: var(--err);
	stroke-width: 2;
	stroke-linecap: round;
}

.c-dot {
	fill: var(--accent);
}

.c-legend {
	display: flex;
	flex-wrap: wrap;
	gap: 6px 22px;
	margin: 12px 0 0;
	color: var(--dim);
	font-size: 0.8125rem;
}

.c-legend span::before {
	content: "";
	display: inline-block;
	width: 18px;
	margin-right: 8px;
	border-top: 2px solid var(--accent);
	vertical-align: middle;
}

.c-legend .lg-avg::before {
	border-top: 2px dashed var(--text);
}

.c-legend .lg-err::before {
	content: "\00d7";
	width: auto;
	border: 0;
	color: var(--err);
	font-weight: 700;
}

/* Keyboard heatmap */
.kb {
	--k: clamp(21px, calc((100vw - 120px) / 12.6), 46px);
	--g: clamp(3px, 0.8vw, 6px);
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var(--g);
	font-family: var(--font-mono);
}

.kb-row {
	display: flex;
	gap: var(--g);
}

.kb-row-1 {
	padding-left: calc(var(--k) * 0.5);
}

.kb-row-2 {
	padding-left: calc(var(--k) * 0.25);
}

.kb-row-3 {
	padding-right: calc(var(--k) * 1.25);
}

.key {
	position: relative;
	z-index: 0;
	display: grid;
	place-items: center;
	width: var(--k);
	height: var(--k);
	overflow: hidden;
	border: 1px solid var(--line);
	border-radius: 7px;
	background: var(--bg-raised);
	color: var(--text);
	font-size: clamp(0.68rem, 0.6rem + 0.45vw, 0.95rem);
	line-height: 1;
}

.key::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	background: var(--heat);
	opacity: calc(var(--r, 0) * 0.55);
}

.key small {
	position: absolute;
	bottom: 2px;
	font-size: 0.55em;
	font-weight: 700;
}

.key.is-empty {
	border-style: dashed;
	background: transparent;
	color: var(--dim);
}

.key-space {
	width: calc(var(--k) * 6);
}

.kb-legend {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	margin-top: 14px;
	color: var(--dim);
	font-size: 0.75rem;
}

.kb-legend i {
	width: 120px;
	height: 8px;
	border: 1px solid var(--line);
	border-radius: 4px;
	background: linear-gradient(90deg, var(--bg-raised), var(--err));
}

/* Key lists */
.a-keys {
	display: grid;
	gap: 10px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.a-keys li {
	display: grid;
	grid-template-columns: 3.4em 1fr auto;
	align-items: center;
	gap: 12px;
	font-size: 0.875rem;
}

.a-keys li > span:last-child {
	color: var(--dim);
	font-family: var(--font-mono);
	white-space: nowrap;
}

.bar {
	position: relative;
	height: 6px;
	overflow: hidden;
	border-radius: 3px;
	background: var(--line);
}

.bar::after {
	content: "";
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	width: calc(var(--w, 0) * 100%);
	border-radius: 3px;
	background: var(--accent);
}

.bar-err::after {
	background: var(--err);
}

.a-words {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.a-words li {
	padding: 3px 9px;
	border-radius: 6px;
	background: var(--bg-raised);
	color: var(--err);
	font: 0.875rem/1.5 var(--font-mono);
	text-decoration: underline;
	text-underline-offset: 3px;
}

.a-words li.is-fixed {
	color: var(--dim);
	text-decoration: none;
}

.a-words small {
	font-family: var(--font-ui);
	font-size: 0.7rem;
}

.a-tips {
	display: grid;
	gap: 12px;
	margin: 0;
	padding: 0;
	list-style: none;
	font-size: 1.0625rem;
}

.a-tips li {
	position: relative;
	padding-left: 26px;
}

.a-tips li::before {
	content: "\2192";
	position: absolute;
	left: 0;
	color: var(--accent);
}

.a-how {
	margin: 0 0 12px;
	padding-left: 1.2em;
	font: 0.875rem/1.6 var(--font-mono);
}

.a-how li {
	margin: 6px 0;
}

.a-how li::marker {
	color: var(--accent);
}

.a-note {
	margin: 0;
	color: var(--dim);
	font-size: 0.875rem;
}

/* History */
.a-hist-top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 10px;
}

.spark {
	display: block;
}

.table-scroll {
	overflow-x: auto;
}

.a-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.875rem;
}

.a-table th,
.a-table td {
	padding: 9px 10px;
	border-bottom: 1px solid var(--line);
	text-align: left;
	white-space: nowrap;
}

.a-table th {
	color: var(--dim);
	font-size: 0.7rem;
	font-weight: 650;
	letter-spacing: 0.1em;
	text-transform: uppercase;
}

.a-table .num {
	font-family: var(--font-mono);
	text-align: right;
}

.tag {
	margin-left: 6px;
	color: var(--accent);
	font-size: 0.68rem;
	font-weight: 650;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.tag.is-practice {
	color: var(--warn);
}

/* ---------- Small screens: the settings panel becomes a bottom sheet ---------- */
@media (max-width: 599px) {
	.view-test {
		justify-content: flex-start;
		gap: 18px;
		min-height: 0;
		padding-top: 8px;
		padding-bottom: 24px;
	}

	.settings-summary {
		display: none;
	}

	.settings {
		position: fixed;
		top: auto;
		right: 0;
		bottom: 0;
		left: 0;
		width: auto;
		max-height: 85vh;
		overflow: auto;
		padding: 18px 16px calc(24px + env(safe-area-inset-bottom));
		border-width: 1px 0 0;
		border-radius: 12px 12px 0 0;
		animation-name: wpm-sheet-in;
		animation-duration: 260ms;
	}

	@keyframes wpm-sheet-in {
		from {
			transform: translateY(100%);
		}
	}

	.sheet-backdrop {
		background: rgba(28, 31, 36, 0.4);
	}

	.sheet-done {
		justify-self: stretch;
		justify-content: center;
	}

	.live {
		gap: 20px;
	}

	.r-actions {
		display: grid;
		grid-template-columns: 1fr 1fr;
	}

	.r-actions .btn {
		justify-content: center;
		padding-inline: 10px;
	}

	.analysis {
		grid-template-columns: minmax(0, 1fr);
		gap: 36px;
	}
}

/* Replay speed: same option buttons, in one row */
.rp-speed {
	display: flex;
	gap: 6px;
}

.rp-speed .opt > span {
	min-height: 34px;
	padding: 6px 10px;
}

/* ---------- Topic label, custom text, empty state ---------- */
.live > span {
	white-space: nowrap;
}

.live .live-topic {
	flex: 1 1 0;
	min-width: 0;
	margin-left: auto;
	overflow: hidden;
	text-align: right;
	color: var(--dim);
	font: 600 0.7rem/1.3 var(--font-ui);
	letter-spacing: 0.1em;
	text-overflow: ellipsis;
	text-transform: uppercase;
	white-space: nowrap;
}

.custom-box {
	display: grid;
	gap: 8px;
	margin-top: 12px;
}

.custom-box[hidden] {
	display: none;
}

.custom-label {
	color: var(--dim);
	font-size: 0.7rem;
	font-weight: 650;
	letter-spacing: 0.12em;
	text-transform: uppercase;
}

.custom-box textarea {
	width: 100%;
	min-height: 110px;
	padding: 10px 12px;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: var(--bg);
	color: var(--text);
	font: 0.9rem/1.5 var(--font-mono);
	resize: vertical;
}

.custom-box textarea:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 1px;
}

.custom-hint {
	margin: 0;
	color: var(--dim);
	font-size: 0.8125rem;
}

.custom-hint.is-error {
	color: var(--err);
	font-weight: 600;
}

.custom-box .btn {
	justify-self: start;
}

.empty-note {
	position: absolute;
	inset: 0;
	z-index: 1;
	display: grid;
	place-items: center;
	margin: 0;
	color: var(--dim);
	text-align: center;
}

.empty-note[hidden] {
	display: none;
}

/* A blocked key (letter where a space belongs) flashes the caret red */
.tv-caret.is-flash::before,
.tv-caret.is-flash::after {
	animation: wpm-flash 260ms ease-out;
}

@keyframes wpm-flash {
	0%,
	60% {
		background: var(--err);
		opacity: 0.85;
	}
}

/* ---------- Interactive speed chart ---------- */
.c-help {
	margin: -6px 0 12px;
	color: var(--dim);
	font-size: 0.8125rem;
}

.chart-box {
	position: relative;
}

.chart {
	touch-action: pan-y;
	cursor: crosshair;
	user-select: none;
	-webkit-user-select: none;
}

.chart:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 4px;
	border-radius: 6px;
}

.c-bar {
	fill: var(--chart-bar);
	opacity: 0.18;
	transition: opacity 120ms ease;
}

.c-bar.has-err {
	fill: var(--err);
	opacity: 0.22;
}

.c-bar.is-hot {
	opacity: 0.55;
}

.c-area {
	fill: var(--accent);
	opacity: 0.06;
}

.c-err-dot {
	fill: var(--err);
	pointer-events: none;
}

.c-hit {
	fill: transparent;
}

.c-cursor {
	pointer-events: none;
	transition: transform 90ms var(--ease), opacity 150ms ease;
}

.c-cursor.no-anim,
.c-cursor.no-anim .c-cursor-dot {
	transition: none;
}

.c-cursor line {
	stroke: var(--text);
	stroke-width: 1;
	stroke-dasharray: 3 3;
	opacity: 0.6;
}

.c-cursor-dot {
	fill: var(--bg-raised);
	stroke: var(--accent);
	stroke-width: 2.5;
	transition: cy 90ms var(--ease);
}

.c-tip {
	position: absolute;
	top: -8px;
	left: 0;
	z-index: 5;
	display: flex;
	gap: 10px;
	padding: 6px 10px;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: var(--bg-raised);
	box-shadow: var(--shadow);
	color: var(--dim);
	font: 0.78rem/1.3 var(--font-ui);
	white-space: nowrap;
	pointer-events: none;
	transform: translateY(-100%);
	transition: transform 90ms var(--ease);
}

.c-tip[hidden] {
	display: none;
}

.c-tip strong {
	color: var(--text);
}

.c-tip .is-err {
	color: var(--err);
	font-weight: 600;
}

.c-legend .lg-bar::before {
	width: 10px;
	height: 12px;
	border: 0;
	border-radius: 2px;
	background: var(--accent);
	opacity: 0.35;
}

.c-legend .lg-err::before {
	content: "";
	width: 8px;
	height: 8px;
	border: 0;
	border-radius: 50%;
	background: var(--err);
}

.c-detail {
	margin-top: 16px;
	padding: 14px 16px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: var(--bg-raised);
	animation: wpm-panel-in 180ms var(--ease);
}

.c-detail[hidden] {
	display: none;
}

.c-detail-head {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 6px 16px;
	color: var(--dim);
	font-size: 0.875rem;
}

.c-detail-head strong {
	color: var(--text);
	font-size: 0.75rem;
	letter-spacing: 0.1em;
	text-transform: uppercase;
}

.c-typed {
	margin: 10px 0 12px;
	font: 1.05rem/1.6 var(--font-mono);
	overflow-wrap: anywhere;
}

.c-typed .k-ok {
	color: var(--text);
}

.c-typed .k-no {
	color: var(--err);
	text-decoration: underline;
	text-decoration-thickness: 2px;
}

.c-typed .k-back {
	margin: 0 2px;
	color: var(--warn);
	font-size: 0.85em;
}

.c-typed em {
	color: var(--dim);
	font: italic 0.9rem var(--font-ui);
}

/* ---------- Caret styles (Customizer) ---------- */
.caret-line .tv-caret {
	width: 3px;
	margin-left: -1px;
}

.caret-line .tv-caret::before {
	inset: 14% 0;
	border-radius: 2px;
	opacity: 1;
}

.caret-line .tv-caret::after,
.caret-underline .tv-caret::before {
	display: none;
}

.caret-instant .tv-caret {
	transition: none;
}
