:root {
	--bg: #f2efe7;
	--bg-strong: #e6dfd1;
	--panel: rgba(252, 248, 241, 0.9);
	--panel-strong: #fffaf2;
	--ink: #1d2a28;
	--ink-muted: #556765;
	--line: rgba(29, 42, 40, 0.12);
	--line-strong: rgba(29, 42, 40, 0.18);
	--accent: #c45d1c;
	--accent-soft: rgba(196, 93, 28, 0.16);
	--secondary: #19594a;
	--secondary-soft: rgba(25, 89, 74, 0.14);
	--gold: #b49a49;
	--danger: #9c3a2c;
	--shadow: 0 24px 60px rgba(29, 42, 40, 0.1);
	--shadow-soft: 0 14px 36px rgba(29, 42, 40, 0.08);
	--radius: 24px;
	/* Semantic aliases (#243): exact shipped values, grouped by role. */
	/* Surfaces */
	--surface-card-gradient: linear-gradient(
		180deg,
		rgba(255, 252, 247, 0.95),
		rgba(244, 237, 226, 0.78)
	);
	--surface-field: rgba(255, 255, 255, 0.82);
	--surface-inset: rgba(255, 255, 255, 0.72);
	--surface-selected: rgba(255, 244, 236, 0.92);
	--surface-board-frame: #4b3a2a;
	--surface-ink-faint: rgba(29, 42, 40, 0.03);
	--surface-ink-subtle: rgba(29, 42, 40, 0.04);
	--surface-ink-wash: rgba(29, 42, 40, 0.08);
	--scrim: rgba(29, 42, 40, 0.64);
	--grid-line: rgba(29, 42, 40, 0.03);
	/* Borders */
	--line-soft: rgba(29, 42, 40, 0.08);
	--focus-border: rgba(196, 93, 28, 0.5);
	/* Foregrounds */
	--on-accent: #fff9f1;
	--on-danger: #fff;
	--text-caution: #806b1d;
	/* Gradients */
	--accent-gradient: linear-gradient(135deg, var(--accent), #de7d2f);
	--progress-stripe-strong: rgba(85, 103, 101, 0.34);
	--progress-stripe-soft: rgba(85, 103, 101, 0.16);
	/* Status washes and borders */
	--secondary-wash: rgba(25, 89, 74, 0.1);
	--danger-wash: rgba(156, 58, 44, 0.1);
	--danger-line: rgba(156, 58, 44, 0.18);
	/* Status-dot ring tints */
	--status-ring-neutral: rgba(85, 103, 101, 0.12);
	--status-ring-ok: rgba(25, 89, 74, 0.16);
	--status-ring-caution: rgba(180, 154, 73, 0.18);
	--status-ring-caution-soft: rgba(180, 154, 73, 0.16);
	--status-ring-error: rgba(156, 58, 44, 0.16);
	--status-ring-error-soft: rgba(156, 58, 44, 0.14);
	/* Shadows: elevation and focus rings */
	--shadow-accent: 0 14px 24px rgba(196, 93, 28, 0.18);
	--shadow-accent-strong: 0 16px 28px rgba(196, 93, 28, 0.24);
	--ring-focus: 0 0 0 4px rgba(196, 93, 28, 0.12);
	--ring-focus-danger: 0 0 0 4px rgba(156, 58, 44, 0.12);
	/* Spacing (#244): magnitude primitives, then the approved roles (DESIGN.md)
	   within < group < section < frame. 2/5/9/15px are optical steps. */
	--space-2: 2px;
	--space-4: 4px;
	--space-5: 5px;
	--space-6: 6px;
	--space-8: 8px;
	--space-9: 9px;
	--space-10: 10px;
	--space-12: 12px;
	--space-14: 14px;
	--space-15: 15px;
	--space-16: 16px;
	--space-18: 18px;
	--space-20: 20px;
	--space-22: 22px;
	--space-24: 24px;
	--space-28: 28px;
	--space-48: 48px;
	--space-within-1: var(--space-4);
	--space-within-2: var(--space-6);
	--space-within-3: var(--space-8);
	--space-within-4: var(--space-10);
	--space-group-1: var(--space-12);
	--space-group-2: var(--space-14);
	--space-group-3: var(--space-16);
	--space-group-4: var(--space-18);
	--space-section-1: var(--space-20);
	--space-section-2: var(--space-22);
	--space-section-3: var(--space-24);
	--space-section-4: var(--space-28);
	--space-frame: var(--space-48);
	/* Typography (#245): role families (three monospace stacks kept distinct),
	   then repeated shipped values by magnitude. Not a type scale. */
	--font-body: "Avenir Next", "Trebuchet MS", sans-serif;
	--font-display: "Iowan Old Style", "Palatino Linotype", serif;
	--font-mono: "SFMono-Regular", Menlo, Consolas, monospace;
	--font-mono-clock: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
	--font-mono-moves: "SFMono-Regular", ui-monospace, Menlo, monospace;
	--font-size-0-7: 0.7rem;
	--font-size-0-72: 0.72rem;
	--font-size-0-74: 0.74rem;
	--font-size-0-78: 0.78rem;
	--font-size-0-8: 0.8rem;
	--font-size-0-82: 0.82rem;
	--font-size-0-85: 0.85rem;
	--font-size-0-86: 0.86rem;
	--font-size-0-95: 0.95rem;
	--font-size-1-1: 1.1rem;
	--font-size-1-2: 1.2rem;
	--font-size-2-6: 2.6rem;
	--font-weight-500: 500;
	--font-weight-600: 600;
	--font-weight-700: 700;
	--line-height-1: 1;
	--line-height-1-4: 1.4;
	--line-height-1-5: 1.5;
	--letter-spacing-neg-0-02: -0.02em;
	--letter-spacing-0-06: 0.06em;
	--letter-spacing-0-08: 0.08em;
}

* {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	min-height: 100%;
	background:
		radial-gradient(
			circle at top left,
			rgba(196, 93, 28, 0.12),
			transparent 28%
		),
		radial-gradient(circle at top right, var(--secondary-soft), transparent 24%),
		linear-gradient(180deg, #f8f3ea 0%, var(--bg) 100%);
	color: var(--ink);
	font-family: var(--font-body);
}

body::before {
	content: "";
	position: fixed;
	inset: 0;
	background-image:
		linear-gradient(var(--grid-line) 1px, transparent 1px),
		linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
	background-size: 32px 32px;
	pointer-events: none;
}

button,
input,
select,
textarea {
	font: inherit;
}

code,
pre,
.result-json,
.job-meta {
	font-family: var(--font-mono);
}

.page-shell {
	width: min(1440px, calc(100% - 32px));
	margin: var(--space-section-3) auto var(--space-frame);
}

.is-hidden {
	/* biome-ignore lint/complexity/noImportantStyles: utility class must beat component display rules (e.g. .panel grid/flex) regardless of specificity or source order. */
	display: none !important;
}

.panel,
.job-panel,
.result-panel,
.notice-banner {
	background: var(--panel);
	border: 1px solid var(--line-soft);
	box-shadow: var(--shadow);
}

.panel-kicker {
	margin: 0 0 var(--space-within-4);
	text-transform: uppercase;
	letter-spacing: 0.16em;
	font-size: var(--font-size-0-74);
}

.panel-kicker {
	color: var(--accent);
}

h1,
h2,
.cluster-heading h3,
.disclosure-summary h3 {
	margin: 0;
	font-family: var(--font-display);
	letter-spacing: -0.03em;
}

h1 {
	font-size: clamp(2.8rem, 5vw, 4.6rem);
	line-height: 0.95;
}

h2 {
	font-size: 1.7rem;
}

.inline-note,
.result-placeholder p,
.metric-label,
.table-empty,
.job-empty,
.status-copy,
.workspace-note,
.cluster-heading p,
.disclosure-summary p {
	color: var(--ink-muted);
}

.health-pill {
	display: inline-flex;
	align-items: center;
	gap: var(--space-within-4);
	padding: var(--space-within-4) var(--space-group-2);
	border-radius: 999px;
	background: var(--surface-ink-wash);
}

.health-dot {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: var(--gold);
	box-shadow: 0 0 0 6px var(--status-ring-caution-soft);
}

.health-dot.ok {
	background: var(--secondary);
	box-shadow: 0 0 0 6px var(--status-ring-ok);
}

.health-dot.error {
	background: var(--danger);
	box-shadow: 0 0 0 6px var(--status-ring-error-soft);
}

.workflow-nav {
	margin-top: var(--space-group-4);
	display: inline-flex;
	flex-wrap: wrap;
	gap: var(--space-within-4);
	padding: var(--space-within-4);
	border-radius: 18px;
	background: rgba(255, 250, 243, 0.74);
	border: 1px solid var(--line-soft);
	box-shadow: var(--shadow-soft);
}

.workflow-nav-button {
	appearance: none;
	border: 1px solid var(--secondary-soft);
	background: rgba(25, 89, 74, 0.06);
	color: var(--secondary);
	border-radius: 999px;
	padding: var(--space-within-4) var(--space-group-3);
	cursor: pointer;
	transition:
		background 160ms ease,
		color 160ms ease,
		transform 160ms ease,
		box-shadow 160ms ease;
}

.workflow-nav-button.active {
	background: var(--accent-gradient);
	color: var(--on-accent);
	box-shadow: var(--shadow-accent);
	border-color: rgba(196, 93, 28, 0.28);
}

/* #353: Tools disclosure menu holding every workflow except Train. */
/* .reveal leaves a transform on the nav, so it is its own stacking context;
   lift it above the later .reveal panels or they cover the open menu. */
.workflow-nav-primary {
	position: relative;
	z-index: 20;
}

.tools-menu {
	position: relative;
}

.tools-menu-trigger {
	display: inline-flex;
	align-items: center;
	gap: var(--space-within-2);
}

.tools-menu-trigger::after {
	content: "";
	width: 0;
	height: 0;
	border-inline: 4px solid transparent;
	border-top: 5px solid currentColor;
	transition: transform 160ms ease;
}

.tools-menu-trigger[aria-expanded="true"]::after {
	transform: rotate(180deg);
}

.tools-menu-current:not(:empty)::before {
	content: "· ";
}

.tools-menu-list {
	position: absolute;
	top: calc(100% + var(--space-within-3));
	inset-inline-start: 0;
	z-index: 30;
	display: grid;
	gap: var(--space-2);
	min-width: 220px;
	max-width: calc(100vw - 32px);
	padding: var(--space-within-2);
	border: 1px solid var(--line);
	border-radius: 16px;
	background: var(--panel-strong);
	box-shadow: var(--shadow-soft);
}

.tools-menu-list[hidden],
.tools-menu-item[hidden] {
	display: none;
}

.tools-menu-item {
	appearance: none;
	border: 0;
	border-radius: 10px;
	padding: var(--space-within-4) var(--space-group-1);
	background: transparent;
	color: var(--ink);
	text-align: start;
	cursor: pointer;
}

.tools-menu-item:hover {
	background: var(--secondary-wash);
}

.tools-menu-item.active {
	background: var(--secondary-wash);
	color: var(--secondary);
	font-weight: var(--font-weight-600);
}

.tools-menu-item:focus-visible,
.workflow-nav-button:focus-visible,
.notice-link:focus-visible {
	outline: none;
	box-shadow: var(--ring-focus);
}

/* "Open Tools" inside the train-load-error banner reads as an inline link. */
.notice-link {
	appearance: none;
	border: 0;
	padding: 0;
	background: none;
	color: inherit;
	font-weight: inherit;
	text-decoration: underline;
	cursor: pointer;
}

.layout {
	margin-top: var(--space-section-3);
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--space-section-3);
	align-items: start;
}

.notice-banner {
	margin-top: var(--space-group-4);
	padding: var(--space-group-2) var(--space-group-4);
	border-radius: 18px;
	font-weight: var(--font-weight-600);
}

.notice-banner.error {
	display: block;
	background: var(--danger-wash);
	border-color: var(--danger-line);
	color: var(--danger);
}

.notice-banner.info {
	display: block;
	background: var(--secondary-wash);
	border-color: rgba(25, 89, 74, 0.18);
	color: var(--secondary);
}

.control-grid,
.source-grid {
	display: grid;
	/* minmax(0, 1fr): a wide table or long path inside must scroll in its own
	   box, not stretch the column (and the page) past a phone screen. */
	grid-template-columns: minmax(0, 1fr);
	gap: var(--space-section-3);
}

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

.panel,
.job-panel,
.result-panel {
	border-radius: var(--radius);
	padding: var(--space-section-3);
}

.panel-accent {
	background:
		linear-gradient(
			135deg,
			rgba(255, 250, 242, 0.95),
			rgba(244, 233, 217, 0.88)
		),
		var(--panel);
}

.panel-heading {
	display: flex;
	align-items: end;
	justify-content: space-between;
	gap: var(--space-group-3);
	margin-bottom: var(--space-group-4);
}

.stack-form {
	display: grid;
	gap: var(--space-group-2);
}

.form-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--space-group-3);
}

.form-cluster {
	display: grid;
	gap: var(--space-group-2);
	padding: var(--space-group-4);
	border-radius: 20px;
	border: 1px solid var(--line-soft);
	background: var(--surface-card-gradient);
}

.form-cluster-featured {
	padding: var(--space-section-2);
	background: linear-gradient(
		135deg,
		rgba(255, 248, 239, 0.98),
		rgba(248, 235, 216, 0.9)
	);
	border-color: rgba(196, 93, 28, 0.18);
}

.cluster-heading {
	display: grid;
	gap: var(--space-within-2);
}

.cluster-kicker {
	margin: 0;
	text-transform: uppercase;
	letter-spacing: 0.14em;
	font-size: var(--font-size-0-72);
	color: var(--secondary);
}

.cluster-heading h3,
.disclosure-summary h3 {
	font-size: var(--font-size-1-1);
}

.cluster-heading p,
.disclosure-summary p {
	margin: 0;
	line-height: var(--line-height-1-5);
	font-size: 0.92rem;
}

.disclosure-card {
	border: 1px solid var(--line-soft);
	border-radius: 22px;
	background: rgba(255, 250, 243, 0.72);
	/* Not overflow: hidden: a field tooltip near the bottom must be able to
	   hang below the card instead of being cut off. */
	box-shadow: var(--shadow-soft);
}

.disclosure-card[open] {
	background: rgba(255, 251, 246, 0.86);
}

.disclosure-summary {
	list-style: none;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-group-3);
	padding: var(--space-group-4) var(--space-section-1);
	cursor: pointer;
}

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

.disclosure-summary::after {
	content: "+";
	width: 34px;
	height: 34px;
	border-radius: 50%;
	display: inline-grid;
	place-items: center;
	flex: 0 0 auto;
	font-size: 1.3rem;
	line-height: var(--line-height-1);
	color: var(--secondary);
	background: var(--secondary-wash);
	border: 1px solid rgba(25, 89, 74, 0.12);
}

.disclosure-card[open] .disclosure-summary::after {
	content: "−";
}

.disclosure-body {
	padding: 0 var(--space-group-4) var(--space-group-4);
}

.table-disclosure .disclosure-body {
	padding-top: 0;
}

.stack-form label {
	display: grid;
	gap: var(--space-within-3);
}

.stack-form span {
	font-size: 0.84rem;
	color: var(--ink-muted);
	text-transform: uppercase;
	letter-spacing: var(--letter-spacing-0-08);
}

.field-required-marker {
	display: inline;
	margin-left: var(--space-within-1);
	color: var(--accent);
	font-size: 0.96em;
	font-weight: var(--font-weight-700);
	line-height: var(--line-height-1);
}

input,
textarea,
select {
	width: 100%;
	padding: var(--space-group-2) var(--space-15);
	border-radius: 14px;
	border: 1px solid var(--line);
	background: var(--surface-field);
	color: var(--ink);
	transition:
		border-color 160ms ease,
		transform 160ms ease,
		box-shadow 160ms ease;
}

input:focus,
textarea:focus,
select:focus {
	outline: none;
	border-color: var(--focus-border);
	box-shadow: var(--ring-focus);
	transform: translateY(-1px);
}

.field-input-invalid,
.field-input-invalid:focus {
	border-color: rgba(156, 58, 44, 0.46);
	box-shadow: var(--ring-focus-danger);
}

.field-error {
	margin-top: var(--space-2);
	font-size: var(--font-size-0-8);
	line-height: var(--line-height-1-4);
	color: var(--danger);
	text-transform: none;
	letter-spacing: 0;
}

textarea {
	min-height: 96px;
	resize: vertical;
}

.two-up,
.three-up,
.four-up,
.button-row {
	display: grid;
	gap: var(--space-group-1);
}

.two-up {
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.three-up {
	grid-template-columns: repeat(3, minmax(0, 1fr));
}

.four-up {
	grid-template-columns: repeat(4, minmax(0, 1fr));
}

.button-row {
	grid-template-columns: 1fr 1fr;
}

.player-filter-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--space-group-2);
}

.player-filter-card {
	display: grid;
	gap: var(--space-group-2);
	padding: var(--space-group-4);
	border-radius: 18px;
	border: 1px solid var(--line);
	background: rgba(255, 255, 255, 0.42);
}

.mode-panel {
	display: grid;
	gap: var(--space-group-1);
}

.mode-panel.is-hidden {
	display: none;
}

/* REQ-07 (#20): mount points for createRatingClockFilter. display:contents lets
   the JS-rendered .two-up rows participate in the surrounding grid (.form-cluster
   / .mode-panel) directly, so spacing matches the former inline markup. */
.rating-clock-mount {
	display: contents;
}

/* label.toggle-row: outranks `.stack-form label` (display: grid), which
   otherwise stacks the box above its text inside a stack-form. */
label.toggle-row,
.toggle-row {
	display: flex;
	align-items: center;
	gap: var(--space-group-1);
	padding: var(--space-within-4) 0 var(--space-within-1);
}

.toggle-row span {
	margin: 0;
	text-transform: none;
	letter-spacing: 0;
	font-size: var(--font-size-0-95);
}

.toggle-row input {
	width: 20px;
	height: 20px;
	margin: 0;
}

.inline-toggle {
	align-items: end;
	padding: 0;
}

.disclosure-toggle-row {
	border: 1px solid var(--line);
	border-radius: 14px;
	padding: var(--space-group-2) var(--space-15);
	background: var(--surface-field);
}

.action-button,
.ghost-button {
	appearance: none;
	border: none;
	cursor: pointer;
	border-radius: 14px;
	padding: var(--space-group-2) var(--space-group-3);
	transition:
		transform 160ms ease,
		box-shadow 160ms ease,
		opacity 160ms ease;
}

.action-button {
	background: var(--accent-gradient);
	color: var(--on-accent);
	box-shadow: var(--shadow-accent-strong);
}

.ghost-button {
	background: rgba(25, 89, 74, 0.08);
	color: var(--secondary);
	border: 1px solid var(--secondary-soft);
}

.small-button {
	padding: var(--space-within-4) var(--space-group-1);
}

/* A run button and the Stop button shown beside it while the run goes. */
.run-buttons {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--space-within-4);
}

.action-button:hover,
.ghost-button:hover,
.job-item:hover {
	transform: translateY(-1px);
}

/* A disabled button must not look pressable (Train "Next" read as live). */
.action-button:disabled,
.ghost-button:disabled,
.ghost-button[aria-disabled="true"] {
	opacity: 0.45;
	cursor: not-allowed;
	box-shadow: none;
	transform: none;
}

.workspace-grid {
	display: grid;
	grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
	gap: var(--space-section-3);
	align-items: start;
}

.workspace-note {
	margin: 0 0 var(--space-group-2);
	line-height: var(--line-height-1-5);
}

/* REQ-08 (#21): the job workspace sidebar is one card stacking two sections
   (Presets + Recent Jobs). It stays inside #workspace-grid so the REQ-12 (#145)
   producer/tool gate hides it under tool modes. */
.job-panel {
	min-height: 360px;
	display: flex;
	flex-direction: column;
	gap: var(--space-section-1);
	overflow: hidden;
}

/* Each section keeps the original heading / note / scrolling-list rows. */
.sidebar-section {
	min-height: 0;
	display: grid;
	grid-template-rows: auto auto minmax(0, 1fr);
	overflow: hidden;
}

.preset-section {
	grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.sidebar-toggle {
	display: none;
	width: 100%;
	justify-content: center;
}

.job-entry {
	display: grid;
	gap: var(--space-within-2);
}

.job-reuse {
	justify-self: start;
}

.preset-chip {
	text-transform: capitalize;
}

.jobs-list {
	display: grid;
	gap: var(--space-within-4);
	min-height: 0;
	max-height: 720px;
	overflow-y: auto;
	padding-right: var(--space-within-2);
}

.job-panel .panel-heading {
	margin-bottom: var(--space-within-3);
}

.job-item {
	border: 1px solid var(--line);
	background: rgba(255, 255, 255, 0.75);
	border-radius: 18px;
	padding: var(--space-group-2);
	cursor: pointer;
	transition:
		border-color 160ms ease,
		background 160ms ease,
		transform 160ms ease;
}

.job-item.active {
	border-color: rgba(196, 93, 28, 0.4);
	background: var(--surface-selected);
}

.job-item-failed {
	border-color: var(--danger-line);
	background: rgba(255, 246, 244, 0.86);
}

.job-title,
.job-meta {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-group-1);
}

.job-title {
	font-weight: var(--font-weight-700);
}

.job-summary {
	margin-top: var(--space-within-4);
	font-size: var(--font-size-0-86);
	line-height: 1.45;
	color: var(--ink-muted);
	text-align: left;
}

.job-meta {
	margin-top: var(--space-within-3);
	font-size: var(--font-size-0-78);
	color: var(--ink-muted);
}

.status-chip {
	padding: var(--space-5) var(--space-9);
	border-radius: 999px;
	font-size: var(--font-size-0-72);
	text-transform: uppercase;
	letter-spacing: var(--letter-spacing-0-08);
	background: var(--surface-ink-wash);
	color: var(--ink-muted);
}

.status-chip.running,
.status-chip.queued {
	background: rgba(180, 154, 73, 0.14);
	color: var(--text-caution);
}

.status-chip.cancelling {
	background: rgba(180, 154, 73, 0.2);
	color: var(--text-caution);
}

.status-chip.completed {
	background: var(--secondary-soft);
	color: var(--secondary);
}

.status-chip.failed,
.status-chip.cancelled {
	background: rgba(156, 58, 44, 0.12);
	color: var(--danger);
}

.result-panel {
	min-height: 360px;
}

.result-placeholder {
	min-height: 270px;
	display: grid;
	align-content: center;
	justify-items: start;
	gap: var(--space-within-4);
}

.metric-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
	gap: var(--space-group-2);
	margin-bottom: var(--space-group-4);
}

.metric-card {
	padding: var(--space-group-3);
	border-radius: 18px;
	background: linear-gradient(
		180deg,
		var(--panel-strong),
		rgba(243, 236, 224, 0.92)
	);
	border: 1px solid var(--line);
}

.metric-value {
	margin-top: var(--space-within-4);
	font-size: 1.55rem;
	font-weight: var(--font-weight-700);
}

.metric-value-small {
	font-size: 1.05rem;
	word-break: break-word;
}

.metric-label {
	font-size: var(--font-size-0-8);
	letter-spacing: 0.07em;
	text-transform: uppercase;
}

/* What the number above it means, in one plain sentence. */
.metric-note {
	margin: var(--space-within-3) 0 0;
	font-size: var(--font-size-0-8);
	line-height: var(--line-height-1-4);
	color: var(--ink-muted);
}

.result-section {
	margin-bottom: var(--space-group-4);
}

.result-subhead {
	margin: var(--space-within-2) 0 var(--space-group-2);
	font-family: var(--font-display);
	font-size: var(--font-size-1-2);
	letter-spacing: var(--letter-spacing-neg-0-02);
}

h4.result-subhead {
	margin-top: var(--space-group-3);
	font-size: var(--font-size-1-1);
}

.progress-grid {
	margin-top: var(--space-group-3);
}

/* Job progress bar + ETA/step lines (REQ-010 / #36). The bar colour reflects
   the job status; queued jobs show an animated gray-striped indeterminate bar. */
.job-progress {
	display: grid;
	gap: var(--space-within-4);
	margin-bottom: var(--space-group-4);
}

.job-progress-bar {
	-webkit-appearance: none;
	appearance: none;
	width: 100%;
	height: 10px;
	border: 1px solid var(--line);
	border-radius: 999px;
	overflow: hidden;
	background: var(--surface-ink-wash);
}

.job-progress-bar::-webkit-progress-bar {
	background: var(--surface-ink-wash);
	border-radius: 999px;
}

.job-progress-bar::-webkit-progress-value {
	border-radius: 999px;
	background: var(--ink-muted);
	transition: width 0.4s ease;
}

.job-progress-bar::-moz-progress-bar {
	border-radius: 999px;
	background: var(--ink-muted);
}

/* running -> green */
.job-progress-bar.progress-running::-webkit-progress-value {
	background: var(--secondary);
}
.job-progress-bar.progress-running::-moz-progress-bar {
	background: var(--secondary);
}

/* cancelling -> amber */
.job-progress-bar.progress-cancelling::-webkit-progress-value {
	background: var(--gold);
}
.job-progress-bar.progress-cancelling::-moz-progress-bar {
	background: var(--gold);
}

/* failed -> red */
.job-progress-bar.progress-failed::-webkit-progress-value {
	background: var(--danger);
}
.job-progress-bar.progress-failed::-moz-progress-bar {
	background: var(--danger);
}

/* queued (indeterminate) -> animated gray stripes */
.job-progress-bar.progress-queued,
.job-progress-bar:indeterminate {
	background-image: repeating-linear-gradient(
		45deg,
		var(--progress-stripe-strong) 0,
		var(--progress-stripe-strong) 8px,
		var(--progress-stripe-soft) 8px,
		var(--progress-stripe-soft) 16px
	);
	background-size: 22px 22px;
	animation: progress-stripes 0.8s linear infinite;
}

.job-progress-bar.progress-queued::-webkit-progress-bar {
	background: transparent;
}

@keyframes progress-stripes {
	from {
		background-position: 0 0;
	}
	to {
		background-position: 22px 0;
	}
}

.progress-eta,
.progress-step {
	margin: 0;
	font-size: var(--font-size-0-82);
	color: var(--ink-muted);
	font-variant-numeric: tabular-nums;
}

.progress-eta-warmup {
	font-style: italic;
}

.result-actions {
	margin-top: var(--space-group-3);
	max-width: 280px;
}

.result-headline {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-group-3);
	margin-bottom: var(--space-section-1);
}

.result-headline p {
	margin: var(--space-within-2) 0 0;
}

.status-copy {
	margin-top: var(--space-within-3);
}

.result-context {
	margin-bottom: var(--space-group-4);
	padding: var(--space-group-4);
	border-radius: 20px;
	border: 1px solid var(--line);
	background: var(--surface-card-gradient);
}

.result-context h3 {
	margin: 0;
	font-size: var(--font-size-1-2);
	font-family: var(--font-display);
	letter-spacing: var(--letter-spacing-neg-0-02);
}

.result-context .status-copy {
	margin-top: var(--space-within-2);
}

.workflow-comparison {
	margin-bottom: var(--space-group-4);
	padding: var(--space-group-4);
	border-radius: 20px;
	border: 1px solid var(--line);
	background: var(--surface-card-gradient);
}

.workflow-comparison h3 {
	margin: 0;
	font-size: var(--font-size-1-2);
	font-family: var(--font-display);
	letter-spacing: var(--letter-spacing-neg-0-02);
}

.workflow-recommendation {
	margin-top: var(--space-within-2);
	margin-bottom: var(--space-group-1);
}

.workflow-table th[scope="row"] {
	color: var(--ink-muted);
	font-weight: var(--font-weight-500);
	width: 40%;
}

.workflow-table td {
	font-variant-numeric: tabular-nums;
}

/* Counter-intuitive verdict (REQ-006 / #49). */
.verdict-card {
	margin-bottom: var(--space-group-4);
	padding: var(--space-group-4);
	border-radius: 20px;
	border: 1px solid var(--line);
	background: var(--surface-card-gradient);
}

.verdict-headline {
	margin: var(--space-within-2) 0 0;
	font-size: 1.5rem;
	line-height: 1.25;
	font-family: var(--font-display);
	letter-spacing: var(--letter-spacing-neg-0-02);
}

.verdict-narrative {
	margin-top: var(--space-group-1);
}

.verdict-flags {
	list-style: none;
	margin: var(--space-group-2) 0 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-within-3);
}

.verdict-flag-chip {
	display: inline-flex;
	align-items: center;
	gap: var(--space-within-3);
	max-width: 100%;
	padding: var(--space-within-3) var(--space-group-1);
	border-radius: 999px;
	border: 1px solid rgba(156, 58, 44, 0.32);
	background: var(--danger-wash);
	color: var(--danger);
	font-size: var(--font-size-0-85);
}

.verdict-flag-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: var(--danger);
	color: var(--on-danger);
	font-weight: var(--font-weight-700);
	font-size: var(--font-size-0-72);
	flex-shrink: 0;
}

.verdict-flag-text {
	display: inline-flex;
	flex-direction: column;
	min-width: 0;
}

.verdict-flag-name {
	font-weight: var(--font-weight-600);
}

.verdict-flag-summary {
	color: var(--ink-muted);
	font-size: var(--font-size-0-78);
}

.verdict-flag-value {
	font-variant-numeric: tabular-nums;
	font-weight: var(--font-weight-600);
	flex-shrink: 0;
}

.verdict-table {
	margin-top: 0;
}

.verdict-table th[scope="row"] {
	color: var(--ink-muted);
	font-weight: var(--font-weight-500);
	text-transform: none;
	letter-spacing: 0;
}

.verdict-table td {
	font-variant-numeric: tabular-nums;
}

.verdict-card .verdict-table {
	margin-top: var(--space-group-2);
}

.verdict-games {
	margin-top: var(--space-group-2);
}

.verdict-games-label {
	margin: 0 0 var(--space-within-3);
	font-size: var(--font-size-0-78);
	text-transform: uppercase;
	letter-spacing: var(--letter-spacing-0-08);
	color: var(--ink-muted);
}

.verdict-games-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-within-3);
}

.verdict-game-chip {
	display: inline-flex;
	align-items: center;
	padding: var(--space-within-2) var(--space-group-1);
	border-radius: 999px;
	border: 1px solid var(--line-strong);
	background: rgba(255, 255, 255, 0.6);
	color: var(--ink-muted);
	font: inherit;
	font-size: var(--font-size-0-82);
	font-variant-numeric: tabular-nums;
	cursor: pointer;
	transition:
		border-color 160ms ease,
		background 160ms ease,
		color 160ms ease;
}

/* REQ-009 (#52): clickable cited-game chips deep-dive into a single game. */
button.verdict-game-chip:hover,
button.verdict-game-chip:focus-visible {
	border-color: var(--focus-border);
	background: var(--surface-selected);
	color: var(--ink);
}

.verdict-game-chip[aria-disabled="true"] {
	cursor: default;
}

/* --------------------------------------------------------------------------
   Deep Dive panel (REQ-009 / #52). Sits beside the result inside .result-stack;
   the stack is a single column until .deep-dive-open splits it into two.
   -------------------------------------------------------------------------- */
.result-stack {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--space-section-3);
	align-items: start;
}

.result-stack.deep-dive-open {
	grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.9fr);
}

.deep-dive-panel {
	border-radius: var(--radius);
	padding: var(--space-section-3);
	background: var(--panel);
	border: 1px solid var(--line-soft);
	box-shadow: var(--shadow);
	min-height: 200px;
}

.deep-dive-head {
	display: flex;
	align-items: start;
	justify-content: space-between;
	gap: var(--space-group-3);
	margin-bottom: var(--space-group-3);
}

.deep-dive-head h2 {
	margin: var(--space-within-1) 0 0;
}

.deep-dive-meta {
	margin: 0 0 var(--space-group-2);
	font-size: var(--font-size-0-82);
	line-height: var(--line-height-1-5);
	color: var(--ink-muted);
}

.deep-dive-status {
	display: grid;
	gap: var(--space-within-4);
	justify-items: start;
	padding: var(--space-within-3) 0;
}

.deep-dive-loading {
	grid-auto-flow: column;
	align-items: center;
	justify-content: start;
}

.deep-dive-spinner {
	width: 18px;
	height: 18px;
	border-radius: 50%;
	border: 2px solid var(--line-strong);
	border-top-color: var(--secondary);
	animation: deep-dive-spin 800ms linear infinite;
}

@keyframes deep-dive-spin {
	to {
		transform: rotate(360deg);
	}
}

.deep-dive-failure h3 {
	margin: 0;
}

.deep-dive-hint {
	color: var(--ink-muted);
}

.deep-dive-plies {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: var(--space-group-1);
	max-height: 640px;
	overflow-y: auto;
}

.deep-dive-ply {
	border: 1px solid var(--line);
	border-radius: 16px;
	padding: var(--space-group-1) var(--space-group-2);
	background: var(--surface-inset);
	display: grid;
	gap: var(--space-within-3);
}

.deep-dive-ply-head {
	display: flex;
	align-items: baseline;
	gap: var(--space-within-4);
	justify-content: space-between;
}

.deep-dive-ply-index {
	font-size: var(--font-size-0-72);
	text-transform: uppercase;
	letter-spacing: var(--letter-spacing-0-08);
	color: var(--ink-muted);
}

.deep-dive-ply-move {
	font-weight: var(--font-weight-700);
	font-variant-numeric: tabular-nums;
}

.deep-dive-ply-eval {
	margin-left: auto;
	font-variant-numeric: tabular-nums;
	color: var(--secondary);
}

.deep-dive-position {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 36px;
	border-radius: 12px;
	border: 1px dashed var(--line);
	background: var(--surface-ink-faint);
}

.deep-dive-position-label {
	font-size: var(--font-size-0-74);
	text-transform: uppercase;
	letter-spacing: var(--letter-spacing-0-08);
	color: var(--ink-muted);
}

.deep-dive-deltas {
	display: flex;
	gap: var(--space-group-4);
	margin: 0;
}

.deep-dive-deltas div {
	display: grid;
	gap: var(--space-2);
}

.deep-dive-deltas dt {
	font-size: var(--font-size-0-7);
	text-transform: uppercase;
	letter-spacing: var(--letter-spacing-0-06);
	color: var(--ink-muted);
}

.deep-dive-deltas dd {
	margin: 0;
	font-variant-numeric: tabular-nums;
}

.deep-dive-badges {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-within-2);
}

.deep-dive-badge {
	padding: 3px var(--space-9);
	border-radius: 999px;
	font-size: var(--font-size-0-7);
	text-transform: uppercase;
	letter-spacing: var(--letter-spacing-0-06);
	font-weight: var(--font-weight-600);
}

.deep-dive-badge--only-move {
	background: rgba(180, 154, 73, 0.18);
	color: var(--text-caution);
}

.deep-dive-badge--maia {
	background: rgba(156, 58, 44, 0.14);
	color: var(--danger);
}

.maia-fields {
	margin-top: var(--space-group-1);
	padding: var(--space-group-2) var(--space-group-3);
	border-radius: 18px;
	border: 1px dashed var(--line);
	background: rgba(255, 255, 255, 0.55);
}

.maia-fields .inline-note {
	margin-top: 0;
}

.payload-disclosure {
	margin-top: var(--space-group-4);
}

.payload-disclosure .disclosure-body {
	padding-top: 0;
}

.result-json {
	margin: 0;
	padding: var(--space-group-4);
	border-radius: 18px;
	background: #1c2424;
	color: #dbe4df;
	overflow-x: auto;
}

.table-frame {
	overflow-x: auto;
	border: 1px solid var(--line);
	border-radius: 18px;
	background: var(--surface-inset);
}

.data-table {
	width: 100%;
	border-collapse: collapse;
}

.data-table th,
.data-table td {
	padding: var(--space-group-1) var(--space-group-2);
	border-bottom: 1px solid var(--line-soft);
	text-align: left;
	vertical-align: top;
}

.data-table th {
	font-size: var(--font-size-0-78);
	text-transform: uppercase;
	letter-spacing: var(--letter-spacing-0-08);
	color: var(--ink-muted);
}

.reveal {
	opacity: 0;
	transform: translateY(18px);
	animation: reveal 700ms ease forwards;
}

.reveal:nth-of-type(2) {
	animation-delay: 100ms;
}

.reveal:nth-of-type(3) {
	animation-delay: 180ms;
}

.reveal:nth-of-type(4) {
	animation-delay: 260ms;
}

@keyframes reveal {
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@media (max-width: 1180px) {
	.source-grid,
	.workspace-grid,
	.result-stack.deep-dive-open {
		grid-template-columns: minmax(0, 1fr);
	}
}

/* REQ-08 (#21): sidebar is persistent at >= 1024px; below that it collapses to
   a drawer toggled open via #sidebar-toggle. */
@media (max-width: 1023px) {
	.sidebar-toggle {
		display: inline-flex;
	}

	.job-sidebar {
		display: none;
	}

	.job-sidebar.is-open {
		display: flex;
	}
}

@media (max-width: 860px) {
	.workflow-nav,
	.form-grid,
	.player-filter-grid,
	.two-up,
	.three-up,
	.four-up,
	.button-row {
		grid-template-columns: 1fr;
	}

	.page-shell {
		width: min(100% - 20px, 1440px);
		margin-top: var(--space-12);
	}

	.panel,
	.job-panel,
	.result-panel,
	.notice-banner {
		padding: var(--space-18);
		border-radius: 22px;
	}

	.disclosure-summary {
		padding: var(--space-group-3);
	}

	.panel-heading {
		flex-wrap: wrap;
	}

	h1 {
		font-size: var(--font-size-2-6);
	}
}

.opening-board-row {
	display: grid;
	grid-template-columns: minmax(220px, 300px) 1fr;
	gap: var(--space-group-4);
	align-items: center;
	margin-top: var(--space-group-2);
	padding: var(--space-group-2);
	border-radius: 18px;
	background: var(--surface-ink-subtle);
	border: 1px solid var(--line-soft);
}

.opening-board-wrap {
	aspect-ratio: 1 / 1;
	width: 100%;
	max-width: 300px;
	border-radius: 8px;
	overflow: hidden;
	background: var(--surface-board-frame);
}

#opening-board.cg-wrap {
	width: 100%;
	height: 100%;
	aspect-ratio: 1 / 1;
}

.opening-board-meta {
	display: grid;
	gap: var(--space-within-2);
}

.opening-board-actions {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-within-2);
}

#opening-board-status.is-invalid {
	color: var(--danger);
	font-weight: var(--font-weight-600);
}

@media (max-width: 720px) {
	.opening-board-row {
		grid-template-columns: 1fr;
	}
	.opening-board-wrap {
		max-width: 100%;
	}
}

/* ===== Field tooltips ===== */
/* Reusable info-icon + tooltip pattern. Trigger is a real <button> so it's
   keyboard-focusable; tooltip is a <span role="tooltip"> referenced via
   aria-describedby. Show on :hover, :focus-visible, and parent :focus-within. */

label:has(> .tooltip-trigger) {
	position: relative;
}

/* In a stack form every label is a one-column grid, which would put the info
   button on its own row. Use three columns instead: the caption (it wraps when
   space is short, keeping its "*"), the button right after it, then the rest
   of the row. The input spans the next row, and inputs sit at the bottom so a
   row of fields lines up even when one caption wraps. The tooltip is
   absolutely positioned, so it takes no grid cell. */
.stack-form label:not(.toggle-row):has(> .tooltip-trigger) {
	grid-template-columns: minmax(0, max-content) auto 1fr;
	align-items: center;
	align-content: end;
	column-gap: var(--space-within-2);
}

.stack-form label:not(.toggle-row):has(> .tooltip-trigger) > span:first-child {
	display: block;
}

.stack-form
	label:not(.toggle-row):has(> .tooltip-trigger)
	> :not(:first-child, .tooltip-trigger, .field-tooltip) {
	grid-column: 1 / -1;
}

/* An open tooltip can hang past its panel; lift that panel above the panels
   after it (each .reveal panel is its own stacking context). */
.panel:has(.tooltip-trigger:hover),
.panel:has(.tooltip-trigger:focus-visible),
.panel:has(label:focus-within > .tooltip-trigger) {
	position: relative;
	z-index: 30;
}

label > span:has(+ .tooltip-trigger) {
	display: inline-flex;
	align-items: center;
	gap: var(--space-within-2);
}

.tooltip-trigger {
	width: 18px;
	height: 18px;
	padding: 0;
	margin: 0;
	border: 0;
	background: transparent;
	color: var(--ink-muted);
	cursor: help;
	border-radius: 50%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: color 120ms ease;
}

.tooltip-trigger:hover,
.tooltip-trigger:focus-visible {
	color: var(--accent);
}

.tooltip-trigger:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

.tooltip-trigger > svg {
	width: 16px;
	height: 16px;
	display: block;
}

.field-tooltip {
	position: absolute;
	top: calc(100% + 6px);
	left: 0;
	z-index: 10;
	max-width: 22rem;
	min-width: 14rem;
	padding: var(--space-within-4) var(--space-group-1);
	border-radius: 12px;
	background: var(--ink);
	color: var(--panel-strong);
	box-shadow: var(--shadow-soft);
	font-size: var(--font-size-0-85);
	line-height: var(--line-height-1-4);
	font-weight: 400;
	opacity: 0;
	pointer-events: none;
	transform: translateY(-4px);
	transition:
		opacity 120ms ease,
		transform 120ms ease;
}

.field-tooltip--right {
	left: auto;
	right: 0;
}

.field-tooltip code {
	background: rgba(255, 255, 255, 0.12);
	padding: 1px var(--space-within-1);
	border-radius: 4px;
}

/* `.stack-form span` styles field captions (small caps); a tooltip is prose. */
.stack-form .field-tooltip {
	font-size: var(--font-size-0-85);
	color: var(--panel-strong);
	text-transform: none;
	letter-spacing: normal;
}

.tooltip-trigger:hover + .field-tooltip,
.tooltip-trigger:focus-visible + .field-tooltip,
label:focus-within > .tooltip-trigger + .field-tooltip {
	opacity: 1;
	pointer-events: auto;
	transform: translateY(0);
}

/* ===== Weakness trainer ===== */
.train-grid {
	display: grid;
	gap: var(--space-section-1);
}

/* Train sub-sections (Weakness Trainer / Visualization Trainer): the sub-nav
   reuses the primary .workflow-nav pill bar, left-aligned inside the grid. */
.train-subnav {
	margin-top: 0;
	justify-self: start;
}

.train-section {
	display: grid;
	gap: var(--space-section-1);
}

.train-subnav .workflow-nav-button {
	padding: var(--space-within-3) var(--space-group-2);
	font-size: var(--font-size-0-86);
}

/* ===== Weakness evolution (Weakness Trainer section) ===== */
.weakness-evolution {
	display: grid;
	gap: var(--space-group-3);
}

.weakness-group {
	display: grid;
	gap: var(--space-within-4);
}

.weakness-group-heading {
	display: flex;
	align-items: center;
	gap: var(--space-within-3);
	margin: 0;
	text-transform: capitalize;
}

.weakness-count {
	padding: 0 var(--space-within-3);
	border-radius: 999px;
	background: var(--secondary-soft);
	color: var(--secondary);
	font-size: var(--font-size-0-78);
}

.weakness-card {
	display: grid;
	gap: var(--space-within-3);
	padding: var(--space-group-1);
	border: 1px solid var(--line-soft);
	border-radius: 12px;
}

.weakness-card-head {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: var(--space-within-2) var(--space-within-4);
	font-size: var(--font-size-0-86);
}

.weakness-tag {
	font-weight: var(--font-weight-600);
}

.weakness-timeline {
	display: grid;
	gap: var(--space-within-1);
	margin: 0;
	padding: 0;
	list-style: none;
	font-size: var(--font-size-0-82);
}

.weakness-event {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-within-4);
}

.weakness-event > :empty {
	display: none;
}

.weakness-empty {
	margin: 0;
	font-size: var(--font-size-0-86);
}

.weakness-phase,
.weakness-first,
.weakness-severity,
.weakness-resolved,
.weakness-event-time,
.weakness-empty {
	color: var(--ink-muted);
}

/* The set picker is taller than the title: line both up at the top. */
.train-topics-panel > .panel-heading {
	align-items: start;
}

.train-set-picker {
	display: flex;
	align-items: center;
	gap: var(--space-within-3);
	flex-wrap: wrap;
}

.train-set-picker .select-input {
	min-width: 200px;
}

.train-stage {
	display: grid;
	grid-template-columns: minmax(280px, 440px) minmax(0, 1fr);
	gap: var(--space-section-3);
	align-items: start;
}

.train-board-wrap {
	display: grid;
	gap: var(--space-within-3);
}

.train-turn-flag {
	font-weight: var(--font-weight-600);
	color: var(--ink-muted);
	text-align: center;
}

/* #349: game replay under the drill board; display:flex would beat [hidden]. */
.train-replay,
.finder-examples,
.explorer-controls {
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
}

.train-replay[hidden] {
	display: none;
}

.train-replay-note {
	margin: 0;
	color: var(--ink-muted);
	font-size: var(--font-size-0-85);
	text-align: center;
}

/* Chessground sizes its board to a multiple of 8px inside the host, so the
   frame lives on the board itself rather than on the host. */
.training-board {
	aspect-ratio: 1 / 1;
	width: 100%;
}

.training-board cg-board {
	border-radius: 10px;
	box-shadow: var(--shadow-soft);
}

.training-board.cg-wrap {
	aspect-ratio: 1 / 1;
}

/* #301 step 1: topic list. */
.train-topic-list {
	display: grid;
	gap: var(--space-section-1);
}

.train-topic-list {
	margin-bottom: var(--space-section-1);
}

.train-topic-group h3 {
	margin: 0 0 var(--space-within-3);
	font-size: var(--font-size-0-95);
	color: var(--ink-muted);
}

.train-topic-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
	gap: var(--space-group-1);
}

.train-topic {
	display: grid;
	align-content: start;
	gap: var(--space-within-1);
	padding: var(--space-group-2) var(--space-group-3);
	border: 1px solid var(--line);
	border-radius: 14px;
	background: var(--panel-strong);
	color: var(--ink);
	font: inherit;
	text-align: left;
	cursor: pointer;
	transition:
		border-color 160ms ease,
		background-color 160ms ease;
}

.train-topic:hover,
.train-topic:focus-visible {
	border-color: var(--focus-border);
	background: var(--surface-selected);
}

.train-topic-name {
	font-size: var(--font-size-1-1);
	font-weight: var(--font-weight-600);
}

.train-topic-hint {
	color: var(--ink-muted);
	font-size: var(--font-size-0-86);
	line-height: var(--line-height-1-4);
}

.train-topic-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--space-within-3);
	margin-top: var(--space-within-1);
	color: var(--secondary);
	font-size: var(--font-size-0-82);
	font-weight: var(--font-weight-600);
}

.train-topic-badge {
	padding: var(--space-2) var(--space-within-3);
	border-radius: 999px;
	background: var(--accent-soft);
	color: var(--ink);
}

/* #354: weakness lessons home, above the topic list. */
.weakness-list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
	gap: var(--space-group-1);
	margin: 0;
	padding: 0;
	list-style: none;
}

/* Subgrid rows line up the meters and buttons across a row of cards. */
.weakness-card {
	display: grid;
	grid-row: span 3;
	grid-template-rows: subgrid;
	gap: var(--space-within-4);
	padding: var(--space-group-2) var(--space-group-3);
	border: 1px solid var(--line);
	border-radius: 14px;
	background: var(--panel-strong);
}

.weakness-card h3,
.weakness-card p {
	margin: 0;
}

.weakness-card-text {
	display: grid;
	align-content: start;
	gap: var(--space-within-1);
}

.weakness-card .weakness-meter {
	display: grid;
	align-content: start;
	justify-items: start;
	gap: var(--space-within-1);
	padding-top: var(--space-within-4);
	border-top: 1px solid var(--line-soft);
	font-size: var(--font-size-0-82);
}

.weakness-meter-label {
	padding: var(--space-2) var(--space-within-3);
	border-radius: 999px;
	background: var(--surface-ink-wash);
	color: var(--ink);
	font-weight: var(--font-weight-600);
}

.weakness-meter[data-state="better"] .weakness-meter-label {
	background: var(--secondary-soft);
	color: var(--secondary);
}

.weakness-meter[data-state="worse"] .weakness-meter-label {
	background: var(--danger-wash);
	color: var(--danger);
}

.weakness-meter-pass {
	color: var(--ink-muted);
}

.weakness-rescan-status.is-error {
	color: var(--danger);
}

.weakness-actions {
	display: flex;
	gap: var(--space-within-3);
}

/* #301 step 2: one topic. */
.train-drill-head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--space-group-1) var(--space-group-3);
	margin-bottom: var(--space-group-3);
}

.train-drill-title h2 {
	margin: 0;
}

.feedback-grid a {
	color: var(--secondary);
}

.train-side {
	display: grid;
	gap: var(--space-group-3);
	align-content: start;
}

.train-clock {
	font-size: var(--font-size-2-6);
	font-weight: var(--font-weight-700);
	font-variant-numeric: tabular-nums;
	font-family: var(--font-mono-clock);
	color: var(--secondary);
	letter-spacing: 0.02em;
}

.train-progress {
	margin: var(--space-within-1) 0 0;
	color: var(--ink-muted);
	font-size: 0.9rem;
}

/* #301: two lines are reserved so a longer status never pushes the button. */
.train-status {
	margin: 0;
	min-height: calc(2em * var(--line-height-1-5));
	line-height: var(--line-height-1-5);
}

.train-feedback {
	display: grid;
	align-content: start;
	min-height: 220px;
	gap: var(--space-group-1);
	padding: var(--space-group-3);
	border-radius: 14px;
	background: var(--panel-strong);
	border: 1px solid var(--line);
}

.feedback-placeholder {
	margin: 0;
	color: var(--ink-muted);
	line-height: var(--line-height-1-5);
}

.feedback-verdict {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	font-size: var(--font-size-1-1);
	font-weight: var(--font-weight-700);
}

.feedback-time {
	font-variant-numeric: tabular-nums;
	color: var(--ink-muted);
	font-weight: var(--font-weight-600);
}

.verdict-good {
	color: var(--secondary);
}

.verdict-bad {
	color: var(--danger);
}

.verdict-neutral {
	color: var(--ink-muted);
}

.feedback-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: var(--space-within-4) var(--space-group-3);
	margin: 0;
}

.feedback-grid dt {
	font-size: var(--font-size-0-72);
	text-transform: uppercase;
	letter-spacing: var(--letter-spacing-0-08);
	color: var(--ink-muted);
}

.feedback-grid dd {
	margin: 0;
	font-weight: var(--font-weight-600);
}

.train-controls {
	display: flex;
	gap: var(--space-within-4);
}

.train-controls .action-button {
	min-width: 168px;
}

/* #355: the drill's controls wrap so the Test bot picker fits beside Stop on a phone. */
.train-drill .train-controls {
	flex-wrap: wrap;
}

.train-bot {
	display: flex;
	align-self: center;
	align-items: center;
	gap: var(--space-within-4);
	color: var(--ink-muted);
	font-size: var(--font-size-0-85);
}

.train-bot[hidden] {
	display: none;
}

.train-bonus {
	margin-left: var(--space-within-4);
	padding: var(--space-within-1) var(--space-within-4);
	border-radius: 999px;
	background: var(--secondary-soft);
	font-size: var(--font-size-0-72);
}

.train-stat-cards {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: var(--space-group-1);
	margin-bottom: var(--space-group-3);
}

.train-stat-card {
	display: grid;
	gap: var(--space-within-1);
	padding: var(--space-group-2);
	border-radius: 12px;
	background: var(--secondary-soft);
	text-align: center;
}

.train-stat-card .stat-value {
	font-size: 1.6rem;
	font-weight: var(--font-weight-700);
	color: var(--secondary);
	font-variant-numeric: tabular-nums;
}

.train-stat-card .stat-label {
	font-size: var(--font-size-0-72);
	text-transform: uppercase;
	letter-spacing: var(--letter-spacing-0-06);
	color: var(--ink-muted);
}

.train-stats-subhead {
	margin: var(--space-group-3) 0 var(--space-within-3);
	font-size: var(--font-size-0-95);
}

.train-stats-table {
	width: 100%;
	border-collapse: collapse;
	font-size: var(--font-size-0-85);
}

.train-stats-table th,
.train-stats-table td {
	text-align: left;
	padding: var(--space-within-2) var(--space-within-3);
	border-bottom: 1px solid var(--line);
	font-variant-numeric: tabular-nums;
}

.train-stats-table th {
	font-size: var(--font-size-0-72);
	text-transform: uppercase;
	letter-spacing: var(--letter-spacing-0-06);
	color: var(--ink-muted);
}

/* Generate-set form (Train tab) */
.train-generate {
	display: grid;
	gap: var(--space-within-4);
	padding: var(--space-group-2) var(--space-group-3);
	margin: var(--space-within-1) 0 var(--space-group-1);
	border-radius: 14px;
	background: var(--accent-soft);
	border: 1px solid var(--line);
}

.train-generate-fields {
	display: flex;
	flex-wrap: wrap;
	align-items: end;
	gap: var(--space-within-3) var(--space-group-2);
}

.train-generate-fields .field-label {
	margin-bottom: var(--space-2);
}

.train-generate #gen-user {
	min-width: 160px;
}

.train-generate #gen-target,
.train-generate #gen-max-games {
	width: 92px;
}

.train-generate-fields .run-buttons {
	margin-left: auto;
}

.train-generate-details {
	margin-top: var(--space-group-1);
}

.train-generate-details .train-generate {
	margin: 0 var(--space-section-1) var(--space-section-1);
}

.train-generate-status.is-error {
	color: var(--danger);
}

.train-diagnosis {
	padding: var(--space-group-1) var(--space-group-2);
	border-radius: 12px;
	background: var(--accent-soft);
	border: 1px solid var(--accent-soft);
	color: var(--ink);
	font-size: var(--font-size-0-95);
	line-height: var(--line-height-1-5);
}

/* ===== Visualize drill ===== */
.feedback-note {
	margin: 0;
	padding-top: var(--space-within-3);
	border-top: 1px solid var(--line);
	line-height: var(--line-height-1-5);
}

.vis-level-box {
	display: grid;
	justify-items: end;
	gap: var(--space-within-1);
}

.vis-level {
	font-size: var(--font-size-1-2);
	font-weight: var(--font-weight-700);
	color: var(--secondary);
}

.vis-level-detail,
.vis-streak {
	font-size: var(--font-size-0-85);
	color: var(--ink-muted);
}

.vis-moves {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-within-2);
	min-height: var(--space-section-4);
}

.vis-move {
	padding: var(--space-within-1) var(--space-within-3);
	border-radius: 8px;
	background: var(--panel-strong);
	border: 1px solid var(--line);
	font-family: var(--font-mono-clock);
	font-weight: var(--font-weight-600);
	font-variant-numeric: tabular-nums;
}

.vis-question {
	margin: 0;
	font-size: var(--font-size-1-1);
	font-weight: var(--font-weight-700);
	color: var(--ink);
}

.vis-answer-row {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: var(--space-within-3);
}

.vis-square-input {
	width: 5em;
}

.vis-feedback {
	padding: var(--space-group-1);
	border-radius: 14px;
	background: var(--panel-strong);
	border: 1px solid var(--line);
	font-weight: var(--font-weight-600);
}

.vis-feedback.is-good {
	border-left: 3px solid var(--secondary);
	color: var(--secondary);
}

.vis-feedback.is-bad {
	border-left: 3px solid var(--danger);
	color: var(--danger);
}

@media (max-width: 720px) {
	.vis-level-box {
		justify-items: start;
	}
}

@media (max-width: 860px) {
	.train-grid,
	.train-stage {
		grid-template-columns: minmax(0, 1fr);
	}
	.train-board-wrap,
	.training-board {
		max-width: 440px;
	}
	/* Phone: clock and action share one row so the verdict stays on screen.
	   Drill only: the visualization panel reuses .train-side with no clock. */
	.train-drill .train-side {
		grid-template-columns: auto minmax(0, 1fr);
		align-items: center;
	}
	.train-drill .train-controls {
		grid-row: 1;
		grid-column: 2;
		justify-content: end;
	}
	.train-drill .train-status,
	.train-drill .train-feedback {
		grid-column: 1 / -1;
	}
	.train-generate-fields .run-buttons {
		margin-left: 0;
	}
}

/* #273: below 720px the flat label/input run wrapped mid-pair. One column keeps
   every label above its own input and gives "Generate set" its own row; the
   status pills take the full column instead of shrinking to their content.
   720px (not 860px) keeps the inclusive 860px layout unchanged. */
@media (max-width: 720px) {
	.train-generate-fields {
		display: grid;
		grid-template-columns: minmax(0, 1fr);
	}
	.train-generate-fields .run-buttons {
		justify-self: start;
	}
	.status-pill {
		flex-basis: 100%;
	}
}

/* Status strip (#14): three engine/lichess/chessbase pills pinned at the top
   of .page-shell. Pill dots reuse the source-chip tone classes (ok / degraded /
   failed / unchecked). */
/* #315: next-game assignment card above the primary nav (flat, per #246). */
.assignment-card {
	/* No bottom margin: .workflow-nav (inline-flex) brings its own top margin. */
	padding: var(--space-group-2) var(--space-group-4);
	border: 1px solid var(--line);
	border-radius: 16px;
	background: var(--panel);
}

.assignment-card[hidden] {
	display: none;
}

.assignment-rule {
	margin: 0 0 var(--space-within-2);
	font-size: var(--font-size-1-1);
	font-weight: var(--font-weight-600);
	line-height: var(--line-height-1-4);
}

.assignment-meta {
	margin: 0 0 var(--space-within-4);
	font-size: var(--font-size-0-85);
	color: var(--ink-muted);
}

.assignment-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--space-within-4);
}

.assignment-status {
	font-size: var(--font-size-0-85);
}

.status-strip {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-within-4);
	align-items: flex-start;
	margin-bottom: var(--space-group-3);
}

.status-pill {
	border: 1px solid var(--line);
	border-radius: 16px;
	background: var(--panel);
	box-shadow: var(--shadow-soft);
	overflow: hidden;
}

.status-pill-head {
	display: flex;
	align-items: center;
	gap: var(--space-within-4);
	padding: var(--space-within-4) var(--space-group-2);
	background: transparent;
	border: none;
	cursor: pointer;
	font: inherit;
	color: var(--ink);
	width: 100%;
}

.status-pill-head:hover,
.status-pill-head:focus-visible {
	background: rgba(29, 42, 40, 0.05);
	outline: none;
}

.status-pill-dot {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	flex: 0 0 auto;
	background: var(--ink-muted);
	box-shadow: 0 0 0 5px var(--status-ring-neutral);
}

.status-pill-ok .status-pill-dot {
	background: var(--secondary);
	box-shadow: 0 0 0 5px var(--status-ring-ok);
}

.status-pill-degraded .status-pill-dot {
	background: var(--gold);
	box-shadow: 0 0 0 5px var(--status-ring-caution);
}

.status-pill-failed .status-pill-dot {
	background: var(--danger);
	box-shadow: 0 0 0 5px var(--status-ring-error);
}

.status-pill-name {
	font-weight: var(--font-weight-600);
}

.status-pill-status {
	font-size: var(--font-size-0-78);
	color: var(--ink-muted);
}

.status-pill-caret {
	font-size: var(--font-size-0-72);
	color: var(--ink-muted);
	margin-left: var(--space-2);
}

.status-pill-detail {
	display: flex;
	flex-direction: column;
	gap: var(--space-within-3);
	padding: var(--space-within-1) var(--space-group-2) var(--space-group-2);
	border-top: 1px solid var(--line);
	font-size: var(--font-size-0-82);
}

.status-pill-line {
	display: flex;
	align-items: baseline;
	gap: var(--space-within-3);
	min-width: 0;
}

.status-pill-key {
	color: var(--ink-muted);
	flex: 0 0 auto;
	min-width: 64px;
}

.status-pill-val {
	word-break: break-word;
	min-width: 0;
}

.status-pill-val code,
code.status-pill-val {
	font-size: var(--font-size-0-78);
}

.status-pill-muted {
	color: var(--ink-muted);
}

.status-pill-reason {
	color: var(--danger);
	word-break: break-word;
}

.status-pill-actions {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-within-3);
	margin-top: var(--space-2);
}

.status-strip-error {
	display: flex;
	align-items: center;
	gap: var(--space-within-4);
	flex-wrap: wrap;
	padding: var(--space-within-3) var(--space-group-2);
	border-radius: 16px;
	border: 1px solid var(--line);
	background: rgba(156, 58, 44, 0.08);
	color: var(--danger);
	font-size: var(--font-size-0-82);
}

/* Source health panel (#31) */
.source-health-panel {
	grid-column: 1 / -1;
}

.source-health-chips {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: var(--space-group-2);
	margin: var(--space-group-2) 0;
}

.source-chip {
	display: flex;
	align-items: flex-start;
	gap: var(--space-group-1);
	padding: var(--space-group-2) var(--space-group-3);
	border-radius: 16px;
	border: 1px solid var(--line);
	background: var(--surface-ink-subtle);
}

.source-chip-dot {
	margin-top: var(--space-within-2);
	width: 10px;
	height: 10px;
	border-radius: 50%;
	flex: 0 0 auto;
	background: var(--ink-muted);
	box-shadow: 0 0 0 6px var(--status-ring-neutral);
}

.source-chip-ok .source-chip-dot {
	background: var(--secondary);
	box-shadow: 0 0 0 6px var(--status-ring-ok);
}

.source-chip-degraded .source-chip-dot {
	background: var(--gold);
	box-shadow: 0 0 0 6px var(--status-ring-caution);
}

.source-chip-failed .source-chip-dot {
	background: var(--danger);
	box-shadow: 0 0 0 6px var(--status-ring-error);
}

.source-chip-body {
	display: flex;
	flex-direction: column;
	gap: var(--space-within-1);
	min-width: 0;
}

.source-chip-head {
	display: flex;
	align-items: baseline;
	gap: var(--space-within-3);
	flex-wrap: wrap;
}

.source-chip-name {
	font-weight: var(--font-weight-600);
}

.source-chip-status {
	font-size: var(--font-size-0-78);
	color: var(--ink-muted);
}

.source-chip-latency {
	font-size: var(--font-size-0-78);
	color: var(--ink-muted);
}

.source-chip-reason {
	font-size: var(--font-size-0-82);
	color: var(--danger);
	word-break: break-word;
}

/* Clickable ChessBase result rows (#1) */
.chessbase-row.is-loadable {
	cursor: pointer;
}

.chessbase-row.is-loadable:hover,
.chessbase-row.is-loadable:focus-visible {
	background: var(--accent-soft);
	outline: none;
}

.chessbase-row.is-selected {
	background: var(--secondary-soft);
}

.chessbase-moves-cell {
	white-space: nowrap;
}

.chessbase-moves-note {
	display: inline-block;
	margin-right: var(--space-within-3);
	color: var(--ink-muted);
	font-size: var(--font-size-0-82);
}

.chessbase-moves-ready {
	color: var(--secondary);
	font-weight: var(--font-weight-600);
}

.chessbase-rows-hint {
	margin-top: var(--space-within-3);
	font-size: var(--font-size-0-82);
	color: var(--ink-muted);
}

.chessbase-replay-hint {
	display: inline-block;
	margin-left: var(--space-within-3);
	font-size: 0.76rem;
	font-style: italic;
	color: var(--ink-muted);
}

.chessbase-load-game[disabled] {
	opacity: 0.5;
	cursor: not-allowed;
}

.chessbase-detail {
	margin-top: var(--space-group-3);
}

.chessbase-detail-card {
	padding: var(--space-group-3) var(--space-group-4);
	border-radius: 16px;
	border: 1px solid var(--line);
	background: var(--panel-strong);
}

.chessbase-detail-moves {
	margin-top: var(--space-within-4);
	font-family: var(--font-mono-moves);
	font-size: var(--font-size-0-86);
	line-height: 1.6;
	word-break: break-word;
}

/* REQ-04 (#15): ChessBase login trigger + in-page modal. */
.source-health-actions {
	margin-top: var(--space-group-2);
	display: flex;
	gap: var(--space-within-4);
}

.login-modal {
	position: fixed;
	inset: 0;
	z-index: 40;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: var(--space-section-3);
}

.login-modal-backdrop {
	position: absolute;
	inset: 0;
	background: var(--scrim);
}

.login-modal-card {
	position: relative;
	z-index: 1;
	width: min(440px, 100%);
	padding: 26px var(--space-section-4);
	border-radius: var(--radius);
	border: 1px solid var(--line-strong);
	background: var(--panel-strong);
	box-shadow: var(--shadow);
}

.login-modal-card h2 {
	margin: var(--space-within-1) 0 var(--space-within-4);
}

.login-modal-actions {
	margin-top: var(--space-section-2);
	display: flex;
	gap: var(--space-group-1);
}

#chessbase-login-status {
	min-height: 1.2em;
	margin-top: var(--space-within-2);
	color: var(--accent);
}

/* #316: single-game review result, one block per game phase. */
.review-result {
	display: grid;
	gap: var(--space-group-2);
}

.review-phase {
	padding: var(--space-group-1) var(--space-group-3);
	border: 1px solid var(--line);
	border-radius: 16px;
	background: var(--panel);
}

.review-phase h3 {
	margin: 0 0 var(--space-within-2);
	font-size: var(--font-size-1-1);
}

.review-summary {
	margin: 0;
	font-weight: var(--font-weight-600);
}

.review-mistakes {
	margin: var(--space-within-3) 0 0;
	padding-left: var(--space-section-1);
	font-size: var(--font-size-0-85);
	line-height: var(--line-height-1-5);
}

.review-mistakes a {
	color: var(--secondary);
	font-weight: var(--font-weight-600);
}

.review-tags {
	color: var(--ink-muted);
}

/* ===== Opening Explorer: line finder + interactive board ===== */
.finder-form {
	display: grid;
	gap: var(--space-within-3);
}

.finder-label {
	font-weight: var(--font-weight-600);
}

.finder-bubble {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: var(--space-within-4);
	align-items: end;
	padding: var(--space-within-4);
	border: 1px solid var(--line);
	border-radius: 18px;
	background: var(--surface-field);
}

.finder-bubble textarea {
	min-height: 72px;
	border: none;
	background: transparent;
	box-shadow: none;
	transform: none;
	padding: var(--space-within-3);
}

.finder-bubble:focus-within {
	border-color: var(--focus-border);
	box-shadow: var(--ring-focus);
}

.finder-side {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--space-within-3);
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
}

.finder-side legend {
	float: left;
	margin-right: var(--space-within-3);
	padding: 0;
}

.finder-side-option {
	position: relative;
	cursor: pointer;
}

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

.finder-side-pill {
	display: inline-block;
	border: 1px solid var(--line);
	border-radius: 999px;
	padding: var(--space-within-2) var(--space-group-1);
	background: var(--surface-inset);
	color: var(--ink-muted);
	transition:
		background 160ms ease,
		color 160ms ease;
}

.finder-side-option:hover .finder-side-pill {
	color: var(--ink);
}

.finder-side-option input:checked + .finder-side-pill {
	border-color: var(--focus-border);
	background: var(--accent-soft);
	color: var(--ink);
	font-weight: var(--font-weight-600);
}

.finder-side-option input:focus-visible + .finder-side-pill {
	box-shadow: var(--ring-focus);
}

.finder-examples {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-within-3);
}

.finder-chip {
	appearance: none;
	cursor: pointer;
	border: 1px solid var(--line);
	border-radius: 999px;
	padding: var(--space-within-2) var(--space-group-1);
	background: var(--surface-inset);
	color: var(--ink-muted);
	font-size: var(--font-size-0-85);
	transition:
		background 160ms ease,
		color 160ms ease;
}

.finder-chip:hover,
.finder-chip:focus-visible {
	background: var(--accent-soft);
	color: var(--ink);
}

.finder-output {
	display: grid;
	gap: var(--space-within-4);
	margin-top: var(--space-group-3);
}

.finder-output[hidden],
.finder-output progress[hidden] {
	display: none;
}

.finder-status {
	margin: 0;
	font-weight: var(--font-weight-600);
}

.finder-notes {
	margin: 0;
	padding-left: var(--space-group-4);
	color: var(--ink-muted);
	font-size: var(--font-size-0-86);
}

.finder-results {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
	gap: var(--space-group-1);
}

.finder-card {
	display: grid;
	gap: var(--space-within-3);
	align-content: start;
	padding: var(--space-group-2);
	border: 1px solid var(--line-soft);
	border-radius: 16px;
	background: var(--surface-card-gradient);
}

.finder-line {
	margin: 0;
	font-family: var(--font-mono-moves);
	font-size: var(--font-size-0-95);
	line-height: var(--line-height-1-4);
}

.finder-line strong {
	color: var(--accent);
}

.finder-opening {
	margin: 0;
	color: var(--ink-muted);
	font-size: var(--font-size-0-85);
}

.finder-badges {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-within-2);
}

.finder-badge {
	padding: var(--space-2) var(--space-within-3);
	border-radius: 999px;
	background: var(--surface-ink-wash);
	font-size: var(--font-size-0-78);
	font-weight: var(--font-weight-600);
}

.finder-badge-accent {
	background: var(--accent-soft);
	color: var(--accent);
}

.finder-badge-secondary {
	background: var(--secondary-soft);
	color: var(--secondary);
}

.finder-why {
	margin: 0;
	padding-left: var(--space-group-3);
	display: grid;
	gap: var(--space-within-1);
	font-size: var(--font-size-0-86);
	line-height: var(--line-height-1-4);
}

.finder-actions {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-within-3);
}

.study-list {
	list-style: none;
	margin: var(--space-group-1) 0 0;
	padding: 0;
	display: grid;
	gap: var(--space-within-3);
}

.study-item {
	appearance: none;
	cursor: pointer;
	width: 100%;
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: baseline;
	gap: var(--space-within-3);
	padding: var(--space-within-4) var(--space-group-1);
	border: 1px solid var(--line-soft);
	border-radius: 12px;
	background: var(--surface-inset);
	color: var(--ink);
	text-align: left;
	transition: background 160ms ease;
}

.study-item:hover,
.study-item:focus-visible,
.study-item.is-active {
	background: var(--accent-soft);
}

.study-item-name {
	font-weight: var(--font-weight-600);
}

.study-item-meta {
	color: var(--ink-muted);
	font-size: var(--font-size-0-85);
}

.study-view {
	display: grid;
	gap: var(--space-group-1);
	margin-top: var(--space-group-3);
}

.study-view[hidden] {
	display: none;
}

.study-view-head {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: center;
	gap: var(--space-within-4);
}

.study-view-head h3 {
	margin: 0;
}

.study-chapter-title {
	margin: 0;
	color: var(--accent);
	font-size: var(--font-size-0-95);
	font-weight: var(--font-weight-600);
	line-height: var(--line-height-1-4);
}

a.ghost-button {
	text-decoration: none;
}

#study-status:empty,
#study-lichess-status:empty {
	display: none;
}

#study-status,
#study-lichess-status {
	margin-top: var(--space-within-4);
}

#study-status.is-error,
#study-lichess-status.is-error {
	color: var(--danger);
}

/* "Save to studies": inline menu under a finder card or the board line. */
.explorer-save {
	display: grid;
	gap: var(--space-within-3);
	justify-items: start;
}

.save-menu-slot {
	width: 100%;
}

.save-menu-slot:empty {
	display: none;
}

.save-menu {
	display: grid;
	gap: var(--space-within-3);
	width: 100%;
	padding: var(--space-within-4) var(--space-group-1);
	border: 1px solid var(--line-soft);
	border-radius: 12px;
	background: var(--surface-inset);
}

/* The Studies panel's chapter edit form reuses the menu and starts closed. */
.save-menu[hidden] {
	display: none;
}

.save-menu-row {
	display: flex;
	flex-wrap: wrap;
	align-items: end;
	gap: var(--space-within-3);
}

.save-menu-label {
	display: grid;
	gap: var(--space-within-1);
	flex: 1 1 160px;
	min-width: 0;
	color: var(--ink-muted);
	font-size: var(--font-size-0-85);
	font-weight: var(--font-weight-600);
}

.save-menu-label[hidden] {
	display: none;
}

.save-menu-label input,
.save-menu-label select {
	padding: var(--space-within-3) var(--space-within-4);
	border-radius: 10px;
	font-size: var(--font-size-0-86);
}

.save-menu-status {
	margin: 0;
	font-size: var(--font-size-0-86);
	line-height: var(--line-height-1-4);
}

.save-menu-status:empty {
	display: none;
}

.save-menu-status.is-error {
	color: var(--danger);
}

.save-menu-status a {
	color: var(--accent);
	font-weight: var(--font-weight-600);
}

.explorer-layout {
	display: grid;
	grid-template-columns: minmax(260px, 440px) minmax(0, 1fr);
	gap: var(--space-section-3);
	align-items: start;
}

/* Play a bot: the board is what you use most, so it gets the most room. Its
   column (board, eval caption and buttons) fits the screen height once
   scrolled to; Start game and Continue scroll there. */
.play-layout {
	grid-template-columns: minmax(320px, min(860px, calc(100svh - 150px))) minmax(
			300px,
			1fr
		);
}

.explorer-board-col {
	display: grid;
	gap: var(--space-within-4);
}

.play-layout .explorer-board-col {
	scroll-margin-top: var(--space-within-4);
}

.explorer-board {
	aspect-ratio: 1 / 1;
	width: 100%;
}

/* (This file loads after the chessground CSS, so it wins a tie.)
   Chessground's base CSS shifts the file letters 24px right, so the last
   one hangs off the board (and scrolls a phone page sideways). Keep them in
   their squares, at the bottom right corner. */
.cg-wrap cg-container > .files {
	left: calc(-1 * var(--space-4));
	text-align: right;
}

.explorer-board cg-board {
	border-radius: 10px;
	box-shadow: var(--shadow-soft);
}

.explorer-controls {
	display: flex;
	gap: var(--space-within-3);
	justify-content: center;
	align-items: center;
	flex-wrap: wrap;
}

.explorer-controls .small-button {
	min-width: 44px;
}

.explorer-play {
	min-width: 84px;
}

/* Inside .stack-form, whose bare spans are uppercase field captions. */
.explorer-controls .explorer-counter {
	color: var(--ink-muted);
	font-size: var(--font-size-0-85);
	font-variant-numeric: tabular-nums;
	text-transform: none;
	letter-spacing: normal;
}

/* The shown move under the Play board (js/play.js renderNav): a fixed width,
   so the step buttons keep their place while the text changes. */
.explorer-controls .play-nav-counter {
	min-width: 12ch;
	text-align: left;
}

/* Comment for the move just played, coloured by its role in the line. */
.explorer-comment {
	padding: var(--space-within-4) var(--space-group-1);
	border: 1px solid var(--line-soft);
	border-left-width: 4px;
	border-radius: 12px;
	background: var(--surface-inset);
	font-size: var(--font-size-0-95);
	line-height: var(--line-height-1-4);
	animation: comment-in 220ms ease;
}

.explorer-comment[hidden] {
	display: none;
}

.explorer-comment p {
	margin: 0;
}

.explorer-comment .explorer-comment-actions {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-within-2);
	margin-top: var(--space-within-3);
}

.explorer-comment .explorer-comment-move {
	margin-bottom: var(--space-within-1);
	font-family: var(--font-mono-moves);
	font-weight: var(--font-weight-700);
}

.explorer-comment.tone-idea {
	border-color: var(--secondary-soft);
	border-left-color: var(--secondary);
}

.explorer-comment.tone-trap {
	border-color: var(--danger-wash);
	border-left-color: var(--danger);
}

.explorer-comment.tone-punish {
	border-color: var(--secondary-soft);
	border-left-color: var(--secondary);
	background: var(--secondary-wash);
}

@keyframes comment-in {
	from {
		opacity: 0;
		transform: translateY(4px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

.explorer-info-col {
	display: grid;
	gap: var(--space-within-4);
	min-width: 0;
}

.explorer-opening {
	margin: 0;
	font-family: var(--font-display);
	font-size: var(--font-size-1-2);
	font-weight: var(--font-weight-600);
}

.explorer-line {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-within-1);
	font-family: var(--font-mono-moves);
	font-size: var(--font-size-0-86);
}

.explorer-line-empty {
	color: var(--ink-muted);
	font-family: var(--font-body);
}

.explorer-line-move {
	appearance: none;
	cursor: pointer;
	border: 1px solid transparent;
	border-radius: 8px;
	padding: var(--space-2) var(--space-within-2);
	background: transparent;
	color: var(--ink);
}

.explorer-line-move:hover {
	background: var(--surface-ink-wash);
}

.explorer-line-move.is-current {
	background: var(--accent-soft);
	border-color: var(--focus-border);
}

/* Moves still to come stay visible but quiet. */
.explorer-line-move.is-future {
	color: var(--ink-muted);
	opacity: 0.7;
}

.explorer-line .explorer-line-number {
	align-self: center;
	margin-right: var(--space-2);
	color: var(--ink-muted);
}

.explorer-line li {
	display: flex;
}

.explorer-line-move.tone-idea {
	color: var(--secondary);
	font-weight: var(--font-weight-700);
}

.explorer-line-move.tone-trap {
	color: var(--danger);
	font-weight: var(--font-weight-700);
}

.explorer-line-move.tone-punish {
	color: var(--secondary);
	font-weight: var(--font-weight-700);
}

.explorer-line .explorer-line-glyph {
	margin-left: var(--space-2);
}

.finder-continuation {
	margin: 0;
	font-family: var(--font-mono-moves);
	font-size: var(--font-size-0-85);
	line-height: var(--line-height-1-4);
}

.finder-continuation span {
	margin-right: var(--space-within-2);
	color: var(--ink-muted);
	font-family: var(--font-body);
	font-size: var(--font-size-0-78);
	text-transform: uppercase;
	letter-spacing: var(--letter-spacing-0-06);
}

.finder-continuation-trap {
	color: var(--danger);
}

.finder-trap-idea {
	margin: 0;
	font-size: var(--font-size-0-86);
	line-height: var(--line-height-1-4);
}

.finder-trap-idea strong {
	color: var(--danger);
}

.finder-badge-danger {
	background: var(--danger-wash);
	color: var(--danger);
}

/* A study chapter's trap: the dream position beside what to play. */
.study-trap {
	display: grid;
	grid-template-columns: 168px minmax(0, 1fr);
	gap: var(--space-group-1);
	align-items: start;
	padding: var(--space-within-4);
	border: 1px solid var(--danger-line);
	border-left: 3px solid var(--danger);
	border-radius: 12px;
	background: var(--danger-wash);
}

.study-trap-board {
	aspect-ratio: 1 / 1;
	width: 100%;
}

.study-trap-board cg-board {
	border-radius: 6px;
}

.study-trap-body {
	display: grid;
	gap: var(--space-within-3);
	align-content: start;
}

.study-trap-head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--space-within-2) var(--space-within-3);
	margin: 0;
}

.study-trap-label {
	color: var(--danger);
	font-size: var(--font-size-0-78);
	font-weight: var(--font-weight-600);
	text-transform: uppercase;
	letter-spacing: var(--letter-spacing-0-06);
}

.study-trap-share {
	color: var(--ink-muted);
	font-size: var(--font-size-0-85);
}

.study-trap-text {
	margin: 0;
	font-size: var(--font-size-0-95);
	line-height: var(--line-height-1-4);
}

/* A study chapter's ideas: what each side fights for, what to avoid. */
.study-ideas {
	padding: var(--space-within-4);
	border: 1px solid var(--line-soft);
	border-radius: 12px;
	background: var(--surface-inset);
}

.study-ideas > summary {
	cursor: pointer;
	color: var(--accent);
	font-size: var(--font-size-0-78);
	font-weight: var(--font-weight-600);
	text-transform: uppercase;
	letter-spacing: var(--letter-spacing-0-06);
}

.study-ideas [data-ideas-body] {
	display: grid;
	gap: var(--space-within-3);
	margin-top: var(--space-within-3);
}

.study-ideas-summary {
	margin: 0;
	font-size: var(--font-size-0-95);
	line-height: var(--line-height-1-4);
}

.study-ideas-list h5 {
	margin: 0 0 var(--space-within-1);
	font-size: var(--font-size-0-85);
	font-weight: var(--font-weight-600);
}

.study-ideas-list.is-avoid h5 {
	color: var(--danger);
}

.study-ideas-list ul {
	margin: 0;
	padding-left: var(--space-group-3);
	display: grid;
	gap: var(--space-within-1);
	font-size: var(--font-size-0-86);
	line-height: var(--line-height-1-4);
}

.study-ideas-note {
	margin: 0;
	color: var(--ink-muted);
	font-size: var(--font-size-0-78);
}

.study-ideas-note.is-error {
	color: var(--danger);
}

.study-trap-none {
	margin: 0;
	color: var(--ink-muted);
	font-size: var(--font-size-0-86);
}

@media (max-width: 520px) {
	.study-trap {
		grid-template-columns: minmax(0, 1fr);
	}

	.study-trap-board {
		width: min(240px, 100%);
	}
}

.explorer-moves-frame {
	max-height: 420px;
	overflow-y: auto;
	border: 1px solid var(--line);
	border-radius: 14px;
	background: var(--surface-inset);
}

.explorer-moves {
	width: 100%;
	border-collapse: collapse;
	font-size: var(--font-size-0-86);
}

.explorer-moves th {
	position: sticky;
	top: 0;
	padding: var(--space-within-3) var(--space-within-4);
	background: var(--panel-strong);
	border-bottom: 1px solid var(--line-soft);
	text-align: left;
	color: var(--ink-muted);
	font-size: var(--font-size-0-74);
	text-transform: uppercase;
	letter-spacing: var(--letter-spacing-0-06);
}

.explorer-moves td {
	padding: var(--space-within-1) var(--space-within-4);
	border-bottom: 1px solid var(--line-soft);
	vertical-align: middle;
}

.explorer-move-row.is-in-line td {
	background: var(--accent-soft);
}

.explorer-moves tr:last-child td {
	border-bottom: none;
}

.explorer-moves td:last-child {
	width: 40%;
}

.explorer-move-button {
	appearance: none;
	cursor: pointer;
	width: 100%;
	border: none;
	border-radius: 8px;
	padding: var(--space-within-1) var(--space-within-3);
	background: transparent;
	color: var(--ink);
	text-align: left;
	font-family: var(--font-mono-moves);
	font-weight: var(--font-weight-700);
}

.explorer-move-button:hover,
.explorer-move-button:focus-visible {
	background: var(--accent-soft);
}

.explorer-move-games {
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}

.explorer-moves .explorer-move-share {
	margin-left: var(--space-within-3);
	color: var(--ink-muted);
}

.wdl-bar {
	display: flex;
	height: 20px;
	border-radius: 6px;
	overflow: hidden;
	border: 1px solid var(--line);
	font-size: var(--font-size-0-72);
	font-weight: var(--font-weight-600);
	line-height: var(--line-height-1);
}

.wdl-bar span {
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
}

/* Inside #explorer-form, `.stack-form span` would turn the pill label into a
   small uppercase field label. */
.lichess-games-pill span {
	font-size: inherit;
	text-transform: none;
	letter-spacing: normal;
	color: var(--ink-muted);
}

/* The table sits inside .stack-form; undo its uppercase field-caption spans.
   Every span in the table is in a cell, so no `td` (keeps specificity low). */
.explorer-moves span {
	font-size: inherit;
	color: var(--ink);
	text-transform: none;
	letter-spacing: normal;
}

/* Our numbers (expected points, engine eval) next to the Lichess counts. */
.explorer-move-ours {
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}

/* The trap badge keeps its own size and tone over the table's span reset. */
.explorer-moves .finder-badge-secondary {
	font-size: var(--font-size-0-78);
	color: var(--secondary);
}

/* On a phone the share stands in for the game count, so the result bar keeps
   room next to our numbers. */
@media (max-width: 700px) {
	.explorer-moves .explorer-move-count {
		display: none;
	}

	.explorer-moves .explorer-move-share {
		margin-left: 0;
	}
}

.wdl-bar .wdl-white {
	background: var(--panel-strong);
	color: var(--ink);
}

.wdl-bar .wdl-draw {
	background: var(--bg-strong);
	color: var(--ink);
}

.wdl-bar .wdl-black {
	background: var(--ink);
	color: var(--on-accent);
}

.explorer-type-moves summary {
	cursor: pointer;
	color: var(--secondary);
	font-weight: var(--font-weight-600);
}

.explorer-type-moves label {
	margin-top: var(--space-within-3);
}

@media (max-width: 820px) {
	.explorer-layout,
	.play-layout {
		grid-template-columns: 1fr;
	}
	/* Phones: the board takes the panel's side padding too. */
	[data-workflow-view="play"] > .panel {
		padding-inline: var(--space-within-4);
	}
	.finder-bubble {
		grid-template-columns: 1fr;
	}
	.finder-bubble .action-button {
		flex: 1;
	}
}

/* #356: Learn card. The board reuses the drill's .train-stage layout. */
.learn-side {
	display: grid;
	gap: var(--space-group-3);
	min-width: 0;
}

.learn-step {
	display: grid;
	gap: var(--space-within-3);
	justify-items: start;
}

.learn-step h3,
.learn-step p {
	margin: 0;
}

.learn-step [hidden],
#learn-answer[hidden] {
	display: none;
}

#learn-answer {
	display: grid;
	gap: var(--space-group-3);
}

.learn-futures {
	display: grid;
	gap: var(--space-within-3);
	width: 100%;
}

.learn-future {
	text-align: left;
}

.learn-future-label {
	font-weight: var(--font-weight-600);
}

.learn-lens {
	border-collapse: collapse;
}

.learn-lens tr > * {
	padding: var(--space-within-1) var(--space-within-3);
	border-bottom: 1px solid var(--line);
	text-align: left;
}

.learn-rule {
	padding: var(--space-group-1);
	border-radius: 12px;
	background: var(--secondary-wash);
}

.learn-pattern a {
	color: var(--secondary);
}

.learn-pattern {
	margin: 0;
	padding-left: var(--space-group-4);
}

/* Which Lichess games count: the settings panel on the Lichess page and the
   summary pills in the Opening Explorer (js/lichess-games.js). */
.lichess-games-intro {
	margin: 0;
	max-width: 62ch;
	color: var(--ink);
}

.lichess-games-pill {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: var(--space-within-2);
	margin: 0 0 var(--space-group-2);
	padding: var(--space-within-2) var(--space-within-3);
	border: 1px solid var(--line-soft);
	border-radius: 999px;
	background: var(--secondary-wash);
	color: var(--ink-muted);
	width: fit-content;
	max-width: 100%;
}

/* The Lichess-games and opponent pills side by side, wrapping on a phone. */
.pill-row {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-within-2);
	margin: 0 0 var(--space-group-2);
}

.pill-row .lichess-games-pill {
	margin: 0;
}

.lichess-games-pill strong {
	color: var(--ink);
	font-weight: var(--font-weight-600);
}

.pill-select {
	width: auto;
	min-width: 0;
	max-width: 100%;
	padding: 0 var(--space-within-2);
	border: 0;
	background: transparent;
	color: var(--ink);
	font: inherit;
	font-weight: var(--font-weight-600);
	cursor: pointer;
}

.pill-select:focus {
	transform: none;
	box-shadow: none;
}

.pill-select:focus-visible {
	border-radius: 6px;
	box-shadow: var(--ring-focus);
}

.lichess-games-pill .notice-link {
	color: var(--secondary);
	font-weight: var(--font-weight-600);
}

.lichess-games-status {
	margin: 0;
	min-height: 1.4em;
	font-weight: var(--font-weight-600);
	color: var(--ink-muted);
}

.lichess-games-status[data-tone="ok"] {
	color: var(--secondary);
}

.lichess-games-status[data-tone="error"] {
	color: var(--danger);
}

[data-local-only][hidden] {
	display: none;
}

/* Line finder: the expected-points tree under each result (js/line-finder.js)
   and the "Save all as a study" row under the results. */
.finder-save-all {
	display: flex;
	justify-content: flex-end;
	flex-direction: column;
	align-items: flex-end;
	gap: var(--space-within-2);
}

.finder-save-all[hidden] {
	display: none;
}

.finder-tree {
	border-top: 1px solid var(--line-soft);
	padding-top: var(--space-within-3);
}

.finder-tree > summary {
	cursor: pointer;
	font-weight: var(--font-weight-600);
	color: var(--secondary);
	display: flex;
	align-items: baseline;
	gap: var(--space-within-2);
}

.finder-tree-note {
	margin: var(--space-within-2) 0;
	color: var(--ink-muted);
	max-width: 70ch;
	font-size: var(--font-size-0-86);
	line-height: var(--line-height-1-4);
}

/* display:flex drops the native disclosure triangle, so draw one. */
.finder-tree summary {
	list-style: none;
}

.finder-tree summary::-webkit-details-marker {
	display: none;
}

.finder-tree summary::before {
	content: "▸";
	color: var(--ink-muted);
	width: 1ch;
}

.finder-tree[open] > summary::before {
	content: "▾";
}

.finder-tree details[open] > summary::before {
	content: "▾";
}

.finder-tree-level {
	list-style: none;
	margin: 0;
	padding-left: var(--space-group-2);
	border-left: 1px solid var(--line-soft);
	display: grid;
	gap: var(--space-within-1);
}

.finder-tree > .finder-tree-level {
	padding-left: 0;
	border-left: 0;
}

.finder-tree-level summary,
.finder-tree-leaf {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: var(--space-within-2);
}

.finder-tree-level summary {
	cursor: pointer;
}

.finder-tree-leaf::before {
	content: "";
	width: 1ch;
}

.finder-tree-leaf,
.finder-tree-level summary {
	font-size: var(--font-size-0-86);
}

.finder-tree-move {
	appearance: none;
	border: 0;
	padding: 0;
	background: none;
	color: var(--ink);
	font-family: var(--font-mono-moves);
	font-weight: var(--font-weight-600);
	text-decoration: underline;
	text-decoration-color: var(--line);
	cursor: pointer;
}

.finder-tree-move:focus-visible {
	outline: none;
	box-shadow: var(--ring-focus);
}

.finder-tree-points {
	font-weight: var(--font-weight-600);
	font-variant-numeric: tabular-nums;
}

.finder-tree-points.is-good {
	color: var(--secondary);
}

.finder-tree-points.is-bad {
	color: var(--danger);
}

.finder-tree-points.is-even {
	color: var(--ink-muted);
}

.finder-tree-eval {
	color: var(--ink-muted);
	font-size: var(--font-size-0-85);
}

/* Play a bot (js/play.js): reuses the explorer board layout. */
.play-status {
	margin: 0;
	font-family: var(--font-display);
	font-size: var(--font-size-1-2);
	font-weight: var(--font-weight-600);
}

.play-status[data-tone="error"] {
	color: var(--danger);
}

.play-status[data-tone="done"] {
	color: var(--secondary);
}

.finder-tree-chance {
	color: var(--ink-muted);
	font-size: var(--font-size-0-85);
	font-variant-numeric: tabular-nums;
}

/* Play: the bot's clock and yours (js/play.js renderClock). */
.play-clock {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--space-within-2) var(--space-within-4);
	margin: 0;
}

.play-clock[hidden] {
	display: none;
}

.play-clock-row {
	display: inline-flex;
	align-items: baseline;
	gap: var(--space-within-2);
}

.play-clock-label,
.play-clock-extra {
	color: var(--ink-muted);
	font-size: var(--font-size-0-85);
}

.play-clock-time {
	border: 1px solid var(--line);
	border-radius: 8px;
	padding: var(--space-2) var(--space-within-2);
	font-family: var(--font-mono-moves);
	font-size: var(--font-size-1-2);
	font-variant-numeric: tabular-nums;
	color: var(--ink-muted);
}

.play-clock-row.is-running .play-clock-time {
	border-color: var(--focus-border);
	background: var(--accent-soft);
	color: var(--ink);
}

.play-clock-row.is-low .play-clock-time {
	border-color: var(--danger);
	color: var(--danger);
}

/* Think time after each move in the Play move list. */
.play-move-time {
	align-self: center;
	margin-right: var(--space-within-1);
	color: var(--ink-muted);
	font-family: var(--font-body);
	font-size: var(--font-size-0-7);
}

/* Play: "Show engine score" under the board (js/play.js renderEngine). */
.play-eval-toggle {
	justify-content: center;
	padding: 0;
}

/* Play: the settings fold; its summary names the settings when closed.
   `.stack-form span` would make both parts small caps: undo that here. */
.play-settings > summary {
	cursor: pointer;
}

.play-settings > summary::marker {
	color: var(--ink-muted);
}

.play-settings > summary > span {
	display: inline;
	margin: 0;
	text-transform: none;
	letter-spacing: normal;
}

.play-settings > summary > .play-settings-title {
	font-size: var(--font-size-0-95);
	font-weight: var(--font-weight-600);
	color: var(--secondary);
}

.play-settings > summary > .play-settings-summary {
	margin-left: var(--space-within-2);
	color: var(--ink-muted);
	font-size: var(--font-size-0-85);
}

.play-settings[open] > summary {
	margin-bottom: var(--space-within-3);
}

.play-settings[open] .play-settings-summary {
	display: none;
}

/* Play: "Why this move?" (js/play.js renderWhy), reusing the line finder's tree rows. */
.play-why {
	border-top: 1px solid var(--line-soft);
	padding-top: var(--space-within-3);
}

.play-why[hidden] {
	display: none;
}

.play-why > summary {
	cursor: pointer;
	font-weight: var(--font-weight-600);
	color: var(--secondary);
}

.play-why-list {
	border-top: 0;
	padding-top: 0;
}

.play-why-list > li.is-chosen > details > summary .finder-tree-move {
	font-weight: var(--font-weight-700);
}

.play-why-more > summary {
	cursor: pointer;
	color: var(--secondary);
	font-size: var(--font-size-0-85);
}

.play-why-tag {
	color: var(--ink-muted);
	font-size: var(--font-size-0-85);
}

/* Exercises > Calculate (js/exercises.js renderResult): reuses the Play layout. */
.exercise-result {
	display: grid;
	gap: var(--space-within-2);
	border-top: 1px solid var(--line-soft);
	padding-top: var(--space-within-3);
}

.exercise-result[hidden] {
	display: none;
}

.exercise-result p {
	margin: 0;
}

.exercise-result-title {
	font-family: var(--font-display);
	font-weight: var(--font-weight-600);
	color: var(--secondary);
}

.exercise-result a,
.exercise-analysis a {
	color: var(--secondary);
	font-weight: var(--font-weight-600);
}

.exercise-result-title[data-outcome="failed"] {
	color: var(--danger);
}

.exercise-why {
	line-height: var(--line-height-1-5);
}

.exercise-tags {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-within-2);
	margin: 0;
	padding: 0;
	list-style: none;
	color: var(--ink-muted);
	font-size: var(--font-size-0-85);
}

.exercise-tags li {
	border: 1px solid var(--line-soft);
	border-radius: 999px;
	padding: var(--space-within-1) var(--space-within-2);
}

/* Steps between the trees of the bot's moves (js/play.js whyPager). */
.play-why-pager {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--space-within-2);
	margin-bottom: var(--space-within-3);
}

/* Stockfish eval bar beside a board (js/eval-bar.js). The light fill is
   White's winning chance, drawn from White's side of the board. */
.board-with-eval {
	display: grid;
	grid-template-columns: 38px minmax(0, 1fr); /* fits "+10.5" */
	gap: var(--space-within-2);
	align-items: stretch;
}

.eval-bar {
	position: relative;
	overflow: hidden;
	outline: 1px solid #403d39; /* shows the light half against the page; takes no width */
	border-radius: 6px;
	background: #403d39;
	box-shadow: var(--shadow-soft);
}

.eval-bar-fill {
	position: absolute;
	right: 0;
	bottom: 0;
	left: 0;
	height: 50%;
	background: #f2efe9;
	transition: height 320ms ease;
}

.eval-bar.is-flipped .eval-bar-fill {
	top: 0;
	bottom: auto;
}

.eval-bar.is-loading {
	opacity: 0.7;
}

.eval-bar-text {
	position: absolute;
	right: 0;
	bottom: var(--space-4);
	left: 0;
	color: #403d39;
	font-size: var(--font-size-0-7);
	font-weight: var(--font-weight-700);
	font-variant-numeric: tabular-nums;
	text-align: center;
	white-space: nowrap;
}

.eval-bar-text.at-top {
	top: var(--space-4);
	bottom: auto;
}

.eval-bar-text.is-black {
	color: #f2efe9;
}

.eval-caption {
	margin: 0;
	color: var(--ink-muted);
	font-size: var(--font-size-0-85);
	font-variant-numeric: tabular-nums;
	text-align: center;
}

/* Play: saved games ("My games", js/play.js renderGames). */
.play-games {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: var(--space-within-3);
}

.play-game-actions .is-danger {
	border-color: var(--danger);
	background: var(--danger-wash);
	color: var(--danger);
}

.play-games-more {
	display: flex;
	justify-content: center;
}

.play-game-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-within-3);
	padding: var(--space-within-3) var(--space-group-1);
	border: 1px solid var(--line-soft);
	border-radius: 12px;
	background: var(--surface-inset);
}

.play-game-info {
	display: grid;
	gap: var(--space-within-1);
	min-width: 0;
}

.play-game-info span {
	color: var(--ink-muted);
	font-size: var(--font-size-0-86);
}

.play-game-info .play-game-result {
	color: var(--secondary);
	font-weight: var(--font-weight-600);
}

.play-game-info .play-game-result.is-open {
	color: var(--ink-muted);
}

.play-game-actions {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-within-2);
}

/* Expected-points tree as a picture (js/tree-diagram.js). */
.tree-diagram {
	display: grid;
	gap: var(--space-within-2);
	margin: var(--space-within-3) 0;
}

.tree-diagram-caption {
	margin: 0;
	color: var(--ink-muted);
	font-size: var(--font-size-0-85);
}

.tree-diagram-trail {
	font-size: var(--font-size-0-85);
}

/* Says when the board is not on the analyzed position (followBoard). */
.tree-diagram-note {
	margin: 0;
	padding: var(--space-within-3) var(--space-group-2);
	border-radius: 12px;
	background: var(--secondary-wash);
	color: var(--secondary);
	font-size: var(--font-size-0-85);
	font-weight: var(--font-weight-600);
}

.tree-diagram-frame {
	overflow-x: auto;
	padding: var(--space-within-2);
	border: 1px solid var(--line-soft);
	border-radius: 12px;
	background: var(--surface-inset);
}

/* Shrinks to fit so the start of the tree never scrolls out of view; phones scroll instead. */
.tree-diagram-frame svg {
	display: block;
	max-width: 100%;
	height: auto;
}

@media (max-width: 700px) {
	.tree-diagram-frame svg {
		max-width: none;
	}
}

.tree-diagram-edge {
	fill: none;
	stroke: var(--line-strong);
	stroke-linecap: round;
}

/* Ink marks the path you zoomed along; orange is kept for the chosen move. */
.tree-diagram-edge.is-path {
	stroke: var(--ink);
	opacity: 0.6;
}

.tree-diagram-edge.is-aside {
	opacity: 0.45;
}

.tree-diagram-node {
	cursor: pointer;
}

.tree-diagram-node rect {
	fill: #fff;
	stroke: var(--line-strong);
	stroke-width: 1;
	transition: stroke-width 120ms ease;
}

.tree-diagram-node.is-aside {
	opacity: 0.5;
}

.tree-diagram-node.is-aside:hover,
.tree-diagram-node.is-aside:focus-visible {
	opacity: 1;
}

/* The best and the worst move at a step (js/tree-diagram.js rankAmongSiblings). */
.tree-diagram-node.is-end > rect:first-of-type {
	stroke-width: 2;
}

.tree-diagram-badge rect {
	fill: var(--accent);
}

.tree-diagram-badge text {
	fill: #fff;
	font-size: var(--font-size-0-7);
	font-weight: var(--font-weight-700);
	text-anchor: middle;
}

.tree-diagram-node.is-path > rect:first-of-type,
.tree-diagram-node.is-focus > rect:first-of-type {
	stroke: var(--ink);
	stroke-width: 2.5;
	stroke-dasharray: none;
}

.tree-diagram-edge.is-chosen {
	stroke: var(--accent);
	opacity: 0.9;
}

.tree-diagram-node.is-chosen > rect:first-of-type {
	fill: #fbe9dc;
	stroke: var(--accent);
	stroke-width: 3;
}

.tree-diagram-node.is-chosen.is-aside {
	opacity: 1;
}

.tree-diagram-node:hover > rect:first-of-type,
.tree-diagram-node:focus-visible > rect:first-of-type {
	stroke-width: 2.5;
}

.tree-diagram-node:focus {
	outline: none;
}

.tree-diagram.is-zooming .tree-diagram-node.is-new {
	animation: tree-diagram-in 220ms ease-out;
}

@keyframes tree-diagram-in {
	from {
		opacity: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.tree-diagram.is-zooming .tree-diagram-node.is-new {
		animation: none;
	}
}

.tree-diagram-label {
	fill: var(--ink);
	font-family: var(--font-mono-moves);
	font-size: var(--font-size-0-78);
	font-weight: var(--font-weight-700);
}

.tree-diagram-label.is-small {
	font-size: var(--font-size-0-7);
}

.tree-diagram-node.is-chosen .tree-diagram-label {
	fill: var(--accent);
}

/* On a rank colour the chosen move's label goes back to ink, to stay readable. */
.tree-diagram-node.is-chosen.is-toned .tree-diagram-label {
	fill: var(--ink);
}

.tree-diagram-info {
	fill: var(--ink-muted);
	font-size: var(--font-size-0-7);
	font-variant-numeric: tabular-nums;
}

.tree-diagram-more {
	fill: var(--secondary);
	font-size: var(--font-size-0-86);
	font-weight: var(--font-weight-700);
}

.finder-tree-list > summary {
	cursor: pointer;
	color: var(--secondary);
	font-size: var(--font-size-0-85);
	font-weight: var(--font-weight-600);
}

/* Line finder results as a table (js/line-finder.js renderRow): click a row
   to open its reasons, actions and tree underneath. */
.finder-table-wrap {
	overflow-x: auto;
}

.finder-table {
	width: 100%;
	border-collapse: collapse;
	font-variant-numeric: tabular-nums;
}

.finder-table th {
	padding: var(--space-within-2) var(--space-within-3);
	border-bottom: 1px solid var(--line-strong);
	color: var(--ink-muted);
	font-size: var(--font-size-0-78);
	font-weight: var(--font-weight-600);
	text-align: left;
	white-space: nowrap;
}

.finder-table tr.finder-row > td {
	padding: var(--space-within-3);
	border-bottom: 1px solid var(--line-soft);
	vertical-align: top;
}

.finder-row {
	cursor: pointer;
}

.finder-row:hover,
.finder-row:focus-visible,
.finder-row[aria-expanded="true"] {
	background: var(--surface-selected);
}

.finder-row:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: -2px;
}

.finder-cell-line .finder-line,
.finder-cell-line .finder-opening {
	display: block;
}

.finder-row-toggle {
	float: left;
	margin-right: var(--space-within-2);
	color: var(--secondary);
}

.finder-row-toggle::before {
	content: "▸";
}

.finder-row[aria-expanded="true"] .finder-row-toggle::before {
	content: "▾";
}

.finder-table tr.finder-detail > td {
	padding: 0 0 var(--space-group-1);
	border-bottom: 1px solid var(--line-strong);
}

.finder-detail .finder-card {
	border-top-left-radius: 0;
	border-top-right-radius: 0;
}

.finder-tree-title {
	margin: 0;
	font-size: var(--font-size-1-1);
}

.tree-diagram-expand {
	justify-self: start;
}

.tree-diagram-dialog {
	width: 100vw;
	max-width: 100vw;
	height: 100vh;
	max-height: 100vh;
	margin: 0;
	padding: var(--space-group-3);
	border: 0;
	background: var(--panel-strong);
}

.tree-diagram-dialog::backdrop {
	background: rgba(29, 42, 40, 0.4);
}

.tree-diagram-dialog-bar {
	display: flex;
	justify-content: flex-end;
}

.tree-diagram-full .tree-diagram-frame {
	max-height: calc(100vh - 140px);
	overflow: auto;
}

/* Full screen: grow the picture to the width of the screen. */
.tree-diagram-full .tree-diagram-frame svg {
	width: 100%;
	max-width: none;
}

@media (max-width: 700px) {
	.finder-cell-wide {
		display: none;
	}
}

/* Exercises > Analysis (js/exercises.js): Stockfish's best moves, one a row. */
/* Shown only in Analysis: display would otherwise override the hidden attribute. */
.exercise-analysis:not([hidden]) {
	display: grid;
	gap: var(--space-within-2);
}

.exercise-analysis .eval-caption {
	text-align: left;
}

.exercise-lines {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: var(--space-2);
}

.exercise-line {
	appearance: none;
	width: 100%;
	text-align: left;
	cursor: pointer;
	border: 1px solid var(--line-soft);
	border-radius: 8px;
	padding: var(--space-2) var(--space-within-2);
	background: transparent;
	color: var(--ink);
	font: inherit;
	font-variant-numeric: tabular-nums;
}

.exercise-line:hover {
	background: var(--surface-ink-wash);
}

.exercise-line strong {
	margin-right: var(--space-2);
}
