/* Chinese Learning Hub — shared design tokens and reusable components.
   Enqueued on every CLH page (lesson player, dashboard, catalogue, placement).
   Player-specific styles live in player.css; page-specific styles in their
   own dashboard.css / catalog.css / placement.css. */

:root {
	color-scheme: light;
	/* Surfaces, lightest on top: bg < card < raised. Sunken is for wells
	   (progress tracks, quiet chips). */
	--clh-bg: #faf6f0;
	--clh-card-bg: #ffffff;
	--clh-raised: #ffffff;
	--clh-sunken: #f1ebe3;
	--clh-card-shadow: 0 1px 2px rgba(44, 30, 18, 0.05), 0 8px 24px rgba(44, 30, 18, 0.07);
	--clh-radius: 16px;
	--clh-radius-sm: 12px;
	--clh-text: #1f1a17;
	--clh-text-muted: #675e57;
	--clh-border: #ebe4da;
	--clh-control-border: #d3c9be;
	/* Brand red: --clh-accent fills primary buttons (white text on it),
	   --clh-accent-strong is their bottom edge, --clh-accent-text is
	   accent-coloured text on page / card surfaces. */
	--clh-accent: #c8102e;
	--clh-accent-strong: #9c0c24;
	--clh-accent-text: #c8102e;
	--clh-accent-soft: rgba(200, 16, 46, 0.08);
	/* Answer states. Selection is blue so red only ever means "wrong". */
	--clh-select: #1f6fe0;
	--clh-select-soft: rgba(31, 111, 224, 0.1);
	/* Jade: progress and success. --clh-green is text / borders,
	   --clh-green-fill a button fill (white text), --clh-progress a bar fill. */
	--clh-green: #0e7a52;
	--clh-green-soft: rgba(14, 122, 82, 0.1);
	--clh-green-fill: #0e7a52;
	--clh-green-fill-strong: #0a5a3c;
	--clh-progress: #17a673;
	--clh-wrong: #c8102e;
	--clh-wrong-soft: rgba(200, 16, 46, 0.08);
	--clh-disabled-bg: #ebe5dd;
	--clh-disabled-text: #7d746d;
	--clh-focus: #1f6fe0;
	/* Gold: rewards (XP, streak, goals). --clh-warm is gold as text. */
	--clh-gold: #f2a51d;
	--clh-gold-soft: #fff3d6;
	--clh-warm: #b25f00;
	--clh-culture-bg: #fff8e6;
	--clh-culture-border: #f0e3c0;

	--clh-tone-1: #e30000;
	--clh-tone-2: #d97a00;
	--clh-tone-3: #2a9d2a;
	--clh-tone-4: #1f6fe0;
	--clh-tone-5: #888;

	--clh-font: 'Onest', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
	--clh-font-cn: 'Noto Sans TC', 'Noto Sans SC', 'PingFang TC', 'PingFang SC', 'Microsoft JhengHei', 'Microsoft YaHei', sans-serif;
}

/* Dark palette: follows the system unless the learner picked a theme
   (html[data-theme], set by the header switch and an inline head script). */
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		color-scheme: dark;
		--clh-bg: #181513;
		--clh-card-bg: #24201d;
		--clh-raised: #2e2925;
		--clh-sunken: #3a342f;
		--clh-card-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.28);
		--clh-text: #f4efea;
		--clh-text-muted: #c2b8af;
		--clh-border: #3b3530;
		--clh-control-border: #7a7066;
		--clh-accent: #d42a45;
		--clh-accent-strong: #a31c33;
		--clh-accent-text: #ff7385;
		--clh-accent-soft: rgba(255, 90, 110, 0.16);
		--clh-select: #6fa8ff;
		--clh-select-soft: rgba(111, 168, 255, 0.16);
		--clh-green: #4fd69c;
		--clh-green-soft: rgba(79, 214, 156, 0.14);
		--clh-green-fill: #1a8259;
		--clh-green-fill-strong: #125e40;
		--clh-progress: #34c08a;
		--clh-wrong: #ff7385;
		--clh-wrong-soft: rgba(255, 90, 110, 0.14);
		--clh-disabled-bg: #3a3430;
		--clh-disabled-text: #a99e95;
		--clh-focus: #6fa8ff;
		--clh-gold: #f5b942;
		--clh-gold-soft: rgba(245, 185, 66, 0.14);
		--clh-warm: #ffb35c;
		--clh-culture-bg: #332a17;
		--clh-culture-border: #5a4b26;

		--clh-tone-1: #ff6b6b;
		--clh-tone-2: #ffb25e;
		--clh-tone-3: #5edb74;
		--clh-tone-4: #6fb6ff;
		--clh-tone-5: #b0a89f;
	}
}

:root[data-theme="dark"] {
	color-scheme: dark;
	--clh-bg: #181513;
	--clh-card-bg: #24201d;
	--clh-raised: #2e2925;
	--clh-sunken: #3a342f;
	--clh-card-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.28);
	--clh-text: #f4efea;
	--clh-text-muted: #c2b8af;
	--clh-border: #3b3530;
	--clh-control-border: #7a7066;
	--clh-accent: #d42a45;
	--clh-accent-strong: #a31c33;
	--clh-accent-text: #ff7385;
	--clh-accent-soft: rgba(255, 90, 110, 0.16);
	--clh-select: #6fa8ff;
	--clh-select-soft: rgba(111, 168, 255, 0.16);
	--clh-green: #4fd69c;
	--clh-green-soft: rgba(79, 214, 156, 0.14);
	--clh-green-fill: #1a8259;
	--clh-green-fill-strong: #125e40;
	--clh-progress: #34c08a;
	--clh-wrong: #ff7385;
	--clh-wrong-soft: rgba(255, 90, 110, 0.14);
	--clh-disabled-bg: #3a3430;
	--clh-disabled-text: #a99e95;
	--clh-focus: #6fa8ff;
	--clh-gold: #f5b942;
	--clh-gold-soft: rgba(245, 185, 66, 0.14);
	--clh-warm: #ffb35c;
	--clh-culture-bg: #332a17;
	--clh-culture-border: #5a4b26;

	--clh-tone-1: #ff6b6b;
	--clh-tone-2: #ffb25e;
	--clh-tone-3: #5edb74;
	--clh-tone-4: #6fb6ff;
	--clh-tone-5: #b0a89f;
}

/* ---- App shell (dashboard / catalogue / placement) ---- */

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

/* Break out of the theme's constrained post-content width. */
#clh-dashboard,
#clh-placement,
#clh-catalog {
	box-sizing: border-box;
	width: 100%;
	max-width: 720px;
	margin-left: auto;
	margin-right: auto;
}

/* The dashboard is two columns on desktop. */
#clh-dashboard {
	max-width: 1040px;
}

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

.clh-app h1,
.clh-app h2,
.clh-app h3,
.clh-root h1,
.clh-root h2,
.clh-root h3 {
	font-weight: 800;
	letter-spacing: -0.02em;
	line-height: 1.15;
}

.clh-app button,
.clh-root button,
.clh-root input {
	font-family: inherit;
}

/* ---- Chinese text & pinyin ---- */

.clh-zh {
	font-family: var(--clh-font-cn);
	font-weight: 500;
}

.clh-py {
	color: var(--clh-text-muted);
	font-size: 0.92em;
	display: block;
}

/* Inline ruby annotations ({zh:X|py} markers): pinyin stays on the line. */
.clh-ruby {
	ruby-position: under;
}

.clh-ruby rt {
	font-size: 0.7em;
	line-height: 1;
	color: var(--clh-text-muted);
	font-weight: 400;
}

.clh-line-en,
.clh-en {
	color: var(--clh-text-muted);
}

.clh-tone-1 { color: var(--clh-tone-1); }
.clh-tone-2 { color: var(--clh-tone-2); }
.clh-tone-3 { color: var(--clh-tone-3); }
.clh-tone-4 { color: var(--clh-tone-4); }
.clh-tone-5 { color: var(--clh-tone-5); }

/* ---- Cards ---- */

.clh-card {
	background: var(--clh-card-bg);
	border-radius: var(--clh-radius);
	box-shadow: var(--clh-card-shadow);
	padding: 20px;
}

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

/* Small uppercase label above a title. */
.clh-kicker {
	font-size: 0.76rem;
	font-weight: 800;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--clh-text-muted);
}

/* ---- Buttons ----
   Tactile: a solid bottom edge (box-shadow, so pressing never shifts the
   layout) that the button sinks into on :active. */

.clh-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 50px;
	padding: 10px 22px;
	border-radius: 14px;
	font-family: inherit;
	font-size: 1rem;
	font-weight: 700;
	line-height: 1.2;
	cursor: pointer;
	border: 2px solid var(--clh-control-border);
	box-shadow: 0 3px 0 var(--clh-control-border);
	background: var(--clh-raised);
	color: var(--clh-text);
	text-decoration: none;
	transition: transform 0.06s ease, box-shadow 0.06s ease, filter 0.15s ease;
}

/* Explicit hover colours: a theme's a:hover must not recolour a button. */
.clh-btn:hover {
	filter: brightness(0.98);
	color: var(--clh-text);
}

.clh-btn-primary:hover,
.clh-btn-success:hover {
	color: #fff;
}

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

.clh-btn:disabled {
	cursor: default;
	opacity: 0.6;
}

.clh-btn-primary {
	background: var(--clh-accent);
	border-color: var(--clh-accent);
	box-shadow: 0 4px 0 var(--clh-accent-strong);
	color: #fff;
}

.clh-btn-primary:hover {
	filter: brightness(1.06);
}

.clh-btn-primary:active {
	transform: translateY(4px);
}

/* Success: the step after a right answer or a finished lesson. */
.clh-btn-success {
	background: var(--clh-green-fill);
	border-color: var(--clh-green-fill);
	box-shadow: 0 4px 0 var(--clh-green-fill-strong);
	color: #fff;
}

.clh-btn-success:active {
	transform: translateY(4px);
}

.clh-btn-ghost {
	background: transparent;
}

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

/* ---- Progress bars ----
   Progress is jade, never the brand red: red is for mistakes. */

.clh-progress-info {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	font-size: 0.85rem;
	font-weight: 600;
	color: var(--clh-text-muted);
	margin-bottom: 6px;
}

.clh-xp {
	font-weight: 800;
	color: var(--clh-warm);
	font-variant-numeric: tabular-nums;
}

.clh-progress-track {
	height: 12px;
	border-radius: 999px;
	background: var(--clh-sunken);
	overflow: hidden;
}

.clh-progress-fill {
	position: relative;
	height: 100%;
	width: 0;
	min-width: 0;
	background: var(--clh-progress);
	border-radius: 999px;
	transition: width 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* A soft highlight along the top of the bar gives it some body. */
.clh-progress-fill::after {
	content: '';
	position: absolute;
	left: 6px;
	right: 6px;
	top: 3px;
	height: 3px;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.35);
}

/* ---- Segmented controls (繁|简 script toggle) ---- */

.clh-segmented {
	display: inline-flex;
	padding: 3px;
	border-radius: 999px;
	background: var(--clh-sunken);
}

.clh-seg {
	min-height: 38px;
	min-width: 44px;
	padding: 4px 14px;
	border: none;
	border-radius: 999px;
	background: transparent;
	color: var(--clh-text-muted);
	font-size: 0.95rem;
	font-weight: 700;
	cursor: pointer;
	white-space: nowrap;
}

.clh-seg.is-active {
	background: var(--clh-card-bg);
	color: var(--clh-text);
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14);
}

/* ---- Pinyin switch ---- */

.clh-switch {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 44px;
	padding: 6px 12px 6px 14px;
	border: none;
	border-radius: 999px;
	background: var(--clh-sunken);
	color: var(--clh-text);
	font-size: 0.95rem;
	font-weight: 700;
	cursor: pointer;
}

.clh-switch-label {
	font-family: var(--clh-font-cn);
}

/* Labels in English (e.g. "Auto-play audio") keep the UI font. */
.clh-autoplay-switch .clh-switch-label {
	font-family: inherit;
}

.clh-switch-track {
	position: relative;
	width: 40px;
	height: 24px;
	border-radius: 999px;
	background: var(--clh-control-border);
	transition: background 0.2s ease;
	flex: none;
}

.clh-switch-thumb {
	position: absolute;
	top: 3px;
	left: 3px;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
	transition: transform 0.2s ease;
}

.clh-switch.is-on .clh-switch-track {
	background: var(--clh-progress);
}

.clh-switch.is-on .clh-switch-thumb {
	transform: translateX(16px);
}

/* ---- Error ---- */

.clh-error {
	background: var(--clh-card-bg);
	border: 1px solid var(--clh-border);
	border-radius: var(--clh-radius);
	padding: 20px;
	color: var(--clh-accent-text);
}

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

.clh-root button:focus-visible,
.clh-root a:focus-visible,
.clh-root input:focus-visible,
.clh-app button:focus-visible,
.clh-app a:focus-visible,
.clh-app input:focus-visible {
	outline: 3px solid var(--clh-focus);
	outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
	.clh-progress-fill {
		transition: none;
	}
	.clh-switch-track,
	.clh-switch-thumb {
		transition: none;
	}
	.clh-btn {
		transition: none;
	}
}

/* ---- Small / desktop shells ---- */

@media (max-width: 380px) {
	.clh-app {
		padding: 12px 12px 40px;
		font-size: 16px;
	}
}

/* ---- Guest & welcome cards (dashboard, practice, stats) ---- */

.clh-guest,
.clh-welcome {
	max-width: 560px;
	margin: 24px auto 0;
	text-align: center;
	padding: 40px 24px;
}

.clh-guest-title,
.clh-welcome-title {
	font-size: 1.7rem;
	margin: 0 0 12px;
}

.clh-guest-text,
.clh-welcome-text {
	color: var(--clh-text-muted);
	margin: 0 0 24px;
}

.clh-guest-actions,
.clh-welcome-actions {
	display: flex;
	flex-direction: column;
	align-items: center;
}

.clh-guest-actions .clh-btn,
.clh-welcome-actions .clh-btn {
	width: 100%;
	max-width: 360px;
}

/* ---- Offline (lib/offline.js) ---- */

/* A bar across the top of the page while there is no connection. */
.clh-offline-bar {
	padding: 8px 16px;
	background: var(--clh-gold-soft, #fff3d6);
	color: var(--clh-text, #1f1a17);
	font-family: var(--clh-font, system-ui, sans-serif);
	font-size: 0.86rem;
	font-weight: 600;
	line-height: 1.4;
	text-align: center;
}

.clh-offline-bar[hidden] {
	display: none;
}

/* A short message that goes away by itself. */
.clh-toast {
	position: fixed;
	left: 50%;
	bottom: 20px;
	z-index: 1000;
	max-width: calc(100vw - 32px);
	padding: 12px 18px;
	border-radius: 999px;
	background: var(--clh-text, #1f1a17);
	color: var(--clh-bg, #faf6f0);
	font-family: var(--clh-font, system-ui, sans-serif);
	font-size: 0.92rem;
	font-weight: 700;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
	transform: translateX(-50%);
}

.clh-offline-saved {
	margin: 14px 0 0;
	padding: 10px 14px;
	border-radius: var(--clh-radius-sm);
	background: var(--clh-gold-soft);
	font-size: 0.92rem;
	font-weight: 600;
	text-align: center;
}

/* ---- Screen-reader-only text ---- */

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

/* ---- Learning path (lib/path.js) ----
   A unit is a collapsible block with its own progress; its lessons are a
   timeline of status nodes joined by a line. Used by the dashboard and the
   level catalogue. */

.clh-unit {
	background: var(--clh-card-bg);
	border: 2px solid var(--clh-border);
	border-radius: var(--clh-radius);
	margin-bottom: 10px;
	overflow: hidden;
}

.clh-unit.is-current {
	border-color: var(--clh-accent);
}

.clh-unit-summary {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 14px;
	cursor: pointer;
	list-style: none;
}

.clh-unit-summary::-webkit-details-marker {
	display: none;
}

.clh-unit-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	border-radius: 13px;
	background: var(--clh-sunken);
	color: var(--clh-text-muted);
	font-size: 1.1rem;
	font-weight: 800;
	flex: none;
}

.clh-unit.is-current .clh-unit-badge {
	background: var(--clh-accent);
	box-shadow: 0 3px 0 var(--clh-accent-strong);
	color: #fff;
}

.clh-unit.is-done .clh-unit-badge {
	background: var(--clh-green-fill);
	box-shadow: 0 3px 0 var(--clh-green-fill-strong);
	color: #fff;
	font-size: 1.3rem;
}

.clh-unit.is-partial .clh-unit-badge {
	background: var(--clh-green-soft);
	color: var(--clh-green);
}

.clh-unit-text {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-width: 0;
}

.clh-unit-name {
	font-size: 0.74rem;
	font-weight: 800;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--clh-text-muted);
}

.clh-unit.is-current .clh-unit-name {
	color: var(--clh-accent-text);
}

.clh-unit-title {
	font-weight: 700;
	line-height: 1.3;
}

.clh-unit.is-locked .clh-unit-title {
	color: var(--clh-text-muted);
}

.clh-unit-bar {
	display: block;
	height: 6px;
	margin-top: 7px;
	border-radius: 999px;
	background: var(--clh-sunken);
	overflow: hidden;
}

.clh-unit-bar-fill {
	display: block;
	height: 100%;
	border-radius: 999px;
	background: var(--clh-progress);
}

.clh-unit-count {
	font-size: 0.85rem;
	font-weight: 700;
	color: var(--clh-text-muted);
	white-space: nowrap;
	flex: none;
}

.clh-unit-chevron {
	color: var(--clh-text-muted);
	transition: transform 0.2s ease;
	flex: none;
}

.clh-unit[open] .clh-unit-chevron {
	transform: rotate(180deg);
}

.clh-unit-lessons {
	display: flex;
	flex-direction: column;
	padding: 4px 14px 12px;
}

.clh-lesson-row {
	position: relative;
	display: flex;
	align-items: center;
	gap: 14px;
	min-height: 52px;
	padding: 6px 8px 6px 4px;
	border-radius: var(--clh-radius-sm);
	text-decoration: none;
	color: var(--clh-text);
	font-weight: 600;
}

a.clh-lesson-row:hover {
	background: var(--clh-sunken);
}

/* The line that joins one node to the next. */
.clh-lesson-row + .clh-lesson-row::before {
	content: '';
	position: absolute;
	left: 20px;
	top: -14px;
	width: 3px;
	height: 28px;
	border-radius: 2px;
	background: var(--clh-border);
}

.clh-lesson-row.is-completed + .clh-lesson-row::before,
.clh-lesson-row.is-skipped + .clh-lesson-row::before {
	background: var(--clh-progress);
}

.clh-lesson-node {
	position: relative;
	z-index: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: var(--clh-sunken);
	color: var(--clh-text-muted);
	font-size: 1rem;
	flex: none;
}

.clh-lesson-row.is-completed .clh-lesson-node {
	background: var(--clh-green-fill);
	color: #fff;
}

.clh-lesson-row.is-skipped .clh-lesson-node {
	background: var(--clh-green-soft);
	color: var(--clh-green);
}

/* The next lesson is the one loud thing on the path. */
.clh-lesson-row.is-available .clh-lesson-node,
.clh-lesson-row.is-started .clh-lesson-node {
	background: var(--clh-accent);
	color: #fff;
	box-shadow: 0 0 0 5px var(--clh-accent-soft);
}

.clh-lesson-row.is-available,
.clh-lesson-row.is-started {
	font-weight: 800;
}

.clh-lesson-row.is-locked {
	color: var(--clh-text-muted);
	font-weight: 500;
}

.clh-lesson-row.is-completed .clh-lesson-title {
	/* Completed reads as done, not cancelled: normal weight + green check node. */
	font-weight: 500;
}

.clh-lesson-title {
	flex: 1;
	min-width: 0;
}

.clh-lesson-status {
	font-size: 0.8rem;
	font-weight: 800;
	color: var(--clh-text-muted);
	flex: none;
}

.clh-lesson-row.is-available .clh-lesson-status,
.clh-lesson-row.is-started .clh-lesson-status {
	padding: 5px 14px;
	border-radius: 999px;
	background: var(--clh-accent);
	box-shadow: 0 3px 0 var(--clh-accent-strong);
	color: #fff;
}

/* ---- Mastery of a finished lesson ----
   Learned (no badge), Practised, Mastered: how well its words are holding
   up in reviews. */

.clh-lesson-mastery {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	flex: none;
	padding: 3px 10px;
	border-radius: 999px;
	font-size: 0.76rem;
	font-weight: 800;
	background: var(--clh-green-soft);
	color: var(--clh-green);
}

.clh-lesson-mastery.is-mastered {
	background: var(--clh-gold-soft);
	color: var(--clh-warm);
}

.clh-lesson-tag {
	display: inline-flex;
	align-items: center;
	flex: none;
	padding: 3px 10px;
	border-radius: 999px;
	font-size: 0.76rem;
	font-weight: 800;
}

.clh-story-tag {
	background: var(--clh-sunken);
	color: var(--clh-text-muted);
}

.clh-lesson-row.is-mastered .clh-lesson-node {
	background: var(--clh-gold);
	color: #4a3200;
}

/* ---- XP milestones ----
   A rank is shown as a name seal: two characters stacked in a red square.
   Progress towards the next one is gold, like every reward. */

.clh-seal {
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 56px;
	flex: none;
	border-radius: 12px;
	background: var(--clh-accent);
	box-shadow: inset 0 0 0 2px var(--clh-accent), inset 0 0 0 4px rgba(255, 255, 255, 0.55);
	color: #fff;
	font-family: var(--clh-font-cn);
	font-size: 1.15rem;
	font-weight: 700;
	line-height: 1.12;
}

.clh-seal.is-small {
	width: 40px;
	height: 40px;
	border-radius: 9px;
	box-shadow: none;
	font-size: 0.85rem;
	line-height: 1.1;
}

.clh-seal.is-locked {
	background: var(--clh-sunken);
	box-shadow: none;
	color: var(--clh-text-muted);
}

.clh-rank-name {
	display: inline-flex;
	align-items: baseline;
	gap: 6px;
}

.clh-rank-name .clh-zh {
	font-family: var(--clh-font-cn);
	font-weight: 700;
}

.clh-rank-name .clh-py {
	font-size: 0.9em;
}

.clh-milestone-track .clh-progress-fill {
	background: var(--clh-gold);
}

.clh-milestone-next-text {
	margin: 8px 0 0;
	font-size: 0.92rem;
	color: var(--clh-text-muted);
}

.clh-milestone-next-text strong {
	color: var(--clh-warm);
	font-weight: 800;
}

.clh-milestone-banner {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 14px 16px;
	border-radius: var(--clh-radius);
	background: var(--clh-gold-soft);
	text-align: left;
	animation: clh-pop 0.5s cubic-bezier(0.2, 1.5, 0.4, 1);
}

.clh-milestone-banner-kicker {
	font-size: 0.76rem;
	font-weight: 800;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--clh-warm);
}

.clh-milestone-banner-title {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 2px 10px;
	font-size: 1.2rem;
	font-weight: 800;
	line-height: 1.3;
}

.clh-rank-en {
	font-size: 0.95rem;
	font-weight: 600;
	color: var(--clh-text-muted);
}

.clh-milestone-banner-note {
	margin-top: 2px;
	font-size: 0.88rem;
	color: var(--clh-text-muted);
}

/* ---- Tap a word to look it up ---- */

.clh-section-dialogue .clh-bubble-zh,
.clh-section-grammar .clh-zh,
.clh-section-text .clh-zh,
.clh-section-culture .clh-zh,
.clh-lookup-zone .clh-zh {
	cursor: pointer;
}

.clh-lookup-hit {
	border-radius: 4px;
	background: var(--clh-select-soft);
	box-shadow: 0 0 0 2px var(--clh-select-soft);
}

.clh-lookup {
	position: absolute;
	z-index: 60;
	width: max-content;
	min-width: 200px;
	max-width: min(320px, calc(100vw - 24px));
	padding: 14px 44px 14px 16px;
	border: 2px solid var(--clh-control-border);
	border-radius: var(--clh-radius);
	background: var(--clh-raised);
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
	color: var(--clh-text);
	font-family: var(--clh-font);
	font-size: 16px;
	line-height: 1.4;
}

.clh-lookup-close {
	position: absolute;
	top: 4px;
	right: 4px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--clh-text-muted);
	cursor: pointer;
}

.clh-lookup-close:hover {
	color: var(--clh-text);
}

.clh-lookup-entry + .clh-lookup-entry {
	margin-top: 10px;
	padding-top: 10px;
	border-top: 1px solid var(--clh-border);
}

.clh-lookup-head {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 2px 10px;
}

.clh-lookup-word {
	font-family: var(--clh-font-cn);
	font-size: 1.6rem;
	font-weight: 700;
	line-height: 1.2;
}

.clh-lookup-py {
	font-size: 1.05rem;
	font-weight: 600;
}

.clh-lookup-play {
	align-self: center;
	width: 36px;
	height: 36px;
}

.clh-lookup-en {
	margin-top: 2px;
}

.clh-lookup-pos {
	margin-left: 8px;
	font-size: 0.8rem;
	font-style: italic;
	color: var(--clh-text-muted);
}

.clh-lookup-missing {
	font-size: 0.9rem;
	color: var(--clh-text-muted);
}

.clh-lookup-actions {
	margin: 12px -28px 0 0;
}

.clh-lookup-add {
	min-height: 44px;
	width: 100%;
	padding: 6px 14px;
	border: 2px solid var(--clh-control-border);
	border-radius: 12px;
	background: transparent;
	color: var(--clh-text);
	font-family: inherit;
	font-size: 0.92rem;
	font-weight: 700;
	cursor: pointer;
}

.clh-lookup-add.is-done {
	border-color: transparent;
	background: var(--clh-green-soft);
	color: var(--clh-green);
	cursor: default;
}

.clh-lookup-hint {
	margin: -4px 0 14px;
	font-size: 0.88rem;
	color: var(--clh-text-muted);
}

/* ---- Reading settings ----
   Chinese text size: standard, large, extra large. */

:root.clh-zh-l {
	--clh-zh-scale: 1.15;
}

:root.clh-zh-xl {
	--clh-zh-scale: 1.3;
}

.clh-size-toggle .clh-seg {
	min-width: 40px;
	padding: 4px 10px;
	font-family: var(--clh-font-cn);
	line-height: 1;
}

.clh-size-toggle .clh-seg[data-size='m'] { font-size: 0.85rem; }
.clh-size-toggle .clh-seg[data-size='l'] { font-size: 1.05rem; }
.clh-size-toggle .clh-seg[data-size='xl'] { font-size: 1.3rem; }

/* Placeholder cards until the app draws (includes/Preload.php). */
.clh-skel {
	display: flex;
	flex-direction: column;
	gap: 14px;
	padding: 8px 0;
}

.clh-skel-line,
.clh-skel-card {
	border-radius: var(--clh-radius-sm, 10px);
	background: color-mix(in srgb, var(--clh-text, #1f1a17) 8%, transparent);
}

.clh-skel-line {
	width: 38%;
	height: 14px;
}

.clh-skel-line-title {
	width: 62%;
	height: 30px;
}

.clh-skel-line-short {
	width: 55%;
}

.clh-skel-title {
	font-family: var(--clh-font, system-ui, sans-serif);
	font-size: 1.9rem;
	font-weight: 800;
	line-height: 1.15;
	color: var(--clh-text);
}

.clh-skel-card {
	display: flex;
	flex-direction: column;
	gap: 12px;
	min-height: 150px;
	padding: 22px;
	border-radius: var(--clh-radius);
	background: var(--clh-card-bg);
}

.clh-skel-card .clh-skel-line {
	width: 70%;
}

.clh-skel-card .clh-skel-line-short {
	width: 45%;
}

@media (prefers-reduced-motion: no-preference) {
	.clh-skel-line,
	.clh-skel-card {
		animation: clh-skel-pulse 1.4s ease-in-out infinite;
	}
}

@keyframes clh-skel-pulse {
	50% {
		opacity: 0.55;
	}
}
