: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;
}

* {
	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: "Avenir Next", "Trebuchet MS", sans-serif;
}

body::before {
	content: "";
	position: fixed;
	inset: 0;
	background-image:
		linear-gradient(rgba(29, 42, 40, 0.03) 1px, transparent 1px),
		linear-gradient(90deg, rgba(29, 42, 40, 0.03) 1px, transparent 1px);
	background-size: 32px 32px;
	pointer-events: none;
}

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

code,
pre,
.result-json,
.job-meta {
	font-family: "SFMono-Regular", Menlo, Consolas, monospace;
}

.page-shell {
	width: min(1440px, calc(100% - 32px));
	margin: 24px auto 48px;
}

.is-hidden {
	display: none !important;
}

.panel,
.job-panel,
.result-panel,
.notice-banner {
	backdrop-filter: blur(14px);
	background: var(--panel);
	border: 1px solid rgba(255, 255, 255, 0.65);
	box-shadow: var(--shadow);
}

.panel-kicker {
	margin: 0 0 10px;
	text-transform: uppercase;
	letter-spacing: 0.16em;
	font-size: 0.74rem;
}

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

h1,
h2,
.cluster-heading h3,
.disclosure-summary h3 {
	margin: 0;
	font-family: "Iowan Old Style", "Palatino Linotype", serif;
	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: 10px;
	padding: 10px 14px;
	border-radius: 999px;
	background: rgba(29, 42, 40, 0.08);
}

.health-dot {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: var(--gold);
	box-shadow: 0 0 0 6px rgba(180, 154, 73, 0.16);
}

.health-dot.ok {
	background: var(--secondary);
	box-shadow: 0 0 0 6px rgba(25, 89, 74, 0.16);
}

.health-dot.error {
	background: var(--danger);
	box-shadow: 0 0 0 6px rgba(156, 58, 44, 0.14);
}

.workflow-nav {
	margin-top: 18px;
	display: inline-flex;
	flex-wrap: wrap;
	gap: 10px;
	padding: 10px;
	border-radius: 18px;
	background: rgba(255, 250, 243, 0.74);
	border: 1px solid rgba(255, 255, 255, 0.65);
	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: 10px 16px;
	cursor: pointer;
	transition:
		background 160ms ease,
		color 160ms ease,
		transform 160ms ease,
		box-shadow 160ms ease;
}

.workflow-nav-button.active {
	background: linear-gradient(135deg, var(--accent), #de7d2f);
	color: #fff9f1;
	box-shadow: 0 14px 24px rgba(196, 93, 28, 0.18);
	border-color: rgba(196, 93, 28, 0.28);
}

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

.notice-banner {
	margin-top: 18px;
	padding: 14px 18px;
	border-radius: 18px;
	font-weight: 600;
}

.notice-banner.error {
	display: block;
	background: rgba(156, 58, 44, 0.1);
	border-color: rgba(156, 58, 44, 0.18);
	color: var(--danger);
}

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

.control-grid,
.source-grid {
	display: grid;
	gap: 24px;
}

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

.panel,
.job-panel,
.result-panel {
	border-radius: var(--radius);
	padding: 24px;
}

.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: 16px;
	margin-bottom: 18px;
}

.stack-form {
	display: grid;
	gap: 14px;
}

.form-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 16px;
}

.form-cluster {
	display: grid;
	gap: 14px;
	padding: 18px;
	border-radius: 20px;
	border: 1px solid rgba(29, 42, 40, 0.08);
	background: linear-gradient(
		180deg,
		rgba(255, 252, 247, 0.95),
		rgba(244, 237, 226, 0.78)
	);
}

.form-cluster-featured {
	padding: 22px;
	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: 6px;
}

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

.cluster-heading h3,
.disclosure-summary h3 {
	font-size: 1.1rem;
}

.cluster-heading p,
.disclosure-summary p {
	margin: 0;
	line-height: 1.5;
	font-size: 0.92rem;
}

.disclosure-card {
	border: 1px solid rgba(29, 42, 40, 0.08);
	border-radius: 22px;
	background: rgba(255, 250, 243, 0.72);
	overflow: hidden;
	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: 16px;
	padding: 18px 20px;
	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: 1;
	color: var(--secondary);
	background: rgba(25, 89, 74, 0.1);
	border: 1px solid rgba(25, 89, 74, 0.12);
}

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

.disclosure-body {
	padding: 0 18px 18px;
}

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

.stack-form label {
	display: grid;
	gap: 8px;
}

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

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

input,
textarea,
select {
	width: 100%;
	padding: 14px 15px;
	border-radius: 14px;
	border: 1px solid var(--line);
	background: rgba(255, 255, 255, 0.82);
	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: rgba(196, 93, 28, 0.5);
	box-shadow: 0 0 0 4px rgba(196, 93, 28, 0.12);
	transform: translateY(-1px);
}

.field-input-invalid,
.field-input-invalid:focus {
	border-color: rgba(156, 58, 44, 0.46);
	box-shadow: 0 0 0 4px rgba(156, 58, 44, 0.12);
}

.field-error {
	margin-top: 2px;
	font-size: 0.8rem;
	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: 12px;
}

.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: 14px;
}

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

.mode-panel {
	display: grid;
	gap: 12px;
}

.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;
}

.toggle-row {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 0 4px;
}

.toggle-row span {
	margin: 0;
	text-transform: none;
	letter-spacing: 0;
	font-size: 0.95rem;
}

.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: 14px 15px;
	background: rgba(255, 255, 255, 0.82);
}

.action-button,
.ghost-button {
	appearance: none;
	border: none;
	cursor: pointer;
	border-radius: 14px;
	padding: 14px 16px;
	transition:
		transform 160ms ease,
		box-shadow 160ms ease,
		opacity 160ms ease;
}

.action-button {
	background: linear-gradient(135deg, var(--accent), #de7d2f);
	color: #fff9f1;
	box-shadow: 0 16px 28px rgba(196, 93, 28, 0.24);
}

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

.small-button {
	padding: 10px 12px;
}

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

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

.workspace-note {
	margin: 0 0 14px;
	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: 20px;
	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: 6px;
}

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

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

.jobs-list {
	display: grid;
	gap: 10px;
	min-height: 0;
	max-height: 720px;
	overflow-y: auto;
	padding-right: 6px;
}

.job-panel .panel-heading {
	margin-bottom: 8px;
}

.job-item {
	border: 1px solid var(--line);
	background: rgba(255, 255, 255, 0.75);
	border-radius: 18px;
	padding: 14px;
	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: rgba(255, 244, 236, 0.92);
}

.job-item-failed {
	border-color: rgba(156, 58, 44, 0.18);
	background: rgba(255, 246, 244, 0.86);
}

.job-title,
.job-meta {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.job-title {
	font-weight: 700;
}

.job-summary {
	margin-top: 10px;
	font-size: 0.86rem;
	line-height: 1.45;
	color: var(--ink-muted);
	text-align: left;
}

.job-meta {
	margin-top: 8px;
	font-size: 0.78rem;
	color: var(--ink-muted);
}

.status-chip {
	padding: 5px 9px;
	border-radius: 999px;
	font-size: 0.72rem;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	background: rgba(29, 42, 40, 0.08);
	color: var(--ink-muted);
}

.status-chip.running,
.status-chip.queued {
	background: rgba(180, 154, 73, 0.14);
	color: #806b1d;
}

.status-chip.cancelling {
	background: rgba(180, 154, 73, 0.2);
	color: #806b1d;
}

.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: 10px;
}

.metric-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
	gap: 14px;
	margin-bottom: 18px;
}

.metric-card {
	padding: 16px;
	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: 10px;
	font-size: 1.55rem;
	font-weight: 700;
}

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

.metric-label {
	font-size: 0.8rem;
	letter-spacing: 0.07em;
	text-transform: uppercase;
}

.progress-grid {
	margin-top: 16px;
}

/* 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: 10px;
	margin-bottom: 18px;
}

.job-progress-bar {
	-webkit-appearance: none;
	appearance: none;
	width: 100%;
	height: 10px;
	border: 1px solid var(--line);
	border-radius: 999px;
	overflow: hidden;
	background: rgba(29, 42, 40, 0.08);
}

.job-progress-bar::-webkit-progress-bar {
	background: rgba(29, 42, 40, 0.08);
	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,
		rgba(85, 103, 101, 0.34) 0,
		rgba(85, 103, 101, 0.34) 8px,
		rgba(85, 103, 101, 0.16) 8px,
		rgba(85, 103, 101, 0.16) 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: 0.82rem;
	color: var(--ink-muted);
	font-variant-numeric: tabular-nums;
}

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

.result-actions {
	margin-top: 16px;
	max-width: 280px;
}

.result-headline {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 20px;
}

.result-headline p {
	margin: 6px 0 0;
}

.status-copy {
	margin-top: 8px;
}

.result-context {
	margin-bottom: 18px;
	padding: 18px;
	border-radius: 20px;
	border: 1px solid var(--line);
	background: linear-gradient(
		180deg,
		rgba(255, 252, 247, 0.95),
		rgba(244, 237, 226, 0.78)
	);
}

.result-context h3 {
	margin: 0;
	font-size: 1.2rem;
	font-family: "Iowan Old Style", "Palatino Linotype", serif;
	letter-spacing: -0.02em;
}

.result-context .status-copy {
	margin-top: 6px;
}

.workflow-comparison {
	margin-bottom: 18px;
	padding: 18px;
	border-radius: 20px;
	border: 1px solid var(--line);
	background: linear-gradient(
		180deg,
		rgba(255, 252, 247, 0.95),
		rgba(244, 237, 226, 0.78)
	);
}

.workflow-comparison h3 {
	margin: 0;
	font-size: 1.2rem;
	font-family: "Iowan Old Style", "Palatino Linotype", serif;
	letter-spacing: -0.02em;
}

.workflow-recommendation {
	margin-top: 6px;
	margin-bottom: 12px;
}

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

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

/* Counter-intuitive verdict (REQ-006 / #49). */
.verdict-card {
	margin-bottom: 18px;
	padding: 18px;
	border-radius: 20px;
	border: 1px solid var(--line);
	background: linear-gradient(
		180deg,
		rgba(255, 252, 247, 0.95),
		rgba(244, 237, 226, 0.78)
	);
}

.verdict-headline {
	margin: 6px 0 0;
	font-size: 1.5rem;
	line-height: 1.25;
	font-family: "Iowan Old Style", "Palatino Linotype", serif;
	letter-spacing: -0.02em;
}

.verdict-narrative {
	margin-top: 12px;
}

.verdict-flags {
	list-style: none;
	margin: 14px 0 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.verdict-flag-chip {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	max-width: 100%;
	padding: 8px 12px;
	border-radius: 999px;
	border: 1px solid rgba(156, 58, 44, 0.32);
	background: rgba(156, 58, 44, 0.1);
	color: var(--danger);
	font-size: 0.85rem;
}

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

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

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

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

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

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

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

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

.verdict-card .verdict-table {
	margin-top: 14px;
}

.verdict-games {
	margin-top: 14px;
}

.verdict-games-label {
	margin: 0 0 8px;
	font-size: 0.78rem;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--ink-muted);
}

.verdict-games-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.verdict-game-chip {
	display: inline-flex;
	align-items: center;
	padding: 6px 12px;
	border-radius: 999px;
	border: 1px solid var(--line-strong);
	background: rgba(255, 255, 255, 0.6);
	color: var(--ink-muted);
	font: inherit;
	font-size: 0.82rem;
	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: rgba(196, 93, 28, 0.5);
	background: rgba(255, 244, 236, 0.92);
	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: 24px;
	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: 24px;
	backdrop-filter: blur(14px);
	background: var(--panel);
	border: 1px solid rgba(255, 255, 255, 0.65);
	box-shadow: var(--shadow);
	min-height: 200px;
}

.deep-dive-head {
	display: flex;
	align-items: start;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 16px;
}

.deep-dive-head h2 {
	margin: 4px 0 0;
}

.deep-dive-meta {
	margin: 0 0 14px;
	font-size: 0.82rem;
	line-height: 1.5;
	color: var(--ink-muted);
}

.deep-dive-status {
	display: grid;
	gap: 10px;
	justify-items: start;
	padding: 8px 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: 12px;
	max-height: 640px;
	overflow-y: auto;
}

.deep-dive-ply {
	border: 1px solid var(--line);
	border-radius: 16px;
	padding: 12px 14px;
	background: rgba(255, 255, 255, 0.72);
	display: grid;
	gap: 8px;
}

.deep-dive-ply-head {
	display: flex;
	align-items: baseline;
	gap: 10px;
	justify-content: space-between;
}

.deep-dive-ply-index {
	font-size: 0.72rem;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--ink-muted);
}

.deep-dive-ply-move {
	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: rgba(29, 42, 40, 0.03);
}

.deep-dive-position-label {
	font-size: 0.74rem;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--ink-muted);
}

.deep-dive-deltas {
	display: flex;
	gap: 18px;
	margin: 0;
}

.deep-dive-deltas div {
	display: grid;
	gap: 2px;
}

.deep-dive-deltas dt {
	font-size: 0.7rem;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--ink-muted);
}

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

.deep-dive-badges {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.deep-dive-badge {
	padding: 3px 9px;
	border-radius: 999px;
	font-size: 0.7rem;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	font-weight: 600;
}

.deep-dive-badge--only-move {
	background: rgba(180, 154, 73, 0.18);
	color: #806b1d;
}

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

.maia-fields {
	margin-top: 12px;
	padding: 14px 16px;
	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: 18px;
}

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

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

.table-frame {
	overflow-x: auto;
	border: 1px solid var(--line);
	border-radius: 18px;
	background: rgba(255, 255, 255, 0.72);
}

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

.data-table th,
.data-table td {
	padding: 12px 14px;
	border-bottom: 1px solid rgba(29, 42, 40, 0.08);
	text-align: left;
	vertical-align: top;
}

.data-table th {
	font-size: 0.78rem;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	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: 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: 12px;
	}

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

	.disclosure-summary {
		padding: 16px;
	}

	h1 {
		font-size: 2.6rem;
	}
}

.opening-board-row {
	display: grid;
	grid-template-columns: minmax(220px, 300px) 1fr;
	gap: 18px;
	align-items: center;
	margin-top: 14px;
	padding: 14px;
	border-radius: 18px;
	background: rgba(29, 42, 40, 0.04);
	border: 1px solid rgba(29, 42, 40, 0.08);
}

.opening-board-wrap {
	aspect-ratio: 1 / 1;
	width: 100%;
	max-width: 300px;
	border-radius: 8px;
	overflow: hidden;
	background: #4b3a2a;
}

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

.opening-board-meta {
	display: grid;
	gap: 6px;
}

#opening-board-status.is-invalid {
	color: var(--danger);
	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;
}

label > span:has(+ .tooltip-trigger) {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.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: 10px 12px;
	border-radius: 12px;
	background: var(--ink);
	color: var(--panel-strong);
	box-shadow: var(--shadow-soft);
	font-size: 0.85rem;
	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 4px;
	border-radius: 4px;
}

.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: 20px;
}

.train-set-picker {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
}

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

.train-stage {
	display: grid;
	grid-template-columns: minmax(280px, 420px) 1fr;
	gap: 24px;
	align-items: start;
}

.train-board-wrap {
	display: grid;
	gap: 8px;
}

.training-board {
	aspect-ratio: 1 / 1;
	width: 100%;
	border-radius: 10px;
	overflow: hidden;
	background: #4b3a2a;
	box-shadow: var(--shadow-soft);
}

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

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

.train-side {
	display: grid;
	gap: 16px;
	align-content: start;
}

.train-clock {
	font-size: 2.6rem;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
	color: var(--secondary);
	letter-spacing: 0.02em;
}

.train-progress {
	color: var(--ink-muted);
	font-size: 0.9rem;
}

.train-feedback {
	display: grid;
	gap: 12px;
	padding: 16px;
	border-radius: 14px;
	background: var(--panel-strong);
	border: 1px solid var(--line);
}

.feedback-verdict {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	font-size: 1.1rem;
	font-weight: 700;
}

.feedback-time {
	font-variant-numeric: tabular-nums;
	color: var(--ink-muted);
	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: 10px 16px;
	margin: 0;
}

.feedback-grid dt {
	font-size: 0.72rem;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--ink-muted);
}

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

.train-controls {
	display: flex;
	gap: 10px;
}

.train-stat-cards {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 12px;
	margin-bottom: 16px;
}

.train-stat-card {
	display: grid;
	gap: 4px;
	padding: 14px;
	border-radius: 12px;
	background: var(--secondary-soft);
	text-align: center;
}

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

.train-stat-card .stat-label {
	font-size: 0.72rem;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--ink-muted);
}

.train-stats-subhead {
	margin: 16px 0 8px;
	font-size: 0.95rem;
}

.train-stats-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.85rem;
}

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

.train-stats-table th {
	font-size: 0.72rem;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--ink-muted);
}

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

.train-generate-fields {
	display: flex;
	flex-wrap: wrap;
	align-items: end;
	gap: 8px 14px;
}

.train-generate-fields .field-label {
	margin-bottom: 2px;
}

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

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

.train-generate-fields .action-button {
	margin-left: auto;
}

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

.train-diagnosis {
	padding: 12px 14px;
	border-radius: 12px;
	background: var(--panel-strong);
	border-left: 3px solid var(--accent);
	color: var(--ink);
	font-size: 0.95rem;
	line-height: 1.5;
}

@media (max-width: 860px) {
	.train-stage {
		grid-template-columns: 1fr;
	}
	.train-board-wrap {
		max-width: 420px;
	}
	.train-generate-fields .action-button {
		margin-left: 0;
	}
}

/* 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). */
.status-strip {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	align-items: flex-start;
	margin-bottom: 16px;
}

.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: 10px;
	padding: 10px 14px;
	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 rgba(85, 103, 101, 0.12);
}

.status-pill-ok .status-pill-dot {
	background: var(--secondary);
	box-shadow: 0 0 0 5px rgba(25, 89, 74, 0.16);
}

.status-pill-degraded .status-pill-dot {
	background: var(--gold);
	box-shadow: 0 0 0 5px rgba(180, 154, 73, 0.18);
}

.status-pill-failed .status-pill-dot {
	background: var(--danger);
	box-shadow: 0 0 0 5px rgba(156, 58, 44, 0.16);
}

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

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

.status-pill-caret {
	font-size: 0.72rem;
	color: var(--ink-muted);
	margin-left: 2px;
}

.status-pill-detail {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 4px 14px 14px;
	border-top: 1px solid var(--line);
	font-size: 0.82rem;
}

.status-pill-line {
	display: flex;
	align-items: baseline;
	gap: 8px;
	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: 0.78rem;
}

.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: 8px;
	margin-top: 2px;
}

.status-strip-error {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
	padding: 8px 14px;
	border-radius: 16px;
	border: 1px solid var(--line);
	background: rgba(156, 58, 44, 0.08);
	color: var(--danger);
	font-size: 0.82rem;
}

/* 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: 14px;
	margin: 14px 0;
}

.source-chip {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	padding: 14px 16px;
	border-radius: 16px;
	border: 1px solid var(--line);
	background: rgba(29, 42, 40, 0.04);
}

.source-chip-dot {
	margin-top: 6px;
	width: 10px;
	height: 10px;
	border-radius: 50%;
	flex: 0 0 auto;
	background: var(--ink-muted);
	box-shadow: 0 0 0 6px rgba(85, 103, 101, 0.12);
}

.source-chip-ok .source-chip-dot {
	background: var(--secondary);
	box-shadow: 0 0 0 6px rgba(25, 89, 74, 0.16);
}

.source-chip-degraded .source-chip-dot {
	background: var(--gold);
	box-shadow: 0 0 0 6px rgba(180, 154, 73, 0.18);
}

.source-chip-failed .source-chip-dot {
	background: var(--danger);
	box-shadow: 0 0 0 6px rgba(156, 58, 44, 0.16);
}

.source-chip-body {
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 0;
}

.source-chip-head {
	display: flex;
	align-items: baseline;
	gap: 8px;
	flex-wrap: wrap;
}

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

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

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

.source-chip-reason {
	font-size: 0.82rem;
	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: 8px;
	color: var(--ink-muted);
	font-size: 0.82rem;
}

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

.chessbase-rows-hint {
	margin-top: 8px;
	font-size: 0.82rem;
	color: var(--ink-muted);
}

.chessbase-replay-hint {
	display: inline-block;
	margin-left: 8px;
	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: 16px;
}

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

.chessbase-detail-moves {
	margin-top: 10px;
	font-family: "SFMono-Regular", ui-monospace, Menlo, monospace;
	font-size: 0.86rem;
	line-height: 1.6;
	word-break: break-word;
}

/* REQ-04 (#15): ChessBase login trigger + in-page modal. */
.source-health-actions {
	margin-top: 14px;
	display: flex;
	gap: 10px;
}

.login-modal {
	position: fixed;
	inset: 0;
	z-index: 40;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
}

.login-modal-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(29, 42, 40, 0.42);
	backdrop-filter: blur(4px);
}

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

.login-modal-card h2 {
	margin: 4px 0 10px;
}

.login-modal-actions {
	margin-top: 22px;
	display: flex;
	gap: 12px;
}

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