/*
 * On-screen keyboard and typing session UI. Loaded only on views that run the app.
 */

/* ---------- Session layout ---------- */
.ty-session {
	display: grid;
	gap: 1.1rem;
}

.ty-session.is-blocked .ty-toolbar,
.ty-session.is-blocked .ty-timerbar,
.ty-session.is-blocked .ty-kb-wrap {
	display: none;
}

.ty-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.75rem 1.25rem;
}

.ty-live {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin: 0 auto 0 0;
}

.ty-live div {
	display: flex;
	flex-direction: column-reverse;
	min-width: 5.5rem;
	padding: 0.35rem 0.9rem;
	border: 1px solid var(--ty-line);
	border-radius: 12px;
	background: var(--ty-surface);
}

.ty-live dt {
	color: var(--ty-muted);
	font-size: 0.72rem;
	font-weight: 500;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.ty-live dd {
	margin: 0;
	font-family: var(--ty-font-mono);
	font-size: 1.3rem;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	line-height: 1.3;
}

.ty-caps {
	margin: 0;
}

/* ---------- Stage: the text being typed ---------- */
.ty-stage {
	position: relative;
	padding: clamp(1.1rem, 3vw, 1.75rem) clamp(1.1rem, 3.5vw, 2.25rem);
	border: 2px solid var(--ty-line);
	border-radius: var(--ty-radius);
	background: var(--ty-surface);
	cursor: text;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ty-stage.is-focused {
	border-color: color-mix(in srgb, var(--ty-primary) 70%, var(--ty-line));
	box-shadow: 0 0 0 5px color-mix(in srgb, var(--ty-primary) 12%, transparent);
}

.ty-stage.is-complete {
	cursor: default;
	opacity: 0.7;
}

/* The field that owns keyboard input: focusable, invisible, never zooms on iOS. */
.ty-input {
	position: absolute;
	top: 0;
	left: 0;
	width: 1px;
	height: 1px;
	padding: 0;
	border: 0;
	opacity: 0;
	font-size: 16px;
	resize: none;
	pointer-events: none;
}

.ty-text {
	--ty-line-h: 2em;
	overflow: hidden;
	height: calc(var(--ty-line-h) * 3);
	font-family: var(--ty-font-mono);
	font-size: clamp(1.3rem, 2.7vw, 1.8rem);
	font-weight: 400;
}

.ty-text__inner {
	position: relative;
	/* Room for the space at the end of a line, which hangs past the text edge. */
	padding-right: 1.2ch;
	line-height: var(--ty-line-h);
	transition: transform 0.2s ease;
	word-break: normal;
	overflow-wrap: normal;
}

.ty-ch {
	position: relative;
	border-radius: 5px;
	color: var(--ty-ink);
	white-space: pre-wrap;
}

.ty-ch.is-ok {
	color: var(--ty-good);
}

.ty-ch.is-bad {
	background: var(--ty-bad-bg);
	color: var(--ty-bad);
	text-decoration: underline wavy var(--ty-bad);
	text-decoration-thickness: 1px;
	text-underline-offset: 0.2em;
}

/*
 * Spaces are left blank (a dot would look like a full stop and get typed).
 * The next character's box, a space included, is always highlighted.
 */
.ty-ch.is-space.is-current {
	box-shadow: inset 0 -3px 0 var(--ty-primary), inset 0 0 0 1px color-mix(in srgb, var(--ty-primary) 35%, transparent);
}

.ty-ch.is-bad.is-space {
	background: color-mix(in srgb, var(--ty-bad) 35%, transparent);
}

.ty-ch.is-current {
	background: color-mix(in srgb, var(--ty-primary) 16%, transparent);
	color: var(--ty-ink);
	box-shadow: inset 0 -3px 0 var(--ty-primary);
}

.ty-stage:not(.is-focused) .ty-ch.is-current {
	box-shadow: inset 0 -3px 0 var(--ty-line);
}

.ty-ch.is-miss {
	animation: ty-miss 0.3s ease;
}

@keyframes ty-miss {
	0%,
	100% {
		transform: translateX(0);
	}

	30% {
		transform: translateX(-2px);
	}

	60% {
		transform: translateX(2px);
	}
}

.ty-stage__overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
	border-radius: inherit;
	background: color-mix(in srgb, var(--ty-surface) 70%, transparent);
	backdrop-filter: blur(3px);
	color: var(--ty-ink);
	font-weight: 600;
	text-align: center;
}

.ty-stage__overlay[hidden] {
	display: none;
}

@media (prefers-reduced-motion: reduce) {
	.ty-text__inner {
		transition: none;
	}

	.ty-ch.is-miss {
		animation: none;
		outline: 2px solid var(--ty-bad);
	}
}

/* ---------- Keyboard ---------- */
.ty-kb {
	--ty-kb-gap: clamp(3px, 0.5vw, 6px);
	display: grid;
	gap: var(--ty-kb-gap);
	width: 100%;
	max-width: 880px;
	margin-inline: auto;
	padding: clamp(8px, 1.4vw, 14px);
	border: 1px solid var(--ty-line);
	border-radius: calc(var(--ty-radius) + 2px);
	background: var(--ty-surface-2);
	user-select: none;
	font-family: var(--ty-font-sans);
}

.ty-kb__row {
	display: flex;
	gap: var(--ty-kb-gap);
}

.ty-kb__key,
.ty-kb__gap {
	flex: var(--w) 1 0;
	min-width: 0;
}

.ty-kb__key {
	position: relative;
	display: flex;
	aspect-ratio: calc(var(--w) * 1.05) / 1;
	border: 1px solid color-mix(in srgb, var(--ty-f) 35%, var(--ty-line));
	border-radius: clamp(5px, 0.8vw, 10px);
	background: color-mix(in srgb, var(--ty-f) 13%, var(--ty-surface));
	box-shadow: inset 0 -3px 0 color-mix(in srgb, var(--ty-f) 70%, transparent);
	color: var(--ty-ink);
	transition: transform 0.08s ease, background-color 0.12s ease, box-shadow 0.12s ease;
}

.ty-kb__key.ty-finger--none {
	--ty-f: var(--ty-line);
}

.ty-kb__cap {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	width: 100%;
	padding-bottom: 3px;
	overflow: hidden;
	font-size: clamp(0.62rem, 1.5vw, 1rem);
	font-weight: 500;
	line-height: 1.1;
}

.ty-kb__cap.is-named {
	font-size: clamp(0.5rem, 1.05vw, 0.78rem);
	font-weight: 400;
	white-space: nowrap;
}

.ty-kb__shift {
	color: var(--ty-muted);
	font-size: 0.75em;
}

.ty-kb__key.has-bump::after {
	content: "";
	position: absolute;
	bottom: 16%;
	left: 50%;
	width: 24%;
	height: 2px;
	border-radius: 2px;
	background: currentcolor;
	opacity: 0.6;
	transform: translateX(-50%);
}

.ty-kb__key.is-next {
	z-index: 1;
	background: var(--ty-f);
	border-color: color-mix(in srgb, var(--ty-f) 60%, #000);
	box-shadow: 0 0 0 4px color-mix(in srgb, var(--ty-f) 40%, transparent), 0 6px 14px color-mix(in srgb, var(--ty-f) 45%, transparent), inset 0 -3px 0 rgb(0 0 0 / 18%);
	color: #1a1d2e;
	font-weight: 700;
	transform: translateY(-2px);
}

.ty-kb__key.is-next .ty-kb__shift {
	color: #1a1d2e;
}

.ty-kb__key.is-pressed {
	transform: translateY(2px);
}

.ty-kb__key.is-wrong {
	background: color-mix(in srgb, var(--ty-bad) 30%, var(--ty-surface));
	animation: ty-flash 0.32s ease;
}

@keyframes ty-flash {
	from {
		box-shadow: 0 0 0 4px color-mix(in srgb, var(--ty-bad) 45%, transparent);
	}

	to {
		box-shadow: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ty-kb__key {
		transition: none;
	}

	.ty-kb__key.is-pressed {
		transform: none;
	}

	.ty-kb__key.is-wrong {
		animation: none;
		outline: 2px solid #d9534f;
	}
}

/* Heatmap after a test: tint by finger accuracy; finger names are listed in the results. */
.ty-kb.is-heatmap .ty-kb__key {
	--ty-f: var(--ty-line);
}

.ty-kb.is-heatmap .ty-kb__key[data-heat="good"] {
	--ty-f: #40c057;
}

.ty-kb.is-heatmap .ty-kb__key[data-heat="ok"] {
	--ty-f: #fab005;
}

.ty-kb.is-heatmap .ty-kb__key[data-heat="weak"] {
	--ty-f: #f06a5f;
}

.ty-kb.is-heatmap .ty-kb__key[data-heat] {
	background: color-mix(in srgb, var(--ty-f) 50%, var(--ty-surface));
}

/* ---------- Results ---------- */
.ty-results {
	padding: clamp(1.25rem, 3.5vw, 2.25rem);
	border: 1px solid var(--ty-line);
	border-radius: var(--ty-radius);
	background: var(--ty-surface);
	box-shadow: var(--ty-shadow);
}

.ty-results__title {
	font-size: 1.45rem;
}

.ty-results__title:focus {
	outline: none;
}

.ty-results__headline {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
	gap: 0.75rem;
	margin-bottom: 0.9rem;
}

.ty-stat {
	display: flex;
	flex-direction: column;
	gap: 0.2rem;
	margin: 0;
	padding: 1rem 1.2rem;
	border-radius: 14px;
	background: var(--ty-surface-2);
}

.ty-stat__label {
	color: var(--ty-muted);
	font-size: 0.85rem;
	font-weight: 500;
}

.ty-stat__num {
	font-family: var(--ty-font-mono);
	font-size: clamp(2.2rem, 6vw, 3rem);
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	line-height: 1.05;
}

.ty-stat--acc {
	background: color-mix(in srgb, var(--ty-accent) 12%, var(--ty-surface));
}

.ty-stat--acc .ty-stat__num {
	color: var(--ty-good);
}

.ty-results__explain {
	max-width: 70ch;
	color: var(--ty-muted);
	font-size: 0.92rem;
}

.ty-results__more {
	margin-bottom: 1.25rem;
	padding: 0.75rem 1rem;
	border-radius: 12px;
	background: var(--ty-surface-2);
}

.ty-results__more summary {
	font-weight: 600;
	cursor: pointer;
}

.ty-results__more .ty-results__facts {
	margin: 0.75rem 0 0;
}

.ty-results__facts {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
	gap: 0.5rem 1.5rem;
	margin: 0 0 1.5rem;
}

.ty-results__facts dt {
	color: var(--ty-muted);
	font-size: 0.85rem;
}

.ty-results__facts dd {
	margin: 0;
	font-weight: 600;
}

.ty-results__sub {
	font-size: 1.05rem;
}

.ty-results__fingers {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
	gap: 0.4rem 1.5rem;
	margin: 0 0 0.75rem;
	padding: 0;
	list-style: none;
}

.ty-results__finger {
	display: grid;
	grid-template-columns: auto 1fr auto;
	align-items: center;
	gap: 0 0.6rem;
	padding: 0.35rem 0;
	border-bottom: 1px dashed var(--ty-line);
}

.ty-results__dot {
	width: 0.85rem;
	height: 0.85rem;
	border-radius: 50%;
	background: var(--ty-f);
}

.ty-results__pct {
	font-family: var(--ty-font-mono);
	font-weight: 700;
}

.ty-results__level {
	grid-column: 2 / 4;
	color: var(--ty-muted);
	font-size: 0.82rem;
}

.ty-results__finger.is-weak .ty-results__level {
	color: var(--ty-bad);
	font-weight: 600;
}

.ty-results__legend {
	color: var(--ty-muted);
	font-size: 0.88rem;
}

.ty-results__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
}

/* ---------- No keyboard (touch devices) ---------- */
.ty-nokb {
	padding: 1.5rem;
	border: 1px dashed var(--ty-line);
	border-radius: var(--ty-radius);
	text-align: center;
}

.ty-nokb .ty-actions {
	justify-content: center;
}

/* ---------- Lesson (day pages) ---------- */
.ty-stepbar {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem;
	margin: 0 auto 0 0;
	padding: 0;
	list-style: none;
	counter-reset: ty-step;
}

.ty-stepbar li {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	padding: 0.3rem 0.75rem 0.3rem 0.35rem;
	border-radius: 999px;
	background: var(--ty-surface-2);
	color: var(--ty-muted);
	font-size: 0.85rem;
	font-weight: 500;
	counter-increment: ty-step;
}

.ty-stepbar li::before {
	content: counter(ty-step);
	display: inline-grid;
	place-items: center;
	width: 1.45rem;
	height: 1.45rem;
	border-radius: 50%;
	background: var(--ty-surface);
	font-size: 0.75rem;
}

.ty-stepbar li.is-current {
	background: color-mix(in srgb, var(--ty-primary) 12%, var(--ty-surface));
	color: var(--ty-ink);
	font-weight: 600;
}

.ty-stepbar li.is-current::before {
	background: var(--ty-primary);
	color: var(--ty-on-primary);
}

.ty-stepbar li.is-done::before {
	content: "✓";
	background: var(--ty-accent);
	color: #fff;
}

.ty-coachline {
	margin: 0;
	padding: 0.8rem 1.1rem;
	border: 1px solid color-mix(in srgb, var(--ty-accent) 25%, var(--ty-line));
	border-radius: 14px;
	background: color-mix(in srgb, var(--ty-accent) 7%, var(--ty-surface));
	font-size: 1.05rem;
}

.ty-coachline[hidden] {
	display: none;
}

.ty-coachline__who {
	padding: 0.1rem 0.6rem;
	border-radius: 999px;
	background: color-mix(in srgb, var(--ty-f, var(--ty-accent)) 35%, var(--ty-surface));
	font-weight: 600;
}

.ty-stepmeta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 1rem;
	min-height: 2.25rem;
	color: var(--ty-muted);
	font-size: 0.92rem;
}

.ty-stepmeta__clock {
	color: var(--ty-ink);
	font-family: var(--ty-font-mono);
	font-size: 1.2rem;
	font-weight: 600;
}

.ty-card-note--rest {
	text-align: center;
}

.ty-rest__count {
	font-family: var(--ty-font-mono);
	font-size: 2.5rem;
	font-weight: 600;
}

.ty-wrap__facts {
	margin: 0 0 1rem;
	padding-left: 1.2rem;
}

.ty-wrap__facts li + li {
	margin-top: 0.3rem;
}

.ty-wrap__encourage {
	font-size: 1.1rem;
	font-weight: 500;
}

/* ---------- Practice: custom text ---------- */
.ty-custom {
	display: grid;
	gap: 0.5rem;
}

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

.ty-custom__label {
	font-weight: 700;
}

.ty-custom__text {
	min-height: 6rem;
	font-family: var(--ty-font-mono);
}

.ty-custom__hint {
	margin: 0;
	color: var(--ty-muted);
	font-size: 0.88rem;
}

.ty-custom .ty-button {
	justify-self: start;
}

/* ---------- Coach: letters mastered + milestone line ---------- */
.ty-coach {
	display: grid;
	gap: 0.3rem;
	flex: 1 1 260px;
	min-width: 0;
}

.ty-coach__mastered {
	position: relative;
	justify-self: start;
	min-width: 12rem;
	margin: 0;
	padding-bottom: 7px;
	color: var(--ty-muted);
	font-size: 0.85rem;
	font-weight: 500;
}

.ty-coach__mastered::after {
	content: "";
	position: absolute;
	right: 0;
	bottom: 0;
	left: 0;
	height: 4px;
	border-radius: 2px;
	background: linear-gradient(90deg, var(--ty-accent) calc(var(--ty-progress, 0) * 100%), var(--ty-line) 0);
}

/* Always one line tall, so a milestone never moves the typing text. */
.ty-coach__news {
	min-height: 1.5em;
	margin: 0;
	overflow: hidden;
	color: var(--ty-good);
	font-size: 0.92rem;
	font-weight: 600;
	line-height: 1.5;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.ty-coach__news:not(:empty) {
	animation: ty-news-in 0.25s ease;
}

@keyframes ty-news-in {
	from {
		opacity: 0;
		transform: translateY(-3px);
	}
}

@media (prefers-reduced-motion: reduce) {
	.ty-coach__news:not(:empty) {
		animation: none;
	}
}

.ty-messages:empty {
	display: none;
}

.ty-stage-wrap:empty,
.ty-results-wrap:empty,
.ty-stepmeta:empty {
	display: none;
}

/* ---------- Keyboard and sound switches ---------- */
.ty-toggles {
	display: inline-flex;
	gap: 0.4rem;
	margin-left: auto;
}

.ty-toggle {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	min-height: 40px;
	padding: 0.35rem 0.8rem;
	border: 1px solid var(--ty-line);
	border-radius: 999px;
	background: var(--ty-surface);
	color: var(--ty-muted);
	font: inherit;
	font-size: 0.88rem;
	font-weight: 500;
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.ty-toggle:hover {
	border-color: var(--ty-primary);
	color: var(--ty-ink);
}

.ty-toggle[aria-pressed="true"] {
	border-color: color-mix(in srgb, var(--ty-primary) 40%, var(--ty-line));
	background: color-mix(in srgb, var(--ty-primary) 10%, var(--ty-surface));
	color: var(--ty-link);
}

/* Off state: keyboard icon struck through; speaker shows a cross instead of waves. */
.ty-toggle--keyboard[aria-pressed="false"] svg {
	opacity: 0.55;
}

.ty-toggle--sound .ty-toggle__mute,
.ty-toggle--sound[aria-pressed="false"] .ty-toggle__waves {
	display: none;
}

.ty-toggle--sound[aria-pressed="false"] .ty-toggle__mute {
	display: inline;
}

.ty-kb-wrap[hidden] {
	display: none;
}

@media (max-width: 520px) {
	.ty-toggle__label {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip-path: inset(50%);
		white-space: nowrap;
	}
}

/* ---------- Session chart and replay ---------- */
.ty-session-chart {
	margin: 0 0 1.25rem;
}

.ty-session-chart__legend {
	display: flex;
	align-items: flex-start;
	gap: 0.45rem;
	margin: 0.35rem 0 0;
	color: var(--ty-muted);
	font-size: 0.82rem;
}

.ty-session-chart__dot {
	flex: none;
	margin-top: 0.4em;
	width: 0.65rem;
	height: 0.65rem;
	border-radius: 50%;
	background: var(--ty-bad);
}

.ty-replay-box {
	margin: 0 0 1.5rem;
	padding: 0.9rem 1.1rem;
	border: 1px solid var(--ty-line);
	border-radius: 16px;
	background: var(--ty-surface);
}

.ty-replay-box__summary {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	font-weight: 600;
	cursor: pointer;
	list-style: none;
}

.ty-replay-box__summary::-webkit-details-marker {
	display: none;
}

.ty-replay-box__summary::before {
	content: "";
	width: 0;
	height: 0;
	border-top: 0.4rem solid transparent;
	border-bottom: 0.4rem solid transparent;
	border-left: 0.65rem solid var(--ty-primary);
}

.ty-replay-box[open] .ty-replay-box__summary::before {
	transform: rotate(90deg);
}

.ty-replay-box__lead {
	margin: 0.4rem 0 0.9rem;
	color: var(--ty-muted);
	font-size: 0.92rem;
}

.ty-replay {
	display: grid;
	gap: 0.75rem;
}

.ty-replay__stage {
	cursor: default;
}

/* Which exercise the lesson replay is showing. */
.ty-replay__part {
	margin: 0 0 0.35rem;
	font-size: 0.85rem;
	font-weight: 600;
	color: var( --ty-muted );
}

.ty-replay__bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.6rem 1rem;
}

.ty-replay__play {
	min-width: 7rem;
}

.ty-replay__scrub {
	flex: 1 1 200px;
	min-height: 0;
	padding: 0;
	border: 0;
	accent-color: var(--ty-primary);
}

.ty-replay__time,
.ty-replay__wpm {
	font-family: var(--ty-font-mono);
	font-size: 0.95rem;
	font-variant-numeric: tabular-nums;
}

.ty-replay__wpm {
	color: var(--ty-link);
	font-weight: 600;
}

/* ---------- Focus mode: the text alone, full screen ---------- */
.ty-focusfoot {
	display: none;
}

.ty-focus-on,
.ty-focus-on body {
	overflow: hidden;
}

.ty-session.is-focus {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 0;
	padding: 6vh max(6vw, 24px);
	overflow-y: auto;
	background: var(--ty-surface);
}

.ty-session.is-focus > :not(.ty-stage-wrap):not(.ty-focusfoot):not(.ty-caps) {
	display: none !important;
}

.ty-session.is-focus .ty-caps {
	align-self: center;
	margin-bottom: 1.5rem;
}

.ty-session.is-focus .ty-stage-wrap {
	width: 100%;
	max-width: 1200px;
	margin-inline: auto;
}

.ty-session.is-focus .ty-stage {
	padding: 0;
	border: 0;
	background: transparent;
	box-shadow: none;
}

.ty-session.is-focus .ty-stage.is-focused {
	box-shadow: none;
}

.ty-session.is-focus .ty-text {
	--ty-line-h: 2.05em;
	font-size: clamp(1.6rem, 3.3vw, 2.6rem);
	letter-spacing: 0.02em;
}

.ty-session.is-focus.is-expanded .ty-text {
	height: calc(var(--ty-line-h) * 6);
	font-size: clamp(1.8rem, 3.8vw, 3rem);
}

.ty-session.is-focus .ty-stage__overlay {
	background: color-mix(in srgb, var(--ty-surface) 80%, transparent);
	font-size: 1.1rem;
}

.ty-session.is-focus .ty-focusfoot {
	display: grid;
	justify-items: center;
	gap: 1.1rem;
	margin-top: clamp(1.5rem, 5vh, 3rem);
}

.ty-focusbar {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.25rem 1.5rem;
}

.ty-focusbar__btn {
	min-height: 44px;
	padding: 0.4rem 0.3rem;
	border: 0;
	background: none;
	color: var(--ty-muted);
	font: inherit;
	font-size: 1.05rem;
	font-weight: 500;
	cursor: pointer;
}

.ty-focusbar__btn:hover {
	color: var(--ty-ink);
}

.ty-focusbar__btn.is-exit {
	color: var(--ty-link);
}

.ty-focusbar__hint {
	margin: 0;
	color: var(--ty-muted);
	font-size: 0.92rem;
}

.ty-focusbar__hint kbd {
	padding: 0.1rem 0.45rem;
	border: 1px solid var(--ty-line);
	border-bottom-width: 2px;
	border-radius: 6px;
	background: var(--ty-surface);
	font-size: 0.85rem;
}

.ty-session.is-focus .ty-card-note {
	max-width: 720px;
	margin-inline: auto;
}

/* ---------- Style variants: typing line and results ---------- */
.ty-typing--outlined .ty-stage {
	border-color: color-mix(in srgb, var(--ty-ink) 22%, var(--ty-line));
}

.ty-results--compact .ty-results__headline {
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), max-content));
}

.ty-results--compact .ty-stat {
	flex-direction: row;
	align-items: baseline;
	gap: 0.6rem;
	padding: 0.6rem 1rem;
}

.ty-results--compact .ty-stat__num {
	font-size: 1.8rem;
}

.ty-results--bold .ty-results__headline {
	gap: 0;
	overflow: hidden;
	border-radius: 16px;
	background: var(--ty-primary);
}

.ty-results--bold .ty-stat {
	border-radius: 0;
	background: transparent;
	color: var(--ty-on-primary);
}

.ty-results--bold .ty-stat__label,
.ty-results--bold .ty-stat--acc .ty-stat__num {
	color: var(--ty-on-primary);
}

.ty-results--bold .ty-stat + .ty-stat {
	border-left: 1px solid rgb(255 255 255 / 25%);
}

/* ---------- Timer picker (Typing Test, Practice) ---------- */
.ty-duration {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 0.75rem;
}

.ty-duration__custom {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.4rem 0.6rem;
}

.ty-duration__custom[hidden] {
	display: none;
}

.ty-duration__label {
	font-weight: 600;
}

.ty-duration .ty-duration__input {
	width: 5.5rem;
	min-height: 40px;
	padding: 0.35rem 0.6rem;
	border: 1px solid var(--ty-line-strong, var(--ty-line));
	border-radius: 10px;
	background: var(--ty-surface);
	color: var(--ty-ink);
	font: inherit;
	font-variant-numeric: tabular-nums;
}

.ty-duration .ty-duration__input[aria-invalid="true"] {
	border-color: var(--ty-bad);
}

.ty-duration__hint {
	color: var(--ty-muted);
	font-size: 0.9rem;
}

.ty-duration__input[aria-invalid="true"] ~ .ty-duration__hint {
	color: var(--ty-bad);
}

.ty-timerbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 0.9rem;
}

.ty-timerbar__label {
	color: var(--ty-muted);
	font-weight: 600;
}

.ty-sessionctl {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 0.75rem;
	margin-left: auto;
}

.ty-sessionctl[hidden] {
	display: none;
}

.ty-sessionctl__clock {
	margin: 0;
	color: var(--ty-muted);
}

.ty-sessionctl__time {
	display: inline-block;
	min-width: 3.2em;
	color: var(--ty-ink);
	font-family: var(--ty-font-mono);
	font-size: 1.15rem;
	font-variant-numeric: tabular-nums;
}

.ty-sessionctl.is-paused .ty-sessionctl__time {
	color: var(--ty-muted);
}

/* ---------- Detailed report (results) ---------- */
.ty-report {
	margin: 1.25rem 0;
	border: 1px solid var(--ty-line);
	border-radius: var(--ty-radius-sm);
	background: var(--ty-surface);
}

.ty-report__summary {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0.25rem 0.75rem;
	padding: 0.9rem 1.1rem;
	cursor: pointer;
}

.ty-report__title {
	font-weight: 700;
}

.ty-report__hint {
	color: var(--ty-muted);
	font-size: 0.93rem;
}

.ty-report__body {
	padding: 0 1.1rem 1.1rem;
}

.ty-report__facts {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
	gap: 0.6rem;
	margin: 0 0 1rem;
}

.ty-report__facts div {
	padding: 0.6rem 0.8rem;
	border-radius: 10px;
	background: var(--ty-surface-2);
}

.ty-report__facts dt {
	color: var(--ty-muted);
	font-size: 0.82rem;
}

.ty-report__facts dd {
	margin: 0;
	font-size: 1.25rem;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

.ty-report__h {
	margin: 1.25rem 0 0.35rem;
	font-size: 1.02rem;
}

.ty-report__lead,
.ty-report__empty {
	margin: 0 0 0.6rem;
	color: var(--ty-muted);
	font-size: 0.92rem;
}

.ty-report__scroll {
	overflow-x: auto;
	margin-bottom: 0.6rem;
}

.ty-report__table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.95rem;
}

.ty-report__table th,
.ty-report__table td {
	padding: 0.45rem 0.6rem;
	border-bottom: 1px solid var(--ty-line);
	text-align: left;
	vertical-align: middle;
}

.ty-report__table th {
	color: var(--ty-muted);
	font-size: 0.82rem;
	font-weight: 600;
}

.ty-report__word {
	font-family: var(--ty-font-mono);
	font-size: 1.05rem;
	white-space: pre;
}

.ty-report__word .is-expected {
	border-radius: 4px;
	background: color-mix(in srgb, var(--ty-good) 16%, transparent);
	color: var(--ty-good);
	font-weight: 700;
	text-decoration: underline;
}

.ty-report__word .is-typed-wrong {
	border-radius: 4px;
	background: var(--ty-bad-bg);
	color: var(--ty-bad);
	font-weight: 700;
	text-decoration: underline wavy;
}

.ty-report__key {
	display: inline-block;
	min-width: 1.7em;
	padding: 0.05rem 0.4rem;
	border: 1px solid var(--ty-line);
	border-bottom-width: 2px;
	border-radius: 6px;
	background: var(--ty-surface);
	font-family: var(--ty-font-mono);
	font-size: 0.9rem;
	text-align: center;
}

.ty-report__key.is-wrong {
	border-color: color-mix(in srgb, var(--ty-bad) 45%, var(--ty-line));
	color: var(--ty-bad);
}

.ty-report__pair {
	display: inline-flex;
	align-items: center;
	gap: 0.25rem;
	white-space: nowrap;
}

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

.ty-report__num {
	font-variant-numeric: tabular-nums;
}

.ty-report__table .is-fixed {
	color: var(--ty-good);
}

.ty-report__table .is-left {
	color: var(--ty-bad);
	font-weight: 600;
}

.ty-report__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.ty-report__chips li {
	padding: 0.35rem 0.7rem;
	border: 1px solid var(--ty-line);
	border-radius: 999px;
	background: var(--ty-surface-2);
	font-size: 0.92rem;
}

/* ---------- Lesson: practice time today ---------- */
.ty-daytime {
	display: inline-flex;
	align-items: baseline;
	gap: 0.4rem;
	margin: 0;
	padding: 0.3rem 0.8rem;
	border: 1px solid var(--ty-line);
	border-radius: 999px;
	background: var(--ty-surface);
	color: var(--ty-muted);
	font-size: 0.9rem;
}

.ty-daytime__time {
	color: var(--ty-ink);
	font-family: var(--ty-font-mono);
	font-size: 1rem;
	font-variant-numeric: tabular-nums;
}
