/* Chinese Learning Hub — lesson player styles. */

.clh-root {
	color: var(--clh-text);
	font-family: var(--clh-font);
	font-size: 17px;
	line-height: 1.6;
	background: var(--clh-bg);
	padding: 8px 16px 64px;
	box-sizing: border-box;
	max-width: 720px;
	margin: 0 auto;
}

/* Break out of the theme's constrained post-content width (typically ~645px)
   so the player can use its full 720px, centred, with its own padding. */
#clh-lesson {
	box-sizing: border-box;
	width: 100%;
	max-width: 720px;
	margin-left: auto;
	margin-right: auto;
}

.clh-root *,
.clh-root *::before,
.clh-root *::after {
	box-sizing: border-box;
}

/* ---- Top bar ---- */

.clh-topbar {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: 12px 16px;
	padding: 8px 0 4px;
}

.clh-topbar-title {
	min-width: 0;
}

.clh-topbar-unit {
	font-size: 0.76rem;
	font-weight: 800;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--clh-accent-text);
	margin-bottom: 2px;
}

.clh-topbar-heading {
	font-size: 1.7rem;
	margin: 0;
}

.clh-topbar-controls {
	display: flex;
	gap: 8px;
}

/* Only the progress row stays on screen while scrolling: persistent chrome is
   kept minimal so the exercise has the room. One line: leave, progress, XP.
   It sits below the WP admin bar (logged in) via --clh-sticky-top; the site
   header scrolls away in a lesson. */
.clh-progress-sticky {
	position: sticky;
	top: var(--clh-sticky-top, 0px);
	z-index: 10;
	display: flex;
	align-items: center;
	gap: 12px;
	background: var(--clh-bg);
	padding: 12px 0;
	margin-bottom: 12px;
}

.clh-progress-sticky .clh-progress-track {
	flex: 1;
	height: 16px;
}

.clh-progress-sticky .clh-progress-fill::after {
	top: 4px;
	height: 4px;
}

.clh-exit {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	margin-left: -8px;
	border-radius: 50%;
	color: var(--clh-text-muted);
	text-decoration: none;
	flex: none;
}

.clh-exit:hover {
	background: var(--clh-sunken);
	color: var(--clh-text);
}

.clh-progress-text {
	font-size: 0.85rem;
	font-weight: 700;
	color: var(--clh-text-muted);
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.clh-progress-sticky .clh-xp {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 4px 10px;
	border-radius: 999px;
	background: var(--clh-gold-soft);
	font-size: 0.85rem;
	white-space: nowrap;
}

/* ---- Sections ---- */

.clh-sections {
	display: flex;
	flex-direction: column;
	gap: 20px;
}

.clh-section {
	background: var(--clh-card-bg);
	border-radius: var(--clh-radius);
	box-shadow: var(--clh-card-shadow);
	padding: 22px;
	animation: clh-rise 0.35s ease both;
}

@keyframes clh-rise {
	from {
		opacity: 0;
		transform: translateY(10px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

/* Section label: what kind of part this is, in its own colour. */
.clh-section-kicker {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 3px 10px;
	border-radius: 999px;
	font-size: 0.72rem;
	font-weight: 800;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	margin-bottom: 10px;
}

.clh-section-vocab .clh-section-kicker {
	background: var(--clh-select-soft);
	color: var(--clh-select);
}

.clh-section-grammar .clh-section-kicker {
	background: var(--clh-accent-soft);
	color: var(--clh-accent-text);
}

.clh-section-dialogue .clh-section-kicker {
	background: var(--clh-green-soft);
	color: var(--clh-green);
}

.clh-section-culture .clh-section-kicker {
	background: var(--clh-gold-soft);
	color: var(--clh-warm);
}

.clh-section-title {
	font-size: 1.3rem;
	margin: 0 0 14px;
}

.clh-section-text {
	font-size: 1.05rem;
}

.clh-section-text p,
.clh-section-text ul {
	margin: 0 0 12px;
}

.clh-section-text ul {
	padding-left: 22px;
}

.clh-section-text li {
	margin: 4px 0;
}

.clh-section-text p:last-child,
.clh-section-text ul:last-child {
	margin-bottom: 0;
}

/* ---- Vocab ---- */

.clh-vocab-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
	gap: 12px;
}

.clh-vocab-card {
	border: 2px solid var(--clh-border);
	border-radius: var(--clh-radius-sm);
	padding: 14px;
	background: var(--clh-raised);
}

.clh-vocab-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.clh-vocab-zh {
	font-family: var(--clh-font-cn);
	font-weight: 500;
	font-size: calc(2rem * var(--clh-zh-scale, 1));
	line-height: 1.1;
}

.clh-vocab-en {
	font-weight: 700;
	line-height: 1.3;
	margin-top: 6px;
}

.clh-vocab-pos {
	font-size: 0.78rem;
	color: var(--clh-text-muted);
	font-style: italic;
}

.clh-vocab-py {
	display: block;
	margin-top: 4px;
	font-weight: 600;
}

/* ---- Play button ---- */

.clh-play {
	min-width: 44px;
	min-height: 44px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: none;
	border-radius: 999px;
	background: var(--clh-select-soft);
	color: var(--clh-select);
	cursor: pointer;
	flex: none;
	transition: transform 0.1s ease;
}

.clh-play:hover {
	transform: scale(1.08);
}

.clh-play-big {
	min-width: 72px;
	min-height: 72px;
	display: inline-flex;
	margin-bottom: 8px;
	background: var(--clh-select);
	color: #fff;
	box-shadow: 0 4px 0 color-mix(in srgb, var(--clh-select) 70%, #000);
}

/* A playing clip: filled, with a soft pulsing ring so it is never colour alone. */
.clh-play.is-playing {
	background: var(--clh-select);
	border-color: var(--clh-select);
	color: #fff;
	animation: clh-play-ring 1.4s ease-out infinite;
}

@keyframes clh-play-ring {
	0% {
		box-shadow: 0 0 0 0 color-mix(in srgb, var(--clh-select) 45%, transparent);
	}
	70% {
		box-shadow: 0 0 0 10px color-mix(in srgb, var(--clh-select) 0%, transparent);
	}
	100% {
		box-shadow: 0 0 0 0 color-mix(in srgb, var(--clh-select) 0%, transparent);
	}
}

/* The turtle button: same 44px target, outlined rather than filled. */
.clh-play-slow {
	min-width: 44px;
	min-height: 44px;
	border: 2px solid var(--clh-select-soft);
	background: transparent;
	color: var(--clh-select);
}

.clh-play-slow-big {
	min-width: 56px;
	min-height: 56px;
}

.clh-audio-btns {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	flex: none;
}

.clh-listen-btns {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	margin-bottom: 8px;
}

.clh-listen-btns .clh-play {
	margin-bottom: 0;
}

/* ---- Dialogue ---- */

.clh-chat {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.clh-chat-row {
	display: flex;
	align-items: flex-end;
	gap: 8px;
}

.clh-chat-row-right {
	flex-direction: row-reverse;
}

/* Speaker avatar: first character of the name, one colour per speaker. */
.clh-avatar {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	font-family: var(--clh-font-cn);
	font-size: 1rem;
	font-weight: 700;
	flex: none;
}

.clh-avatar-0 { background: var(--clh-accent-soft); color: var(--clh-accent-text); }
.clh-avatar-1 { background: var(--clh-select-soft); color: var(--clh-select); }
.clh-avatar-2 { background: var(--clh-green-soft); color: var(--clh-green); }
.clh-avatar-3 { background: var(--clh-gold-soft); color: var(--clh-warm); }

.clh-bubble {
	max-width: 78%;
	padding: 10px 14px;
	border-radius: 18px;
	background: var(--clh-sunken);
}

.clh-chat-row-left .clh-bubble {
	border-bottom-left-radius: 6px;
}

.clh-chat-row-right .clh-bubble {
	background: var(--clh-select-soft);
	border-bottom-right-radius: 6px;
}

.clh-bubble-top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
}

.clh-bubble-speaker {
	font-size: 0.8rem;
	font-weight: 700;
	color: var(--clh-text-muted);
}

.clh-bubble-play {
	background: transparent;
}

/* In a bubble the two buttons sit bare, side by side. */
.clh-bubble-play.clh-play-slow {
	border-color: transparent;
}

.clh-bubble-zh {
	font-family: var(--clh-font-cn);
	font-weight: 500;
	font-size: calc(1.2rem * var(--clh-zh-scale, 1));
	display: block;
}

.clh-bubble-py {
	display: block;
}

.clh-bubble-en {
	display: none;
	margin-top: 4px;
	color: var(--clh-text-muted);
}

.clh-chat.show-en .clh-bubble-en {
	display: block;
}

.clh-show-translation {
	min-height: 44px;
	margin-top: 14px;
	padding: 6px 16px;
	border: 2px solid var(--clh-control-border);
	border-radius: 999px;
	background: transparent;
	color: var(--clh-text);
	font-weight: 700;
	cursor: pointer;
}

.clh-show-translation:hover {
	border-color: var(--clh-select);
}

/* --- Playing a whole dialogue: a toolbar above the chat --- */

.clh-dialogue-tools {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 12px;
}

.clh-dialogue-play {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 44px;
	padding: 6px 16px;
	border: 2px solid var(--clh-select-soft);
	border-radius: 999px;
	background: transparent;
	color: var(--clh-select);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

.clh-dialogue-play .clh-icon {
	font-size: 1.1em;
}

.clh-dialogue-play:hover {
	border-color: var(--clh-select);
}

.clh-dialogue-play.is-playing {
	background: var(--clh-select);
	border-color: var(--clh-select);
	color: #fff;
}

/* The line being spoken. */
.clh-chat-row.is-playing .clh-bubble {
	outline: 2px solid var(--clh-select);
	outline-offset: 2px;
}

/* ---- Grammar ---- */

.clh-grammar-pattern {
	display: flex;
	flex-direction: column;
	gap: 4px;
	background: var(--clh-accent-soft);
	border-radius: var(--clh-radius-sm);
	padding: 14px 16px;
	margin-bottom: 14px;
}

.clh-grammar-pattern-label {
	font-size: 0.72rem;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--clh-accent-text);
}

.clh-grammar-pattern-text {
	font-family: var(--clh-font-cn);
	font-size: 1.2rem;
	font-weight: 600;
}

.clh-grammar-examples {
	list-style: none;
	padding: 0;
	margin: 14px 0 0;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.clh-grammar-example {
	border-left: 4px solid var(--clh-accent);
	border-radius: 4px var(--clh-radius-sm) var(--clh-radius-sm) 4px;
	background: var(--clh-bg);
	padding: 12px 14px;
}

.clh-grammar-example .clh-zh {
	font-size: calc(1.2rem * var(--clh-zh-scale, 1));
}

/* Examples with audio: text left, buttons right, top aligned. The text may
   shrink so the pair never scrolls sideways on a phone. */
.clh-grammar-example.has-audio {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 10px;
}

.clh-grammar-example.has-audio .clh-zh-line {
	min-width: 0;
}

/* ---- Culture ---- */

.clh-section-culture {
	padding: 0;
	background: transparent;
	box-shadow: none;
}

.clh-culture-card {
	background: var(--clh-culture-bg);
	border: 1px solid var(--clh-culture-border);
	border-radius: var(--clh-radius);
	padding: 22px;
}

.clh-culture-card p {
	margin: 0 0 12px;
}

.clh-culture-card p:last-child {
	margin-bottom: 0;
}

/* ---- Exercises ----
   The section itself is invisible: each exercise is its own card, so there
   is never a card inside a card. */

.clh-section-exercises {
	padding: 0;
	background: transparent;
	box-shadow: none;
}

.clh-exercise-list {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.clh-ex-card {
	background: var(--clh-card-bg);
	border-radius: var(--clh-radius);
	box-shadow: var(--clh-card-shadow);
	padding: 22px 22px 10px;
	margin: 6px 0;
	animation: clh-rise 0.3s ease both;
}

.clh-ex-body {
	margin-bottom: 16px;
}

.clh-ex-prompt {
	margin-bottom: 14px;
}

.clh-ex-question {
	font-size: 1.15rem;
	font-weight: 700;
	line-height: 1.35;
	margin-bottom: 6px;
}

/* Large prompt characters for tone_select, pinyin_input, stroke, mcq & listen. */
.clh-ex-prompt .clh-zh {
	font-size: calc(2.8rem * var(--clh-zh-scale, 1));
	line-height: 1.15;
}

.clh-ex-note {
	font-size: 0.9rem;
	color: var(--clh-text-muted);
	margin-top: 6px;
}

.clh-ex-sentence {
	font-size: 1.5rem;
	font-family: var(--clh-font-cn);
	font-weight: 500;
}

.clh-ex-pinyin {
	color: var(--clh-text-muted);
}

.clh-ex-en {
	color: var(--clh-text-muted);
	margin-top: 4px;
}

.clh-blank {
	border-bottom: 3px solid var(--clh-select);
	padding: 0 6px;
	color: var(--clh-select);
	font-weight: 700;
}

.clh-blank.is-filled {
	background: var(--clh-select-soft);
	border-radius: 6px 6px 0 0;
}

/* Feedback: a banner that slides up into the action bar. */
.clh-ex-feedback {
	display: flex;
	gap: 12px;
	align-items: flex-start;
	margin: 0 0 12px;
	padding: 14px 16px;
	border-radius: var(--clh-radius-sm);
	font-weight: 700;
	animation: clh-feedback-in 0.22s ease both;
}

@keyframes clh-feedback-in {
	from {
		opacity: 0;
		transform: translateY(8px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

.clh-ex-feedback-icon {
	flex: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	font-size: 1rem;
	font-weight: 800;
	color: #fff;
}

.clh-ex-feedback-title {
	display: block;
	font-size: 1.05rem;
	font-weight: 800;
}

.clh-ex-feedback-detail {
	display: block;
	font-weight: 400;
	color: var(--clh-text);
	margin-top: 2px;
}

.clh-ex-feedback.is-correct {
	background: var(--clh-green-soft);
	color: var(--clh-green);
}

/* Replay the answer from the feedback banner. */
.clh-ex-feedback-play {
	margin-left: auto;
	flex: none;
}

.clh-ex-feedback.is-correct .clh-ex-feedback-icon {
	background: var(--clh-green-fill);
	animation: clh-pop 0.4s cubic-bezier(0.2, 1.6, 0.4, 1);
}

.clh-ex-feedback.is-wrong {
	background: var(--clh-wrong-soft);
	color: var(--clh-wrong);
}

.clh-ex-feedback.is-wrong .clh-ex-feedback-icon {
	background: var(--clh-accent);
}

@keyframes clh-pop {
	from {
		transform: scale(0.3);
	}
	to {
		transform: scale(1);
	}
}

.clh-ex-check {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 52px;
	padding: 10px 20px;
	border-radius: 14px;
	font-family: inherit;
	font-size: 1.05rem;
	font-weight: 800;
	letter-spacing: 0.02em;
	cursor: pointer;
	border: 2px solid var(--clh-accent);
	box-shadow: 0 4px 0 var(--clh-accent-strong);
	background: var(--clh-accent);
	color: #fff;
	transition: transform 0.06s ease, box-shadow 0.06s ease;
}

.clh-ex-check:active:not(:disabled) {
	transform: translateY(4px);
	box-shadow: none;
}

/* The .clh-ex-check display rule overrides the UA [hidden] style, so restate
   it explicitly: once an exercise is correct the Check button must disappear. */
.clh-ex-check[hidden] {
	display: none;
}

.clh-ex-check:disabled {
	background: var(--clh-disabled-bg);
	border-color: var(--clh-disabled-bg);
	box-shadow: none;
	color: var(--clh-disabled-text);
	cursor: not-allowed;
}

/* Feedback + Check / Continue: kept in view at the bottom of the screen
   when a card is taller than the viewport, so the next step is always
   visible without scrolling. */
.clh-ex-actions {
	position: sticky;
	bottom: 0;
	z-index: 2;
	background: var(--clh-card-bg);
	padding: 8px 0 16px;
}

.clh-ex-continue {
	width: 100%;
	min-height: 52px;
	font-size: 1.05rem;
	font-weight: 800;
}

/* Options (mcq etc.) */

.clh-options {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.clh-option {
	display: flex;
	align-items: center;
	gap: 12px;
	width: 100%;
	min-height: 56px;
	padding: 10px 16px;
	border: 2px solid var(--clh-control-border);
	box-shadow: 0 3px 0 var(--clh-control-border);
	border-radius: 14px;
	background: var(--clh-raised);
	color: var(--clh-text);
	font-family: inherit;
	font-size: 1.05rem;
	font-weight: 600;
	text-align: left;
	cursor: pointer;
	transition: transform 0.06s ease, box-shadow 0.06s ease, border-color 0.12s ease, background 0.12s ease;
}

.clh-option:active:not(.is-wrong),
.clh-tone-option:active:not(.is-wrong),
.clh-order-chip:active,
.clh-match-btn:active {
	transform: translateY(3px);
	box-shadow: none;
}

.clh-option-key {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border-radius: 8px;
	border: 2px solid var(--clh-control-border);
	font-size: 0.8rem;
	font-weight: 800;
	color: var(--clh-text-muted);
	flex: none;
}

.clh-option-label {
	flex: 1;
}

/* Translate_choose options: large, legible Chinese characters. */
.clh-option-big .clh-zh {
	font-size: 2.5rem;
	line-height: 1.1;
}

.clh-option:hover:not(.is-wrong),
.clh-tone-option:hover:not(.is-wrong),
.clh-order-chip:hover,
.clh-match-btn:hover {
	border-color: var(--clh-select);
	box-shadow: 0 3px 0 var(--clh-select);
}

.clh-option.is-selected,
.clh-tone-option.is-selected,
.clh-match-btn.is-selected {
	border-color: var(--clh-select);
	box-shadow: 0 3px 0 var(--clh-select);
	background: var(--clh-select-soft);
}

.clh-option.is-selected .clh-option-key {
	background: var(--clh-select);
	border-color: var(--clh-select);
	color: var(--clh-card-bg);
}

.clh-option.is-correct,
.clh-tone-option.is-correct {
	border-color: var(--clh-green);
	box-shadow: 0 3px 0 var(--clh-green);
	background: var(--clh-green-soft);
}

.clh-option.is-correct .clh-option-key {
	background: var(--clh-green);
	border-color: var(--clh-green);
	color: var(--clh-card-bg);
}

/* A wrong pick is marked and taken out of play — not by colour alone: the
   label is struck through and the key shows a cross. */
.clh-option.is-wrong,
.clh-tone-option.is-wrong {
	border-color: var(--clh-wrong);
	box-shadow: none;
	background: var(--clh-wrong-soft);
	cursor: not-allowed;
}

.clh-option.is-wrong .clh-option-label,
.clh-tone-option.is-wrong .clh-tone-option-syllable {
	text-decoration: line-through;
	text-decoration-thickness: 2px;
	opacity: 0.75;
}

.clh-option.is-wrong .clh-option-key {
	background: var(--clh-wrong);
	border-color: var(--clh-wrong);
	color: var(--clh-card-bg);
}

/* Pinyin input */

.clh-input {
	width: 100%;
	min-height: 56px;
	padding: 10px 16px;
	font-family: inherit;
	font-size: 1.2rem;
	border: 2px solid var(--clh-control-border);
	border-radius: 14px;
	background: var(--clh-raised);
	color: var(--clh-text);
}

.clh-input:focus {
	border-color: var(--clh-select);
}

.clh-input.is-wrong {
	border-color: var(--clh-wrong);
}

.clh-input.is-correct {
	border-color: var(--clh-green);
}

.clh-tone-help {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: 10px;
	flex-wrap: wrap;
}

.clh-tone-help-label {
	flex-basis: 100%;
	font-size: 0.85rem;
	color: var(--clh-text-muted);
}

.clh-tone-btn {
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	line-height: 1;
	gap: 2px;
	min-width: 52px;
	min-height: 52px;
	border: 2px solid var(--clh-control-border);
	box-shadow: 0 2px 0 var(--clh-control-border);
	border-radius: var(--clh-radius-sm);
	background: var(--clh-raised);
	color: var(--clh-text);
	font-size: 1.1rem;
	cursor: pointer;
}

.clh-tone-btn-mark {
	display: block;
	line-height: 0;
}

/* The mark takes its tone colour, as pinyin does everywhere else. */
.clh-tone-btn.clh-tone-1 .clh-tone-btn-mark { color: var(--clh-tone-1); }
.clh-tone-btn.clh-tone-2 .clh-tone-btn-mark { color: var(--clh-tone-2); }
.clh-tone-btn.clh-tone-3 .clh-tone-btn-mark { color: var(--clh-tone-3); }
.clh-tone-btn.clh-tone-4 .clh-tone-btn-mark { color: var(--clh-tone-4); }
.clh-tone-btn.clh-tone-5 .clh-tone-btn-mark { color: var(--clh-tone-5); }

.clh-tone-btn-num {
	font-size: 0.72rem;
	color: var(--clh-text-muted);
}

/* Pinyin keys drawn by the page on phones (no autocorrect can reach them). */
.clh-pinyin-keys {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin-top: 12px;
	user-select: none;
	-webkit-user-select: none;
}

.clh-pinyin-keys[hidden],
.clh-keys-switch[hidden] {
	display: none;
}

.clh-key-row {
	display: flex;
	justify-content: center;
	gap: 4px;
}

.clh-key {
	flex: 1 1 0;
	max-width: 44px;
	min-width: 0;
	height: 46px;
	padding: 0;
	border: 0;
	border-radius: 8px;
	box-shadow: 0 2px 0 var(--clh-control-border);
	background: var(--clh-raised);
	color: var(--clh-text);
	font-family: inherit;
	font-size: 1.2rem;
	cursor: pointer;
	touch-action: manipulation;
}

.clh-key:active {
	transform: translateY(1px);
	box-shadow: none;
}

.clh-key-wide {
	flex-grow: 1.6;
	max-width: 66px;
}

.clh-key-space {
	flex: 0 1 60%;
	max-width: none;
	font-size: 0.9rem;
	color: var(--clh-text-muted);
}

.clh-keys-switch {
	display: block;
	margin: 10px 0 0 auto;
	padding: 8px 0;
	border: 0;
	background: none;
	color: var(--clh-text-muted);
	font-family: inherit;
	font-size: 0.85rem;
	text-decoration: underline;
	cursor: pointer;
}

.clh-ex-reveal {
	margin-top: 10px;
	font-weight: 700;
	color: var(--clh-text);
}

/* Tone select */

.clh-tone-options {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
	gap: 10px;
}

.clh-tone-option {
	min-height: 68px;
	padding: 4px 10px;
	border: 2px solid var(--clh-control-border);
	box-shadow: 0 3px 0 var(--clh-control-border);
	border-radius: 14px;
	background: var(--clh-raised);
	color: var(--clh-text);
	cursor: pointer;
	transition: transform 0.06s ease, box-shadow 0.06s ease, border-color 0.12s ease;
}

.clh-tone-option-syllable {
	font-size: 1.6rem;
	font-weight: 600;
}

/* Order words */

.clh-order-answer {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	min-height: 68px;
	border: 2px dashed var(--clh-control-border);
	border-radius: 14px;
	padding: 8px;
	margin-bottom: 14px;
}

.clh-order-pool {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.clh-order-chip {
	min-height: 48px;
	padding: 6px 14px;
	border: 2px solid var(--clh-control-border);
	box-shadow: 0 3px 0 var(--clh-control-border);
	border-radius: var(--clh-radius-sm);
	background: var(--clh-raised);
	color: var(--clh-text);
	font-size: calc(1.2rem * var(--clh-zh-scale, 1));
	cursor: pointer;
	transition: transform 0.06s ease, box-shadow 0.06s ease, border-color 0.12s ease;
}

.clh-order-chip .clh-zh {
	font-family: var(--clh-font-cn);
}

.clh-order-chip.is-correct {
	border-color: var(--clh-green);
	box-shadow: 0 3px 0 var(--clh-green);
	background: var(--clh-green-soft);
}

/* Match pairs */

.clh-match-cols {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
}

.clh-match-col {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.clh-match-btn {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	justify-content: center;
	gap: 2px;
	min-height: 56px;
	padding: 8px 14px;
	border: 2px solid var(--clh-control-border);
	box-shadow: 0 3px 0 var(--clh-control-border);
	border-radius: 14px;
	background: var(--clh-raised);
	color: var(--clh-text);
	font-family: inherit;
	font-size: 1rem;
	font-weight: 600;
	text-align: left;
	cursor: pointer;
	transition: transform 0.06s ease, box-shadow 0.06s ease, border-color 0.12s ease;
}

.clh-match-left .clh-zh {
	font-size: calc(1.25rem * var(--clh-zh-scale, 1));
}

.clh-match-done {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	justify-content: center;
	gap: 2px;
	min-height: 56px;
	padding: 8px 14px;
	border: 2px solid var(--clh-green);
	border-radius: 14px;
	background: var(--clh-green-soft);
	color: var(--clh-green);
	font-size: 1rem;
	font-weight: 600;
}

.clh-match-done .clh-zh {
	font-size: calc(1.25rem * var(--clh-zh-scale, 1));
}

.clh-match-done .clh-py {
	color: var(--clh-green);
	opacity: 0.75;
}

.clh-match-btn.is-shake {
	animation: clh-shake 0.4s;
	border-color: var(--clh-wrong);
	box-shadow: 0 3px 0 var(--clh-wrong);
}

@keyframes clh-shake {
	0%, 100% { transform: translateX(0); }
	25% { transform: translateX(-5px); }
	75% { transform: translateX(5px); }
}

/* Stroke */

.clh-stroke-pad {
	--clh-grid: color-mix(in srgb, var(--clh-accent) 28%, transparent);
	display: flex;
	justify-content: center;
	margin: 8px 0;
}

/* The tracing square: a practice grid (米字格) as in a Chinese exercise book,
   a dashed cross and two faint diagonals, drawn behind the character. */
.clh-stroke-pad svg {
	box-sizing: content-box;
	border: 2px solid var(--clh-control-border);
	border-radius: 16px;
	background-color: var(--clh-raised);
	background-image:
		linear-gradient(to bottom right, transparent calc(50% - 0.6px), var(--clh-grid) 50%, transparent calc(50% + 0.6px)),
		linear-gradient(to top right, transparent calc(50% - 0.6px), var(--clh-grid) 50%, transparent calc(50% + 0.6px)),
		repeating-linear-gradient(to right, var(--clh-grid) 0 7px, transparent 7px 13px),
		repeating-linear-gradient(to bottom, var(--clh-grid) 0 7px, transparent 7px 13px);
	background-position: 0 0, 0 0, 0 50%, 50% 0;
	background-size: 100% 100%, 100% 100%, 100% 1.5px, 1.5px 100%;
	background-repeat: no-repeat;
	touch-action: none;
}

.clh-stroke-fallback {
	font-family: var(--clh-font-cn);
	font-size: 7rem;
	line-height: 1;
	color: var(--clh-text);
}

/* "Watch the stroke order" / "Now trace it": what the pad is doing. */
.clh-stroke-status {
	margin: 4px 0 0;
	text-align: center;
	font-size: 0.95rem;
	font-weight: 600;
	color: var(--clh-text-muted);
}

.clh-stroke-controls {
	display: flex;
	gap: 10px;
	margin-top: 8px;
	flex-wrap: wrap;
}

.clh-stroke-controls .clh-btn + .clh-btn {
	margin-top: 0;
}

/* Done exercise rows: a quiet trail of what has been answered. */

.clh-ex-done {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 14px;
	border-radius: 999px;
	background: var(--clh-green-soft);
	color: var(--clh-text-muted);
	font-size: 0.95rem;
}

.clh-ex-done-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: var(--clh-green-fill);
	color: #fff;
	font-size: 0.75rem;
	font-weight: 800;
	flex: none;
}

.clh-ex-done-body {
	display: flex;
	align-items: baseline;
	gap: 8px;
	min-width: 0;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.clh-ex-done-zh {
	font-family: var(--clh-font-cn);
	font-size: calc(1.05rem * var(--clh-zh-scale, 1));
	color: var(--clh-text);
}

.clh-ex-done-label {
	overflow: hidden;
	text-overflow: ellipsis;
}

/* ---- Complete card ---- */

.clh-complete-card {
	text-align: center;
	padding: 36px 22px 28px;
}

.clh-complete-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 96px;
	height: 96px;
	border-radius: 50%;
	background: var(--clh-gold-soft);
	color: var(--clh-gold);
	margin-bottom: 14px;
	animation: clh-pop 0.5s cubic-bezier(0.2, 1.5, 0.4, 1);
}

.clh-complete-title {
	font-size: 1.9rem;
	margin: 0 0 6px;
}

.clh-complete-sub {
	color: var(--clh-text-muted);
	margin: 0 0 22px;
}

.clh-summary {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
	gap: 10px;
	max-width: 440px;
	margin: 0 auto 24px;
}

.clh-summary-item {
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: 14px 8px 12px;
	border-radius: var(--clh-radius-sm);
	border: 2px solid var(--clh-border);
}

.clh-summary-item.is-xp {
	border-color: var(--clh-gold);
	background: var(--clh-gold-soft);
}

.clh-summary-item.is-accuracy {
	border-color: var(--clh-progress);
	background: var(--clh-green-soft);
}

.clh-summary-item.is-streak {
	border-color: var(--clh-select);
	background: var(--clh-select-soft);
}

.clh-summary-value {
	font-size: 1.6rem;
	font-weight: 800;
	line-height: 1.1;
	letter-spacing: -0.02em;
}

.clh-summary-item.is-xp .clh-summary-value { color: var(--clh-warm); }
.clh-summary-item.is-accuracy .clh-summary-value { color: var(--clh-green); }
.clh-summary-item.is-streak .clh-summary-value { color: var(--clh-select); }

.clh-summary-label {
	font-size: 0.78rem;
	font-weight: 700;
	color: var(--clh-text-muted);
}

.clh-complete-actions {
	display: flex;
	flex-direction: column;
	align-items: center;
}

.clh-story-next-note {
	margin: 0 0 14px;
	color: var(--clh-text-muted);
	font-weight: 600;
}

.clh-complete-card .clh-btn {
	width: 100%;
	max-width: 340px;
}

.clh-complete-card .clh-btn + .clh-btn {
	margin-top: 12px;
}

/* Confetti canvas: drawn once when a lesson is finished. */
.clh-confetti {
	position: fixed;
	inset: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
	z-index: 1000;
}

/* ---- Focus & motion ---- */

@media (prefers-reduced-motion: reduce) {
	.clh-match-btn.is-shake,
	.clh-section,
	.clh-ex-card,
	.clh-ex-feedback,
	.clh-ex-feedback-icon,
	.clh-complete-badge,
	.clh-play.is-playing {
		animation: none;
	}
	.clh-root * {
		scroll-behavior: auto !important;
	}
}

/* ---- Small screens ---- */

@media (max-width: 480px) {
	.clh-root {
		padding: 4px 12px 48px;
	}
	.clh-section:not(.clh-section-exercises):not(.clh-section-culture),
	.clh-culture-card {
		padding: 18px 16px;
	}
	.clh-ex-card {
		padding: 18px 16px 6px;
	}
	.clh-topbar-heading {
		font-size: 1.45rem;
	}
	.clh-match-cols {
		gap: 8px;
	}
	.clh-bubble {
		max-width: 84%;
	}
}

@media (max-width: 380px) {
	.clh-root {
		font-size: 16px;
	}
	.clh-progress-text {
		display: none;
	}
}

/* ---- Desktop ---- */

@media (min-width: 720px) {
	.clh-root {
		padding: 12px 24px 72px;
	}
	.clh-section:not(.clh-section-exercises):not(.clh-section-culture),
	.clh-culture-card {
		padding: 28px;
	}
	.clh-ex-card {
		padding: 28px 28px 12px;
	}
}

/* Scrolling to the active section / exercise must clear the sticky progress
   row (and, on other pages, the sticky site header). */
.clh-section,
.clh-ex-card {
	scroll-margin-top: calc(var(--clh-sticky-top, 0px) + 76px);
}

/* ---- Report a problem ----
   A quiet control under each exercise; the form opens in place. */

.clh-ex-actions:has(+ .clh-report) {
	padding-bottom: 4px;
}

.clh-report {
	text-align: right;
}

.clh-report-toggle {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-height: 44px;
	padding: 0 6px;
	border: 0;
	border-radius: 8px;
	background: transparent;
	color: var(--clh-text-muted);
	font-family: inherit;
	font-size: 0.82rem;
	font-weight: 600;
	cursor: pointer;
}

.clh-report-toggle:hover,
.clh-report-toggle[aria-expanded='true'] {
	color: var(--clh-text);
}

.clh-report-panel {
	margin: 2px 0 12px;
	padding: 14px;
	border-radius: var(--clh-radius-sm);
	background: var(--clh-sunken);
	text-align: left;
}

.clh-report-reasons {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.clh-report-reason {
	min-height: 44px;
	padding: 6px 14px;
	border: 2px solid var(--clh-control-border);
	border-radius: 999px;
	background: var(--clh-raised);
	color: var(--clh-text);
	font-family: inherit;
	font-size: 0.92rem;
	font-weight: 600;
	cursor: pointer;
}

.clh-report-reason.is-selected {
	border-color: var(--clh-select);
	background: var(--clh-select-soft);
}

.clh-report-note {
	display: block;
	width: 100%;
	margin-top: 10px;
	padding: 10px 12px;
	border: 2px solid var(--clh-control-border);
	border-radius: 12px;
	background: var(--clh-raised);
	color: var(--clh-text);
	font-family: inherit;
	font-size: 0.95rem;
	resize: vertical;
}

.clh-report-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 12px;
}

.clh-report-actions .clh-btn {
	min-height: 44px;
	padding: 8px 18px;
	font-size: 0.95rem;
}

.clh-report-send:disabled {
	border-color: var(--clh-disabled-bg);
	box-shadow: none;
	background: var(--clh-disabled-bg);
	color: var(--clh-disabled-text);
	opacity: 1;
}

.clh-report-status {
	margin: 4px 0 10px;
	font-size: 0.88rem;
	font-weight: 600;
	color: var(--clh-green);
}

.clh-report-status.is-error {
	color: var(--clh-wrong);
}

/* ---- XP milestone on a summary ---- */

.clh-complete-card .clh-milestone-banner {
	max-width: 440px;
	margin: 0 auto 16px;
}

.clh-complete-card .clh-milestone-next {
	max-width: 440px;
	margin: -8px auto 24px;
	text-align: left;
}

/* ---- Reading settings: Chinese text size ----
   The sizes above are multiplied by --clh-zh-scale (set on <html> by
   lib/settings.js). Inline Chinese in explanations and Chinese answer
   options scale with it too. */

.clh-section p > .clh-zh,
.clh-section li > .clh-zh,
.clh-option-label .clh-zh:not(.clh-option-big .clh-zh),
.clh-ex-zh-line .clh-zh {
	font-size: calc(1em * var(--clh-zh-scale, 1));
}

.clh-topbar-controls {
	flex-wrap: wrap;
}

/* Lesson notes under the player (server-rendered, see Seo::lesson_notes). */
.clh-notes {
	max-width: 720px;
	margin: 32px auto 0;
	padding: 4px 20px;
	background: var(--clh-card-bg);
	border: 1px solid var(--clh-border);
	border-radius: var(--clh-radius);
	color: var(--clh-text);
}
.clh-notes > summary {
	cursor: pointer;
	padding: 12px 0;
	font-weight: 600;
	color: var(--clh-text-muted);
}
.clh-notes[open] > summary { border-bottom: 1px solid var(--clh-border); margin-bottom: 8px; }
.clh-notes h3 { font-size: 1.05rem; margin: 20px 0 8px; }
.clh-notes h4 { font-size: 1rem; margin: 12px 0 6px; }
.clh-notes ul { margin: 0 0 8px; padding-left: 1.2em; }
.clh-notes__words { width: 100%; border-collapse: collapse; }
.clh-notes__words td { padding: 6px 8px 6px 0; border-bottom: 1px solid var(--clh-border); vertical-align: top; }
.clh-notes__words td:first-child { font-size: 1.15rem; white-space: nowrap; }
.clh-notes__words td:nth-child(2) { color: var(--clh-text-muted); white-space: nowrap; }
.clh-notes__dialogue { margin: 0 0 16px; }
.clh-notes__dialogue dt { font-size: 1.1rem; margin-top: 10px; }
.clh-notes__dialogue dd { margin: 2px 0 0; color: var(--clh-text-muted); font-size: 0.95rem; }
