/* hullqin-recorder 通用样式 — Apple 设计语言 (中性石墨 + Apple blue + 柔和分层阴影 + 半透明材质) */

:root {
	/* 中性 — Apple 灰阶 */
	--bg: #f5f5f7; /* 页面底 (Apple signature gray) */
	--bg-subtle: #e8e8ed; /* 次级填充: hover/表头/chip/内嵌槽 */
	--surface: #ffffff; /* 卡片/modal/导航 */
	--border: #d2d2d7; /* hairline */
	--border-strong: #c6c6cc;
	--fg: #1d1d1f; /* Apple near-black */
	--fg-muted: #6e6e73; /* 次级文字 (~5:1 on white) */
	--fg-muted-strong: #58585d; /* 深一级次级文字: 在 --primary-soft 蓝底卡上仍 ≥4.5:1 (6.1:1) */
	--fg-subtle: #86868b; /* 仅装饰性/占位小字 */

	/* 品牌 — Apple blue */
	--primary: #0071e3;
	--primary-hover: #0077ed;
	--primary-soft: #e5f0fb; /* 选中/active 软底 */
	--primary-strong: #075bb2; /* 软底上的 pill/badge 文字: 对 --primary-soft 5.8:1 (AA); 同 --fg-muted-strong 模式 */
	--primary-fg: #ffffff;
	/* --accent 是被 .empty-inline a / aria-current / status-* 等引用的别名, 必须定义 */
	--accent: #0071e3;

	/* 状态 — Apple system colors (text-safe variants) */
	--danger: #d70015;
	--danger-hover: #a80010;
	--danger-soft: #fcebeb;
	--warning: #b25000;
	--warning-soft: #fff3e0;
	--success: #1a7f37;
	--success-soft: #e6f4ea;
	--success-strong: #146c2e; /* 软底上的 pill/badge 文字: 对 --success-soft 5.7:1 (AA) */

	/* 圆角/阴影/动效 */
	--radius-sm: 8px;
	--radius: 12px;
	--radius-lg: 18px;
	--shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.04);
	--shadow: 0 2px 8px rgba(0, 0, 0, 0.05), 0 12px 32px rgba(0, 0, 0, 0.08);
	--shadow-active: 0 0 0 4px rgba(0, 113, 227, 0.25); /* focus ring */
	--ease-fluid: cubic-bezier(0.32, 0.72, 0, 1); /* Apple sheet curve */
	--dur-fast: 120ms;
	--dur-med: 250ms;
	--mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* H5: dark mode 手动切换支持。
   优先级:用户选择 > 系统偏好 > light 默认。
   选择后写入 localStorage('theme'),可选 'light' | 'dark' | 'system'。 */
:root[data-theme="dark"] {
	--bg: #111113;
	--bg-subtle: #2a2a2e;
	--surface: #1c1c1e;
	--border: #38383a;
	--border-strong: #48484c;
	--fg: #f5f5f7;
	--fg-muted: #a1a1a6;
	--fg-muted-strong: #a1a1a6;
	/* v2026-09-07 (ux-fix): 次级文字必须在 --surface 深底上保持 ≥4.5:1 对比度,
	   11-12px 小字 (事件 #N 角标 / 引导步数) 才读得清。Apple 系统灰 #a1a1a6
	   在 #1c1c1e 上约 6.5:1, 取代原 slate #94a3b8 (~5.0) 的同一条规则。 */
	--fg-subtle: #8e8e93;
	--primary: #0a84ff;
	--primary-hover: #409cff;
	--primary-soft: #0a2e4f;
	--primary-strong: #4da3ff; /* 软底 pill 文字: 对 --primary-soft 5.3:1 (AA) */
	--primary-fg: #ffffff;
	--accent: #0a84ff;
	--danger: #ff453a;
	--danger-hover: #ff6961;
	--danger-soft: #3a1214;
	--warning: #ffd60a;
	--warning-soft: #33290a;
	--success: #30d158;
	--success-soft: #103319;
	--success-strong: #30d158; /* 软底 pill 文字: 对 --success-soft 6.9:1 (AA) */
	--shadow-active: 0 0 0 4px rgba(10, 132, 255, 0.32);
}
@media (prefers-color-scheme: dark) {
	:root:not([data-theme]) {
		--bg: #111113;
		--bg-subtle: #2a2a2e;
		--surface: #1c1c1e;
		--border: #38383a;
		--border-strong: #48484c;
		--fg: #f5f5f7;
		--fg-muted: #a1a1a6;
		--fg-muted-strong: #a1a1a6;
		/* v2026-09-07 (ux-fix): 同上 — 次级文字在深底上保持 ≥4.5:1 (Apple 灰 #a1a1a6)。 */
		--fg-subtle: #8e8e93;
		--primary: #0a84ff;
		--primary-hover: #409cff;
		--primary-soft: #0a2e4f;
		--primary-strong: #4da3ff; /* 软底 pill 文字: 对 --primary-soft 5.3:1 (AA) */
		--primary-fg: #ffffff;
		--accent: #0a84ff;
		--danger: #ff453a;
		--danger-hover: #ff6961;
		--danger-soft: #3a1214;
		--warning: #ffd60a;
		--warning-soft: #33290a;
		--success: #30d158;
		--success-soft: #103319;
		--success-strong: #30d158; /* 软底 pill 文字: 对 --success-soft 6.9:1 (AA) */
		--shadow-active: 0 0 0 4px rgba(10, 132, 255, 0.32);
	}
}

* {
	box-sizing: border-box;
}

/* [hidden] global safety net: HTML's hidden attr is supposed to equal
   display:none, but our author rules for .filter-toggle / .filter-form /
   .create-form set display: inline-flex/block which override the UA
   stylesheet and leak controls that should be hidden for anonymous users.
   See commit 1f121e6 "fix(ui): hide anonymous history filters". */
[hidden] {
	display: none !important;
}

body {
	margin: 0;
	padding: 0;
	background: var(--bg);
	color: var(--fg);
	font:
		15px/1.55 -apple-system,
		BlinkMacSystemFont,
		"Helvetica Neue",
		"PingFang SC",
		"Hiragino Sans GB",
		"Microsoft YaHei",
		sans-serif;
	min-height: 100vh;
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

/* v2026-09-07 (ux-fix): vendored static/css/main.css (replay/room/debug 三页加载)
   自带 body { color: rgba(0,0,0,.9) }, 同特异性但加载更晚, 压过上面的 var(--fg) —
   暗色主题下所有继承前景色的文字变黑字落深底 (实测对比度 1.44)。
   html body 提一级特异性夺回主题前景色; 亮色主题视觉不变 (#111827 ≈ rgba(0,0,0,.9))。 */
html body {
	color: var(--fg);
}

header {
	border-bottom: 1px solid var(--border);
	background: var(--surface);
	padding: 12px 24px;
	display: flex;
	align-items: baseline;
	gap: 16px;
}
/* Apple 半透明导航材质: 仅在支持 backdrop-filter 时启用, 否则回落实心 --surface。 */
@supports (backdrop-filter: blur(1px)) {
	header {
		background: color-mix(in srgb, var(--surface) 72%, transparent);
		backdrop-filter: blur(20px) saturate(180%);
		-webkit-backdrop-filter: blur(20px) saturate(180%);
	}
}
@media (prefers-reduced-transparency: reduce) {
	header {
		background: var(--surface);
		backdrop-filter: none;
		-webkit-backdrop-filter: none;
	}
}

header h1 {
	font-size: 19px;
	margin: 0;
	font-weight: 600;
	letter-spacing: -0.02em;
}

header .tag {
	font-size: 11px;
	color: var(--fg-muted);
	font-family: var(--mono);
}

main {
	padding: 24px;
	max-width: 1280px;
	margin: 0 auto;
}

section {
	margin-bottom: 32px;
}

section > h2 {
	font-size: 16px;
	font-weight: 600;
	letter-spacing: -0.01em;
	color: var(--fg);
	margin: 0 0 12px;
	border-bottom: 1px solid var(--border);
	padding-bottom: 8px;
}

.empty {
	padding: 32px;
	text-align: center;
	color: var(--fg-muted);
	background: var(--bg-subtle);
	border-radius: var(--radius);
}

/* 单行 inline 提示:用于 0 条折叠场景(P2-4 活跃录制),保留 muted 色但去掉虚线框。
   <p> 标签天然 block,无需 display;padding 压到 10px 0,跟同行 section 节奏一致。 */
.empty-inline {
	margin: 0;
	padding: 10px 0;
	font-size: 13px;
	color: var(--fg-muted);
}
.empty-inline a {
	color: var(--accent);
	text-decoration: none;
}
.empty-inline a:hover {
	text-decoration: underline;
}

/* form */
form {
	display: flex;
	gap: 8px;
	align-items: center;
}

input[type="text"] {
	flex: 1;
	padding: 6px 14px;
	font-size: 14px;
	font-family: var(--mono);
	border: 1px solid var(--border);
	border-radius: 999px;
	background: var(--surface);
	color: var(--fg);
	transition:
		box-shadow var(--dur-fast) var(--ease-fluid),
		border-color var(--dur-fast) var(--ease-fluid);
}

input[type="text"]:focus {
	outline: none;
	border-color: var(--border);
	box-shadow: var(--shadow-active);
}

button {
	padding: 6px 16px;
	font-size: 13px;
	font-weight: 500;
	border: 1px solid var(--border-strong);
	border-radius: 999px;
	background: var(--surface);
	color: var(--fg);
	cursor: pointer;
	transition:
		background-color var(--dur-fast) var(--ease-fluid),
		color var(--dur-fast) var(--ease-fluid),
		border-color var(--dur-fast) var(--ease-fluid),
		box-shadow var(--dur-fast) var(--ease-fluid),
		transform var(--dur-fast) var(--ease-fluid);
	white-space: nowrap;
}

button:hover {
	background: var(--bg-subtle);
}

button:active {
	transform: scale(0.97);
}

button.primary {
	background: var(--primary);
	color: var(--primary-fg);
	border-color: var(--primary);
}

button.primary:hover {
	background: var(--primary-hover);
	border-color: var(--primary-hover);
}

button.danger {
	background: var(--danger);
	color: white;
	border-color: var(--danger);
}

button.danger:hover {
	background: var(--danger-hover);
	border-color: var(--danger-hover);
}

button:disabled {
	color: var(--fg-subtle);
	opacity: 0.4;
	cursor: not-allowed;
}

/* card */
.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 14px 18px;
	box-shadow: var(--shadow-sm);
	margin-bottom: 8px;
	transition:
		box-shadow var(--dur-fast) var(--ease-fluid),
		transform var(--dur-fast) var(--ease-fluid),
		background-color var(--dur-fast) var(--ease-fluid);
}
.card:hover {
	box-shadow: var(--shadow);
	transform: translateY(-1px);
}
/* B17: card 选中视觉反馈 —— 用 :has 检测 input[data-action="select"]:checked,
   现代浏览器(Safari 15.4+, Chrome 105+, Firefox 121+)原生支持;
   兜底用 JS toggle .selected class(@supports not 块) */
.card:has(input[data-action="select"]:checked) {
	background: var(--primary-soft);
	border-color: var(--primary);
}
.card:has(input[data-action="select"]:checked) .row {
	/* 选中时高亮一点 */
}
@supports not selector(:has(*)) {
	.card.selected {
		background: var(--primary-soft);
		border-color: var(--primary);
	}
}

.card .row {
	display: flex;
	gap: 16px;
	align-items: center;
}

.card .meta {
	display: flex;
	gap: 16px;
	font-family: var(--mono);
	font-size: 12px;
	color: var(--fg-muted);
	flex-wrap: wrap;
}

.card .meta b {
	color: var(--fg);
	font-weight: 600;
}

.card .players {
	font-size: 13px;
}

.card .players span {
	display: inline-block;
	padding: 2px 10px;
	background: var(--bg-subtle);
	border-radius: 999px;
	margin-right: 4px;
	margin-bottom: 4px;
	font-size: 12px;
}

.status-dot {
	display: inline-block;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	vertical-align: middle;
	margin-right: 4px;
}

.status-recording {
	background: var(--success);
}
.status-incomplete {
	background: var(--danger);
}
.status-ended {
	background: var(--fg-muted);
}
.status-connecting {
	background: var(--warning);
}

/* replay page */
.replay-shell {
	display: grid;
	grid-template-rows: auto minmax(0, 1fr) auto;
	height: 100vh;
	overflow: hidden;
}

.replay-summary {
	padding: 8px 16px;
	border-bottom: 1px solid var(--border);
	background: var(--surface);
	font-size: 12px;
	font-family: var(--mono);
	display: flex;
	gap: 16px;
	align-items: center;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.replay-summary-current {
	flex: 1;
	color: var(--fg-muted);
	overflow: hidden;
	text-overflow: ellipsis;
}

.replay-summary-right {
	margin-left: auto;
	display: flex;
	gap: 16px;
	align-items: center;
}

.replay-status-label {
	color: var(--fg-muted);
	font-weight: 600;
}

.replay-summary-action {
	padding: 2px 10px;
	font-size: 12px;
}

.replay-lang-toggle {
	margin-right: 6px;
	font-size: 11px;
	font-weight: 600;
}

.replay-export-browser {
	padding: 2px 8px;
	font-size: 11px;
}

.replay-export-status {
	min-height: 1.25rem;
	color: var(--fg-muted);
	font-size: 12px;
}

.replay-export-status.is-error {
	color: var(--danger);
}

.replay-back {
	font-size: 12px;
	color: var(--fg-muted);
	text-decoration: none;
}
.replay-back:hover {
	text-decoration: underline;
}

.replay-main {
	display: grid;
	grid-template-columns: 1fr 320px;
	min-height: 0;
	overflow: hidden;
}

.replay-iframe-wrap {
	position: relative;
	border-top: 1px solid var(--border);
	border-right: 1px solid var(--border);
	background: white;
	min-height: 0;
	cursor: not-allowed;
	overflow: hidden;
}

/* 回放态：iframe 内部所有按钮失活，避免误操作 */
.replay-iframe-wrap iframe {
	width: 100%;
	height: 100%;
	border: 0;
	display: block;
	pointer-events: none;
	user-select: none;
}

/* iframe 加载前的占位：避免出现“中间空白” */
.replay-iframe-loading {
	position: absolute;
	inset: 0;
	z-index: 2;
	display: flex;
	flex-direction: column;
	gap: 12px;
	align-items: center;
	justify-content: center;
	background: var(--surface);
	color: var(--fg-muted);
	font-size: 13px;
	pointer-events: none;
	transition: opacity 0.25s ease;
}
.replay-iframe-loading.hidden {
	opacity: 0;
	pointer-events: none;
}
.replay-iframe-loading .spinner {
	width: 28px;
	height: 28px;
	border: 3px solid var(--border);
	border-top-color: var(--primary);
	border-radius: 50%;
	animation: replay-spin 0.9s linear infinite;
}
@keyframes replay-spin {
	to {
		transform: rotate(360deg);
	}
}

/* L4: 角落标识 — 移动端单行省略 */
.replay-iframe-wrap::after {
	/* 默认中文; html lang=en 时被 :lang(en) 规则覆盖 */
	content: "回放中 · 操作已禁用";
	position: absolute;
	top: 8px;
	right: 8px;
	z-index: 1;
	max-width: calc(100% - 16px);
	padding: 4px 10px;
	font-size: 11px;
	color: var(--fg-muted);
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 12px;
	pointer-events: none;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.replay-sidebar {
	border-top: 1px solid var(--border);
	background: var(--surface);
	display: flex;
	flex-direction: column;
	min-height: 0;
	overflow: hidden;
}

.replay-sidebar-header {
	padding: 8px 12px;
	border-bottom: 1px solid var(--border);
	font-size: 12px;
	display: flex;
	justify-content: space-between;
	align-items: center;
	flex-shrink: 0;
}

.replay-sidebar-title {
	font-weight: 600;
}

.replay-sidebar-toggle {
	font-size: 11px;
	color: var(--fg-muted);
	display: inline-flex;
	align-items: center;
	gap: 4px;
	cursor: pointer;
}

.replay-sidebar-list {
	flex: 1;
	overflow-y: auto;
	padding: 4px 0;
}

.replay-sidebar-empty {
	padding: 20px;
	text-align: center;
	color: var(--fg-muted);
	font-size: 12px;
}

.replay-sidebar-item {
	padding: 6px 12px;
	border-left: 3px solid transparent;
	font-size: 13px;
	line-height: 1.5;
	cursor: pointer;
	display: flex;
	gap: 8px;
}

.replay-sidebar-item:hover {
	background: var(--bg-subtle);
}

.replay-sidebar-item.active {
	border-left-color: var(--primary);
	background: var(--primary-soft);
	font-weight: 500;
}

.replay-sidebar-item.is-system {
	color: var(--fg-muted);
	font-style: italic;
}

.replay-sidebar-idx {
	font-family: var(--mono);
	font-size: 11px;
	color: var(--fg-muted);
	flex-shrink: 0;
	min-width: 38px;
}

.replay-sidebar-text {
	flex: 1;
	word-break: break-word;
}

.replay-controls {
	padding: 12px 16px;
	border-top: 1px solid var(--border);
	background: var(--surface);
	display: flex;
	gap: 8px;
	align-items: center;
}

.replay-buttons {
	display: flex;
	gap: 6px;
	align-items: center;
	flex-shrink: 0;
}

.replay-step {
	min-width: 36px;
	min-height: 32px;
	padding: 4px 10px;
	white-space: nowrap;
}

.replay-controls .progress {
	flex: 1;
	min-width: 160px;
	display: flex;
	gap: 8px;
	align-items: center;
	font-family: var(--mono);
	font-size: 12px;
}

.replay-controls input[type="range"] {
	flex: 1;
}

.replay-controls .speed {
	display: flex;
	gap: 4px;
}

.replay-controls .speed button {
	padding: 4px 8px;
	font-size: 12px;
	font-family: var(--mono);
	white-space: nowrap;
}

.replay-controls .speed button.active {
	background: var(--primary);
	color: white;
	border-color: var(--primary);
}

/* 移动端 / 窄屏适配 */
@media (max-width: 768px) {
	/* shell 改纵向流式布局，按内容撑开高度 */
	.replay-shell {
		grid-template-rows: auto auto auto;
	}
	/* 主区域：iframe 固定高度（16:9），侧边栏在下方 */
	.replay-main {
		grid-template-columns: 1fr;
		grid-template-rows: auto auto;
	}
	.replay-iframe-wrap {
		border-right: 0;
		aspect-ratio: 4 / 3;
		width: 100%;
	}
	.replay-sidebar {
		max-height: 40vh;
		border-top: 1px solid var(--border);
	}

	/* 控件栏：纵向布局
     行 1：操作按钮（4 步 + 倍速组）
     行 2：进度条 */
	.replay-controls {
		flex-direction: column;
		align-items: stretch;
		gap: 6px;
		padding: 8px 10px;
	}
	.replay-buttons {
		width: 100%;
		flex-wrap: nowrap;
		justify-content: space-between;
	}
	.replay-controls .progress {
		flex: none;
		width: 100%;
		min-width: 0;
	}

	/* 控件按钮紧凑但仍易点 */
	.replay-step,
	#btn-play {
		min-width: 40px;
		min-height: 38px;
		padding: 4px 6px;
	}
	.replay-controls .speed button {
		padding: 4px 5px;
		font-size: 11px;
	}
	.replay-controls .speed {
		gap: 2px;
	}
	.replay-sidebar-item {
		padding: 4px 8px;
		font-size: 12px;
	}
}

.badge-warn {
	display: inline-block;
	margin-top: 8px;
	padding: 3px 10px;
	background: var(--warning-soft);
	color: var(--warning);
	border: 1px solid color-mix(in srgb, var(--warning) 40%, transparent);
	border-radius: var(--radius-sm);
	font-size: 11px;
	font-weight: 600;
}

@media (prefers-color-scheme: dark) {
	.replay-sidebar-item:hover {
		background: var(--bg-subtle);
	}
	.replay-sidebar-item.active {
		border-left-color: var(--primary);
		background: var(--primary-soft);
	}
}

/* ===== 通用容器 ===== */
.container {
	width: 100%;
	max-width: 1200px;
	margin: 0 auto;
	padding: 16px;
}
@media (min-width: 640px) {
	.container {
		padding: 24px 32px;
	}
}

.page-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 16px;
	background: var(--surface);
	border-bottom: 1px solid var(--border);
	position: sticky;
	top: 0;
	z-index: 10;
}
@supports (backdrop-filter: blur(1px)) {
	.page-header {
		background: color-mix(in srgb, var(--surface) 72%, transparent);
		backdrop-filter: blur(20px) saturate(180%);
		-webkit-backdrop-filter: blur(20px) saturate(180%);
	}
}
@media (prefers-reduced-transparency: reduce) {
	.page-header {
		background: var(--surface);
		backdrop-filter: none;
		-webkit-backdrop-filter: none;
	}
}
.page-header h1 {
	font-size: 17px;
	font-weight: 600;
	letter-spacing: -0.02em;
	margin: 0;
}
.page-header a.app-brand {
	text-decoration: none;
	color: inherit;
}
.page-header a.app-brand:hover {
	opacity: 0.85;
}
.page-header .header-nav-link {
	font-size: 14px;
	color: var(--fg);
	text-decoration: none;
	padding: 6px 10px;
	border-radius: 6px;
	white-space: nowrap;
}
.page-header .header-nav-link:hover {
	background: var(--bg-subtle);
}
.page-header .header-nav-link[aria-current="page"] {
	font-weight: 600;
	color: var(--accent, var(--link, var(--fg)));
	background: var(--bg-subtle);
}
.page-header .spacer {
	margin-left: auto;
	display: flex;
	gap: 8px;
}

.section-title {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	font-size: 16px;
	font-weight: 600;
	letter-spacing: -0.01em;
	color: var(--fg);
	margin: 24px 0 12px;
}
.section-title .count {
	font-family: var(--mono);
	font-size: 12px;
	background: var(--bg-subtle);
	padding: 2px 10px;
	border-radius: 999px;
	color: var(--fg-muted);
	font-variant-numeric: tabular-nums;
}
/* 标题行带操作按钮(历史录制的"高级筛选"入口) */
.section-title--with-actions {
	align-items: center;
	gap: 8px;
}
.section-title--with-actions .section-title-text {
	display: inline-flex;
	align-items: baseline;
	gap: 6px;
}
.section-title--with-actions .section-title-actions {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

/* ===== 通用按钮(覆盖默认 button 样式) ===== */
.btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	height: 36px;
	padding: 0 16px;
	font-size: 13px;
	font-weight: 500;
	border: 1px solid var(--border-strong);
	border-radius: 999px;
	background: var(--surface);
	color: var(--fg);
	cursor: pointer;
	transition:
		background-color var(--dur-fast) var(--ease-fluid),
		color var(--dur-fast) var(--ease-fluid),
		border-color var(--dur-fast) var(--ease-fluid),
		box-shadow var(--dur-fast) var(--ease-fluid),
		transform var(--dur-fast) var(--ease-fluid),
		opacity var(--dur-fast) var(--ease-fluid);
	white-space: nowrap;
}
.btn:hover {
	background: var(--bg-subtle);
}
.btn:active {
	transform: scale(0.97);
}
.btn.primary {
	background: var(--primary);
	color: var(--primary-fg);
	border-color: var(--primary);
}
.btn.primary:hover {
	background: var(--primary-hover);
	border-color: var(--primary-hover);
}
.btn.danger {
	background: var(--surface);
	color: var(--danger);
	border-color: var(--danger);
}
.btn.danger:hover {
	background: var(--danger-soft);
}
.btn.ghost {
	background: transparent;
	border-color: transparent;
}
.btn.ghost:hover {
	background: var(--bg-subtle);
}
.btn.icon {
	width: 36px;
	padding: 0;
	justify-content: center;
}
.btn:disabled {
	color: var(--fg-subtle);
	opacity: 0.4;
	cursor: not-allowed;
}
.btn:disabled.btn.primary,
.btn:disabled.btn.danger {
	color: var(--fg-subtle);
	opacity: 0.4;
}
.btn:focus-visible {
	outline: none;
	box-shadow: var(--shadow-active);
}
@media (max-width: 639px) {
	.btn {
		height: 44px;
		padding: 0 16px;
		font-size: 14px;
	}
	.btn.icon {
		width: 44px;
	}
}

/* ===== 分页 ===== */
.pagination {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	padding: 16px;
	font-size: 13px;
}
.pagination .page-info {
	font-family: var(--mono);
	color: var(--fg-muted);
	min-width: 60px;
	text-align: center;
}
.pagination select {
	height: 32px;
	padding: 0 10px;
	font-size: 13px;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: var(--surface);
	color: var(--fg);
	transition: box-shadow var(--dur-fast) var(--ease-fluid);
}
.pagination select:focus-visible {
	outline: none;
	box-shadow: var(--shadow-active);
}
.pagination .page-jump {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}
.pagination .page-jump-input {
	width: 64px;
	height: 32px;
	padding: 0 8px;
	font-size: 13px;
	font-family: var(--mono);
	border: 1px solid var(--border);
	border-radius: 10px;
	background: var(--surface);
	color: var(--fg);
	text-align: center;
	transition: box-shadow var(--dur-fast) var(--ease-fluid);
}
.pagination .page-jump-input:focus-visible {
	outline: none;
	box-shadow: var(--shadow-active);
}

/* ===== Modal(二次确认) ===== */
.modal-backdrop {
	position: fixed;
	inset: 0;
	z-index: 200;
	background: rgba(0, 0, 0, 0.4);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	display: flex;
	align-items: center;
	justify-content: center;
	animation: fadeIn var(--dur-med) var(--ease-fluid);
}
@keyframes fadeIn {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}
/* Apple "materialize": 淡入 + scale(0.96→1), 材质浮现而非单纯淡出。 */
@keyframes modalMaterialize {
	from {
		opacity: 0;
		transform: scale(0.96);
	}
	to {
		opacity: 1;
		transform: scale(1);
	}
}
.modal {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	padding: 24px;
	max-width: 420px;
	width: calc(100% - 32px);
	box-shadow: var(--shadow);
	animation: modalMaterialize var(--dur-med) var(--ease-fluid);
}
.modal h3 {
	margin: 0 0 16px;
	font-size: 17px;
	font-weight: 600;
	letter-spacing: -0.02em;
}
.modal dl {
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 6px 16px;
	margin: 0 0 16px;
	font-size: 13px;
}
.modal dt {
	color: var(--fg-muted);
}
.modal dd {
	margin: 0;
	font-family: var(--mono);
}
.modal .warn {
	color: var(--danger);
	font-size: 12px;
	margin: 0 0 16px;
}
.modal-actions {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
}

/* ===== BGA 导入失败详情弹窗 (bga-import-error.js) ===== */
.bga-import-error-modal {
	max-width: 480px;
}
.bga-import-error__reason {
	margin: 0 0 10px;
	font-size: 14px;
}
.bga-import-error__detail {
	margin: 0 0 14px;
	font-size: 13px;
	color: var(--fg-muted);
}
.bga-import-error__detail code {
	display: inline-block;
	max-width: 100%;
	word-break: break-all;
	font-family: var(--mono);
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	padding: 2px 6px;
	color: var(--danger);
}
.bga-import-error__trace {
	font-family: var(--mono);
	word-break: break-all;
}
.bga-import-copy-trace {
	margin-left: 8px;
	vertical-align: middle;
}

/* ===== BGA 导入任务批量勾选 / 409 已导入内联结果框 (import-page.js) ===== */
/* 匿名态 batch-delete 需登录 → 勾选整列(表头 + 行)隐藏。 */
body.bga-no-select .bga-col-select,
body.bga-no-select .bga-job-select-cell {
	display: none;
}
.bga-jobs-table .bga-job-select-cell {
	width: 36px;
	text-align: center;
}
.bga-jobs-table .bga-job-select-cell input {
	width: 16px;
	height: 16px;
	cursor: pointer;
}
.bga-result-already {
	margin-right: 8px;
	font-weight: 500;
}

/* ===== Toast (Apple HUD 深色胶囊) ===== */
.toast {
	position: fixed;
	bottom: 16px;
	left: 50%;
	transform: translate(-50%, 12px);
	padding: 10px 18px;
	background: rgba(29, 29, 31, 0.92);
	color: #ffffff;
	border-radius: 999px;
	box-shadow: var(--shadow);
	z-index: 1000;
	font-size: 13px;
	opacity: 0;
	transition:
		opacity var(--dur-med) var(--ease-fluid),
		transform var(--dur-med) var(--ease-fluid);
}
.toast.visible {
	opacity: 1;
	transform: translate(-50%, 0);
}
:root[data-theme="dark"] .toast {
	background: rgba(0, 0, 0, 0.85);
}
@media (prefers-color-scheme: dark) {
	:root:not([data-theme]) .toast {
		background: rgba(0, 0, 0, 0.85);
	}
}

/* ===== 全局滚动 ===== */
html {
	scroll-behavior: smooth;
}
body {
	overflow-x: hidden;
}

/* ===== 卡片内部布局 ===== */
.card .row {
	display: flex;
	gap: 16px;
	align-items: center;
	flex-wrap: wrap; /* 移动端自动换行 */
}
.card .room-id {
	font-weight: 600;
	font-family: var(--mono);
	font-size: 14px;
}
.card .card-actions {
	margin-left: auto;
	display: flex;
	gap: 8px;
	align-items: center;
	flex-wrap: wrap;
}
/* 历史卡片 actions 全断点 icon-only + 紧凑间距 (PC / 移动统一) */
.historical-card .card-actions {
	gap: 4px;
}
.historical-card .card-actions .btn.icon,
.historical-card .card-actions .room-link {
	width: 32px;
	height: 32px;
	padding: 0;
}
.card .ts {
	font-size: 11px;
	color: var(--fg-muted);
	font-family: var(--mono);
}

/* ===== 移动端卡片堆叠 ===== */
@media (max-width: 639px) {
	.card .row {
		gap: 8px;
	}
	.card .card-actions {
		margin-left: 0;
		width: 100%;
		justify-content: flex-end;
	}
	.card .meta {
		width: 100%;
	}
	.card .players {
		width: 100%;
	}
}

/* ===== 首页特� ===== */
/* ===== 首页看板(8 项指标) ===== */
.dashboard {
	margin-top: 8px;
}
.dashboard .section-title {
	margin: 8px 0 12px;
}
.dashboard-grid {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 12px;
}
.dashboard-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 16px 18px;
	box-shadow: var(--shadow-sm);
	display: flex;
	flex-direction: column;
	gap: 6px;
	min-width: 0;
}
.dashboard-card--games {
	background: var(--primary-soft);
}
.dashboard-card--winrate {
	background: var(--surface);
}
.stat-value {
	font-family: var(--mono);
	font-size: 2rem;
	font-weight: 600;
	color: var(--fg);
	line-height: 1.15;
	letter-spacing: -0.02em;
	font-variant-numeric: tabular-nums;
}
.dashboard-card--winrate .stat-value {
	color: var(--fg);
}
.stat-label {
	font-size: 13px;
	font-weight: 500;
	color: var(--fg-muted);
	letter-spacing: 0;
}
.dashboard-card--games .stat-label {
	color: var(--fg-muted-strong);
}
.dashboard-divider {
	border: 0;
	border-top: 1px solid var(--border);
	margin: 20px 0 0;
}
@media (max-width: 1023px) {
	.dashboard-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}
@media (max-width: 479px) {
	.dashboard-grid {
		grid-template-columns: minmax(0, 1fr);
	}
}

.create-form {
	display: flex;
	gap: 8px;
	align-items: center;
	flex-wrap: wrap;
}
.create-form input[type="text"] {
	flex: 1;
	min-width: 200px;
	padding: 8px 16px;
	font-size: 14px;
	font-family: var(--mono);
	border: 1px solid var(--border);
	border-radius: 999px;
	background: var(--surface);
	color: var(--fg);
	transition: box-shadow var(--dur-fast) var(--ease-fluid);
}
.create-form input[type="text"]:focus {
	outline: none;
	border-color: var(--border);
	box-shadow: var(--shadow-active);
}
.create-form button {
	flex-shrink: 0;
}
.create-msg {
	/* P2-2: 块级元素直接接 form 下方;margin 由组件自己负责垂直间距,
     不再依赖 :not(:empty) margin-left(原 form 内 flex item 撑出来的右侧偏移) */
	display: block;
	width: 100%;
	margin: 8px 0 0;
	font-size: 12px;
	line-height: 1.5;
	min-height: 1em;
}

/* ===== 多局回放 toolbar + grid ===== */
.multi-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	padding: 12px 16px;
	background: var(--surface);
	border-bottom: 1px solid var(--border);
	position: sticky;
	top: 56px;
	z-index: 9;
}
@supports (backdrop-filter: blur(1px)) {
	.multi-toolbar {
		background: color-mix(in srgb, var(--surface) 72%, transparent);
		backdrop-filter: blur(20px) saturate(180%);
		-webkit-backdrop-filter: blur(20px) saturate(180%);
	}
}
@media (prefers-reduced-transparency: reduce) {
	.multi-toolbar {
		background: var(--surface);
		backdrop-filter: none;
		-webkit-backdrop-filter: none;
	}
}
.multi-toolbar .label {
	font-size: 13px;
	color: var(--fg-muted);
}
.multi-toolbar input[type="number"] {
	width: 60px;
	height: 36px;
	padding: 0 10px;
	font-size: 13px;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: var(--surface);
	color: var(--fg);
	transition: box-shadow var(--dur-fast) var(--ease-fluid);
}
.multi-toolbar input[type="number"]:focus-visible {
	outline: none;
	box-shadow: var(--shadow-active);
}
.multi-toolbar .btn {
	white-space: nowrap;
}

/* multi-replay grid/cell 样式由 multi-replay.html 的 inline <style> 负责,
   这里只留 toolbar 和 button 样式。 */
@media (max-width: 639px) {
	.multi-toolbar {
		padding: 10px 12px;
		gap: 6px;
	}
	.multi-toolbar .btn {
		height: 40px;
		padding: 0 12px;
		font-size: 12px;
	}
}

/* ===== 筛选表单(历史录制) ===== */
.filter-form {
	display: block;
	padding: 16px;
	margin-bottom: 12px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow-sm);
}
.filter-common {
	display: grid;
	/* 高级筛选入口已上移至标题行,这里只放玩家名 / 房间 ID / 状态 / 应用&重置。 */
	grid-template-columns:
		minmax(180px, 1.1fr) minmax(180px, 1fr) minmax(160px, 0.8fr)
		auto;
	align-items: center;
	gap: 8px;
}
.filter-input {
	height: 36px;
	padding: 0 14px;
	font-size: 13px;
	border: 1px solid var(--border);
	border-radius: 999px;
	background: var(--surface);
	color: var(--fg);
	min-width: 0;
	width: 100%;
	font-family: var(--mono);
	transition: box-shadow var(--dur-fast) var(--ease-fluid);
}
.filter-input:focus {
	outline: none;
	box-shadow: var(--shadow-active);
}
.filter-sep {
	color: var(--fg-muted);
	font-family: var(--mono);
	font-size: 14px;
	user-select: none;
}
.filter-actions {
	display: flex;
	align-items: center;
	gap: 4px;
	white-space: nowrap;
}
.filter-actions .btn {
	height: 36px;
}
/* 桌面:筛选表单所有按钮(应用/重置/高级入口)与 input 等高,保持水平基线。 */
.filter-form .btn {
	height: 36px;
}
.filter-advanced {
	width: 100%;
}
.filter-advanced > summary {
	display: none;
}
.filter-advanced:not([open]) .filter-advanced-grid {
	display: none;
}
.filter-advanced-grid {
	/* 三组高级字段:时间、玩家 ID、回合数。每组内 fieldset 自带 grid,
     外层用三列等宽,避免之前 7 列网格在中等宽度错位。 */
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	align-items: center;
	gap: 8px;
	margin-top: 12px;
	padding-top: 12px;
	border-top: 1px solid var(--border);
}
/* 高级字段组:fieldset 零样式,内部 grid 让“label + 两个 input + 箭头”自然换行。 */
.filter-field-group {
	border: 0;
	padding: 0;
	margin: 0;
	min-width: 0;
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
	align-items: center;
	gap: 6px;
}
.filter-field-group[data-filter-group="player-id"] {
	grid-template-columns: minmax(0, 1fr);
}
.filter-field-group .filter-sep {
	color: var(--fg-muted);
	font-family: var(--mono);
}
@media (max-width: 1050px) {
	.filter-common {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
	.filter-actions {
		justify-self: end;
		grid-column: 3;
	}
	.filter-advanced-grid {
		grid-template-columns: 1fr;
	}
	.filter-advanced-grid .filter-sep {
		display: none;
	}
	.filter-field-group,
	.filter-field-group[data-filter-group="player-id"] {
		grid-template-columns: minmax(0, 1fr);
	}
}

/* ===== 批量操作条 ===== */
.bulk-bar {
	display: none;
	align-items: center;
	gap: 12px;
	padding: 10px 16px;
	margin-bottom: 8px;
	background: var(--primary-soft);
	border: 1px solid color-mix(in srgb, var(--primary) 28%, transparent);
	border-radius: var(--radius);
	box-shadow: var(--shadow-sm);
	font-size: 13px;
	color: var(--fg);
}
.bulk-bar.visible {
	display: flex;
}
.bulk-bar .bulk-count-text {
	font-weight: 500;
}
.bulk-bar .bulk-count-text b {
	color: var(--primary);
	font-family: var(--mono);
}
.bulk-bar .bulk-select-all {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	cursor: pointer;
	user-select: none;
}
.bulk-bar .bulk-select-all input {
	width: 16px;
	height: 16px;
	cursor: pointer;
}
.bulk-bar > .btn {
	margin-left: auto;
}
.bulk-bar > .btn + .btn {
	margin-left: 0;
}
.bulk-bar > .btn:not(:first-child) {
	margin-left: 0;
}
@media (max-width: 639px) {
	.bulk-bar {
		flex-wrap: wrap;
		gap: 8px;
		padding: 10px 12px;
	}
	.bulk-bar > .btn {
		margin-left: 0;
	}
	.bulk-bar .bulk-count-text {
		width: 100%;
		order: 2;
	}
}

/* ===== 历史卡片 checkbox 列 ===== */
.historical-card .card-checkbox {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 2px;
	margin-right: 4px;
}
.historical-card .card-checkbox input {
	width: 16px;
	height: 16px;
	cursor: pointer;
	accent-color: var(--primary);
}

/* ===== 表单校验错误提示 ===== */
.create-msg[data-kind="error"] {
	color: var(--danger);
	font-weight: 500;
}
.create-msg[data-kind="success"] {
	color: var(--success);
	font-weight: 500;
}

/* B12: input 校验红框视觉 + aria-invalid 化
   用 [data-error] 属性而不是 :invalid,避免污染 RFC 验证流程(novalidate 仍开) */
.create-form input[type="text"][data-error] {
	border-color: var(--danger);
	outline: 2px solid var(--danger-soft);
	outline-offset: -1px;
}
.create-form input[type="text"][data-error]:focus {
	outline-color: var(--danger);
	border-color: var(--danger);
}

/* 视觉隐藏但保留可访问性(用于 label) */
.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* H5: 主题切换按钮 */
.theme-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border: 1px solid transparent;
	border-radius: 999px;
	background: transparent;
	color: var(--fg-muted);
	cursor: pointer;
	transition:
		background-color var(--dur-fast) var(--ease-fluid),
		color var(--dur-fast) var(--ease-fluid),
		transform var(--dur-fast) var(--ease-fluid);
}
.theme-toggle:hover {
	background: var(--bg-subtle);
	color: var(--fg);
}
.theme-toggle:active {
	transform: scale(0.92);
}
.theme-toggle:focus-visible {
	outline: none;
	box-shadow: var(--shadow-active);
}
.theme-toggle svg {
	width: 16px;
	height: 16px;
}

/* 版式切换按钮承载 i18n 文本 (版式·经典/版式·BGA ≈60px), 固定 32px 方钮宽会裁字 — 按内容撑开 */
.replay-layout-toggle {
	width: auto;
	min-width: 32px;
	padding: 0 8px;
}

/* M10: 尊重 prefers-reduced-motion(用户偏好减少动画) */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}
}

/* L1: btn-play 内 icon-play / icon-pause 切换显示
   data-running 在父元素 .replay-buttons 上 (不是 #btn-play 本身),
   之前用 #btn-play[data-running="1"] 的写法特异性 (1,1,1) 比
   #btn-play .icon-pause 的 (1,0,1) 高, 但 #btn-play 没有 data-running 属性,
   该规则实际从不命中 -> pause 永远 hidden. 改为 .replay-buttons[data-running] 后
   与 replay.html 内联 .replay-buttons[data-running="X"] 规则一�� (同特异性 + 后写者赢). */
.replay-buttons .icon-play,
.replay-buttons .icon-pause {
	display: inline-flex;
}
.replay-buttons[data-running="1"] .icon-play {
	display: none;
}
.replay-buttons[data-running="1"] .icon-pause {
	display: inline-flex;
}
.replay-buttons[data-running="0"] .icon-pause {
	display: none;
}

/* L1: replay-step / mini-controls button 图标尺寸 */
.replay-step svg,
.mini-controls button svg {
	width: 14px;
	height: 14px;
	vertical-align: middle;
}
.multi-toolbar .btn svg {
	width: 14px;
	height: 14px;
	vertical-align: middle;
}

/* L2: 全部倍速选择器 */
.speed-all-wrap {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 13px;
	color: var(--fg-muted);
}
.speed-all-wrap select {
	height: 36px;
	padding: 0 10px;
	font-size: 13px;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: var(--surface);
	color: var(--fg);
	transition: box-shadow var(--dur-fast) var(--ease-fluid);
}
.speed-all-wrap select:focus-visible {
	outline: none;
	box-shadow: var(--shadow-active);
}

/* L3: 多局 cell 移动端高度自适应 */
@media (max-width: 639px) {
	.multi-cell .frame {
		aspect-ratio: 4 / 3;
		min-height: 220px;
	}
}

/* L6: modal focus-visible 强化 */
.modal button:focus-visible {
	outline: 2px solid var(--primary);
	outline-offset: 2px;
}

/* v12-2026-07-21 (F10): share modal 内 admin 公开可见 checkbox 自定义样式,
   统一跨平台观感, 焦点环可见。 */
.modal input[type="checkbox"] {
	width: 16px;
	height: 16px;
	margin: 0;
	cursor: pointer;
	accent-color: var(--primary);
	flex-shrink: 0;
}
.modal input[type="checkbox"]:focus-visible {
	outline: 2px solid var(--primary);
	outline-offset: 2px;
}

/* L1: btn-play 内 svg 文字混排 */
#btn-play {
	gap: 6px;
}
#btn-play svg {
	width: 14px;
	height: 14px;
}

/* L5: lang=en 时把角落 "回放中 · 操作已禁用" 标签切到英文。
   :lang(en) 选择器特异性高于 .replay-iframe-wrap::after,因而覆盖默认 */
:lang(en) .replay-iframe-wrap::after {
	content: "Replaying · disabled";
}

/* ===== B4 配套:player 404/error UI ===== */
.player-not-found {
	padding: 60px 24px;
	text-align: center;
	color: var(--fg-muted);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	margin: 24px 0;
}
.player-not-found h2 {
	color: var(--fg);
	margin: 0 0 8px;
	font-size: 18px;
}
.player-not-found p {
	margin: 0 0 20px;
	font-size: 13px;
}
.player-not-found .btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 36px;
	min-width: 160px;
	padding: 0 16px;
	background: var(--primary);
	color: var(--primary-fg);
	border: 1px solid var(--primary);
	border-radius: var(--radius-sm);
	text-decoration: none;
	font-size: 14px;
}
.player-not-found .btn:hover {
	filter: brightness(0.95);
}

/* ============================================================
 * Replay DOM board (ccbs.css + ccbs-theme-overrides.css 配套)
 * 追加: ccbs 内部小部件定位 + replay-player-* 玩家面板 utility。
 * 这些是 ccbs.css 没定义、官方 React 端用 inline style 处理的部分。
 * ============================================================ */

/* 卡内右上角 bonus chip(官方 React 端用 absolute top-1 right-1) */
.ccbs-bonus-chip {
	position: absolute;
	top: 4px;
	right: 4px;
	width: 20px;
	height: 20px;
	line-height: 18px;
	font-size: 12px;
	border: 1px solid #fff;
	box-shadow: 0 0 3px 1px rgba(0, 0, 0, 0.2);
	border-radius: 4px;
}
:root[data-theme="dark"] .ccbs-bonus-chip {
	border-color: #ddd;
}

/* 卡左上角 score 数字(官方用 left-0.5,这里简化 left:0) */
.ccbs-score.left-0 {
	left: 0;
	text-align: left;
	padding-left: 4px;
	box-sizing: border-box;
}

/* 贵族右上分数: 复用 .ccbs-score 效果, 只改锚点 (noble 110×110 pre-scale) */
.ccbs-noble .ccbs-score {
	top: 0;
	right: 0;
	left: auto;
}

/* 卡底部 cost chips(官方 React 端 absolute bottom-0.5 left-0.5 + flex-col-reverse) */
.ccbs-cost-chips {
	position: absolute;
	bottom: 4px;
	left: 4px;
	display: flex;
	flex-direction: column-reverse;
	gap: 2px;
}
.ccbs-cost-chip {
	position: relative;
	font-size: 13px;
	width: 26px;
	height: 26px;
	line-height: 26px;
	border-width: 1px;
	box-sizing: border-box;
}

/* 贵族左侧 req chip 容器(ccbs-noble-left 是 absolute 覆盖到左半) */
.ccbs-req-chip {
	margin: 2px 0;
	width: 18px;
	height: 22px;
	line-height: 20px;
	font-size: 11px;
	text-align: center;
	border: 1px solid #fff;
	border-radius: 4px;
	box-shadow: 0 0 3px 1px rgba(0, 0, 0, 0.2);
	color: #fff;
	font-weight: 700;
	text-shadow:
		0 0 0.1em #000,
		0 0 0.1em #000,
		0 0 0.1em #000;
}

/* ====== 玩家面板 ====== */
.replay-player-panel {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 12px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-left: 3px solid transparent;
	border-radius: var(--radius-sm);
	font-size: 13px;
	color: var(--fg);
	transition: border-color 120ms ease;
}
.replay-player-panel[data-active="true"] {
	border-left-color: var(--primary);
	background: var(--bg-subtle);
}
.replay-player-avatar {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	font-size: 22px;
	flex: 0 0 auto;
	background: var(--bg-subtle);
	border-radius: 50%;
}
.replay-player-info {
	display: flex;
	align-items: center;
	gap: 6px;
	min-width: 80px;
}
.replay-player-name {
	font-weight: 600;
	color: var(--fg);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 120px;
}
/* v5-2026-07-19: owner 走 absolute overlay (由 replay.html 的 .replay-player-avatar .replay-player-owner 接管);
   这里仅保留 font-weight 兜底, 避免一些老 caller 直接挂在 panel 上时塌掉 */
.replay-player-owner {
	font-weight: 600;
}
.replay-player-gems,
.replay-player-bonuses,
.replay-player-reserves,
.replay-player-decks {
	display: flex;
	gap: 3px;
	align-items: center;
	flex-wrap: wrap;
}
.replay-player-gems .ccbs-rect,
.replay-player-bonuses .ccbs-circle {
	font-size: 12px;
}
.replay-player-bonuses .ccbs-circle.ccbs-small {
	--ccbs-scale: 0.55;
	font-size: 11px;
}
.replay-player-reserves .ccbs-card,
.replay-player-decks .ccbs-card {
	width: 36px;
	height: 48px;
}
.replay-player-score {
	margin-left: auto;
	font-weight: 700;
	color: var(--fg);
	font-size: 14px;
	white-space: nowrap;
}

/* 移动端断点(≤480px):玩家面板拆双行 */
@media (max-width: 480px) {
	.replay-player-panel {
		flex-wrap: wrap;
		row-gap: 6px;
	}
	.replay-player-info {
		flex: 1 1 100%;
	}
	.replay-player-gems,
	.replay-player-bonuses,
	.replay-player-reserves,
	.replay-player-decks {
		flex: 1 1 auto;
	}
	.replay-player-score {
		margin-left: auto;
	}
}

/* Game list participants 网格(Task 5/6) */
/* auto-fit 紧凑网格,2-4 玩家对局自适应;winner 加左侧强调色 + 软底 */
.participants-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
	gap: 8px;
	margin-top: 6px;
}
.participant {
	display: flex;
	align-items: baseline;
	gap: 4px;
	flex-wrap: wrap;
	font-size: 12px;
	padding: 4px 8px;
	background: var(--bg-subtle, #f5f5f5);
	border-radius: 4px;
	border-left: 3px solid transparent;
}
.participant.is-winner {
	border-left-color: var(--success, #16a34a);
	background: var(--success-soft, #f0fdf4);
}
.participant .name {
	font-weight: 500;
}
.participant .score {
	font-weight: 600;
}
.participant .meta {
	color: var(--fg-muted, #6b7280);
	font-size: 11px;
}
.participant .winner-mark {
	font-size: 11px;
}
.participants-empty {
	color: var(--fg-muted, #6b7280);
	font-size: 12px;
	margin-top: 4px;
	font-style: italic;
}
.participant-avatar {
	width: 24px;
	height: 24px;
	border-radius: 50%;
	object-fit: cover;
	flex: none;
}

@media (max-width: 600px) {
	.participants-grid {
		grid-template-columns: repeat(2, 1fr);
	}
	.participant {
		font-size: 11px;
		padding: 3px 6px;
	}
}

/* ===== room-link: icon-only 外链按钮 (跳 hullqin 房间) ===== */
.room-link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border-radius: 999px;
	color: var(--fg-muted);
	border: 1px solid transparent;
	background: transparent;
	text-decoration: none;
	transition:
		background var(--dur-fast) var(--ease-fluid),
		color var(--dur-fast) var(--ease-fluid),
		transform var(--dur-fast) var(--ease-fluid);
}
.room-link:hover {
	background: var(--bg-subtle);
	color: var(--fg);
}
.room-link:active {
	transform: scale(0.92);
}
.room-link:focus-visible {
	outline: none;
	box-shadow: var(--shadow-active);
}
@media (max-width: 639px) {
	.room-link {
		width: 36px;
		height: 36px;
	}
}

/* ===== replay-room-card: 房间号小卡片 (浮在 board-wrap 左上角) ===== */
.replay-room-card {
	position: absolute;
	top: 8px;
	left: 12px;
	z-index: 5;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 10px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	font-size: 13px;
	box-shadow: var(--shadow-sm);
	/* 防止小屏被棋盘遮住,棋盘场景默认 padding 8/12/12,左 12px 与卡片对齐 */
}
.replay-room-card .label {
	color: var(--fg-muted);
	font-weight: 500;
}
.replay-room-card .value {
	display: inline-flex;
	align-items: center;
	gap: 3px;
	color: var(--fg);
	text-decoration: none;
	font-weight: 600;
}
.replay-room-card .value:hover {
	color: var(--primary);
}
.replay-room-card .value:focus-visible {
	outline: none;
	box-shadow: var(--shadow-active);
	border-radius: 2px;
}
.replay-room-card .icon {
	opacity: 0.7;
}
@media (max-width: 639px) {
	.replay-room-card {
		top: 4px;
		left: 8px;
		font-size: 12px;
		padding: 4px 8px;
	}
}

/* ===== Logo / brand ===== */
.app-logo {
	display: inline-block;
	vertical-align: middle;
}
.app-wordmark {
	vertical-align: middle;
}

/* 顶部 page-header 中的 wordmark(h1 #app-brand) */
.page-header .app-brand {
	display: inline-flex;
	align-items: center;
	gap: 8px;
}
.page-header .app-brand .app-logo-wordmark {
	font-size: 16px;
	font-weight: 600;
}

/* replay summary 中的小 logo(与文字水平对齐) */
.replay-brand {
	display: inline-flex;
	align-items: center;
	margin-right: 4px;
}
.replay-brand .app-logo {
	display: block;
}

/* ============================================================
   Mobile optimization (≤639px) — 录制列表页 v2
   目标:提高密度、极简卡片、logo 放大、菜单折叠、筛选折叠
   ============================================================ */

/* 弹层菜单(全断点) */
.auth-menu {
	position: relative;
	display: inline-flex;
	align-items: center;
}
.auth-menu-popover {
	position: absolute;
	top: calc(100% + 6px);
	right: 0;
	min-width: 180px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 6px;
	z-index: 100;
}
.auth-menu-header {
	padding: 8px 10px;
	font-size: 12px;
	color: var(--fg-muted);
	border-bottom: 1px solid var(--border);
	margin-bottom: 4px;
	white-space: nowrap;
}
.auth-menu-item {
	display: block;
	width: 100%;
	padding: 8px 10px;
	background: transparent;
	border: none;
	border-radius: var(--radius-sm);
	color: var(--fg);
	text-align: left;
	font-size: 13px;
	cursor: pointer;
	text-decoration: none;
	font: inherit;
	white-space: nowrap;
	transition: background-color var(--dur-fast) var(--ease-fluid);
}
.auth-menu-item:hover {
	background: var(--bg-subtle);
}

/* 高级筛选入口位于常用筛选栏，数量徽标提示折叠中的生效条件。 */
.filter-toggle {
	display: inline-flex;
	height: 36px;
	padding: 0 14px;
	font-size: 12px;
	font-weight: 500;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 999px;
	color: var(--fg-muted);
	align-items: center;
	gap: 4px;
	cursor: pointer;
	transition:
		background var(--dur-fast) var(--ease-fluid),
		color var(--dur-fast) var(--ease-fluid),
		transform var(--dur-fast) var(--ease-fluid);
}
.filter-toggle:hover {
	background: var(--bg-subtle);
	color: var(--fg);
}
.filter-toggle:active {
	transform: scale(0.97);
}
.filter-toggle.has-active-filters {
	border-color: var(--primary);
	color: var(--primary);
}
.filter-toggle svg {
	transition: transform 0.15s ease;
}
.filter-toggle.is-open svg {
	transform: rotate(180deg);
}
.filter-toggle-count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 18px;
	height: 18px;
	padding: 0 5px;
	border-radius: 9px;
	background: var(--primary);
	color: var(--primary-fg, #fff);
	font: 600 11px/1 var(--mono);
}
.filter-toggle-count[hidden] {
	display: none;
}

@media (max-width: 639px) {
	/* 顶部 header 紧凑 */
	.page-header {
		padding: 6px 12px;
		min-height: 40px;
		gap: 6px;
		flex-wrap: wrap; /* 390px 下 nowrap 导航链接 + 控件区最小宽度 416px, 换行消除横向溢出 */
	}
	.page-header .app-brand .app-logo-wordmark {
		display: none;
	}
	.page-header .app-brand .app-logo {
		transform: scale(2);
		transform-origin: left center;
		margin-right: 12px;
	}
	/* P2-8 (2026-08-31): 移动端把 theme/lang toggle 触控区扩到 40px (iOS HIG ≥44px,
	 * 桌面端保持 32px)。padding 扩热区不破坏 layout。 */
	.page-header .theme-toggle,
	.page-header #lang-toggle {
		min-width: 40px;
		min-height: 40px;
		padding: 0;
	}
	.page-header #lang-toggle {
		font-size: 10px;
	}
	/* P2-10 (2026-08-31): 移动端 auth-menu-trigger 与 nav-link 触控区扩到 ≥40px,
	 * 桌面端保持原样。padding 扩热区不破坏 layout。 */
	.auth-menu-trigger {
		min-width: 40px;
		min-height: 40px;
		padding: 0;
	}
	.page-header .header-nav-link {
		min-height: 40px;
		display: inline-flex;
		align-items: center;
	}

	/* section 间距收紧 */
	main {
		padding: 12px;
	}
	section {
		margin-bottom: 16px;
	}
	.section-title {
		margin: 16px 0 8px;
		padding-bottom: 4px;
	}
	/* card 内边距收紧 */
	.card {
		padding: 8px 10px;
		margin-bottom: 6px;
		border-radius: var(
			--radius
		); /* 12px: 与全站卡片圆角语言一致 (原 radius-sm 8px 偏小) */
	}

	/* 极简历史卡片:checkbox + 房间 id + 按钮 一行 */
	.historical-card .row {
		flex-wrap: nowrap;
		gap: 6px;
		align-items: center;
	}
	.historical-card .room-id-block {
		display: flex;
		flex-direction: column;
		min-width: 0;
		flex: 1 1 auto;
		overflow: hidden;
	}
	.historical-card .room-id {
		font-size: 13px;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
	.historical-card .recorded-at {
		font-size: 10px;
		color: var(--fg-subtle);
		font-family: var(--mono);
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
	.historical-card .card-actions {
		margin-left: 0;
		width: auto;
		justify-content: flex-end;
		flex-shrink: 0;
	}

	/* participants 网格:固定 2 列 */
	.participants-grid {
		grid-template-columns: repeat(2, 1fr);
		gap: 4px;
	}
	.participant {
		font-size: 11px;
		padding: 3px 6px;
	}

	/* 筛选表单 */
	.filter-form {
		padding: 10px;
	}
	.filter-common {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 6px;
	}
	.filter-common .filter-input--primary {
		grid-column: 1 / -1;
	}
	.filter-common .filter-status-group {
		min-width: 0;
	}
	.filter-input {
		height: 40px;
		font-size: 14px;
	}
	.filter-toggle {
		width: 100%;
		height: 38px;
		grid-column: 1 / -1;
		justify-content: center;
	}
	.filter-actions {
		width: 100%;
		grid-column: 1 / -1;
		justify-self: stretch;
	}
	.filter-actions .btn {
		flex: 1 1 0;
		height: 38px;
	}
	.filter-advanced[open] .filter-advanced-grid {
		display: grid;
		grid-template-columns: 1fr 1fr;
		gap: 6px;
		margin-top: 10px;
		padding-top: 10px;
	}
	.filter-advanced:not([open]) .filter-advanced-grid {
		display: none;
	}
	.filter-advanced-grid .filter-sep {
		display: none;
	}
	.filter-advanced-grid .filter-input {
		width: 100%;
		min-width: 0;
		height: 38px;
		font-size: 13px;
	}
	.filter-form .btn {
		font-size: 13px;
	}

	/* 批量操作条 */
	.bulk-bar {
		padding: 8px 10px;
		gap: 6px;
		font-size: 12px;
		flex-wrap: wrap;
	}
	.bulk-bar .btn {
		height: 36px;
		padding: 0 10px;
		font-size: 12px;
	}
	.bulk-bar .bulk-count-text {
		width: 100%;
		order: 2;
	}

	/* 分页 */
	.pagination {
		padding: 12px;
		font-size: 12px;
		gap: 8px;
		flex-wrap: wrap; /* 上/下页 + 页码 + 跳页 + 每页条数一行放不进 390px, 换行防横向溢出 */
	}
	.pagination select {
		height: 36px;
	}

	/* 创建录制表单 */
	.create-form input[type="text"] {
		min-width: 0;
		height: 40px;
	}
	.create-form .btn {
		height: 40px;
	}
}

/* 语义修饰类（取代内联 style 残留，master plan §6.3） */
.filter-input--wide {
	min-width: 160px;
}
.filter-input--narrow {
	min-width: 140px;
}
.filter-input--fixed-140 {
	flex: 0 0 140px;
}
.filter-input--grow {
	flex: 1 1 220px;
}
.filter-actions-col {
	text-align: right;
}
.lang-btn--compact {
	margin-right: 6px;
	font-size: 11px;
	font-weight: 600;
}

/* status-multiselect: 按钮 + checkbox popover,沿用既有 filter-* 视觉语言。 */
.status-multiselect {
	position: relative;
	display: block;
	min-width: 0;
}
.status-trigger {
	appearance: none;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 999px;
	padding: 6px 14px;
	width: 100%;
	text-align: left;
	cursor: pointer;
	font-size: 13px;
	color: var(--fg);
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 6px;
	height: 36px;
	transition: box-shadow var(--dur-fast) var(--ease-fluid);
}
.status-trigger:hover {
	background: var(--bg-subtle);
}
.status-trigger::after {
	content: "▾";
	color: var(--fg-muted);
	font-size: 11px;
}
.status-trigger[aria-expanded="true"] {
	box-shadow: var(--shadow-active);
}
.status-popover {
	position: absolute;
	top: calc(100% + 4px);
	left: 0;
	min-width: 100%;
	max-width: 240px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 6px;
	z-index: 100;
}
.status-options {
	display: flex;
	flex-direction: column;
	gap: 2px;
}
.status-option {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 6px 8px;
	cursor: pointer;
	font-size: 13px;
	border-radius: var(--radius-sm);
	transition: background-color var(--dur-fast) var(--ease-fluid);
}
.status-option:hover {
	background: var(--bg-subtle);
}
.status-option input[type="checkbox"] {
	margin: 0;
}
.status-actions {
	display: flex;
	justify-content: flex-end;
	gap: 6px;
	margin-top: 8px;
	padding-top: 8px;
	border-top: 1px solid var(--border, #e5e7eb);
}
.status-actions .btn {
	font-size: 12px;
	padding: 4px 10px;
}

.active-card.is-readonly .card-actions {
	/* 匿名 active 卡片不显示内部操作,只留原房间链接 + 状态文本 */
	gap: 8px;
}
.active-card.is-readonly {
	opacity: 0.95;
}

/* === 需求1 (2026-09-21): feedback modal 内容层主题化 ===
   放在 app.css (每个页面都加载) 而非 replay.css — 任何能调 modalConfirm 的页面
   都吃到样式, 杜绝「页面相关」的再次退化。标题字号对齐 .replay-modal h3。 */
.feedback-modal__title {
	margin: 0 0 8px;
	font-size: 16px;
	font-weight: 600;
	color: var(--fg);
}
.feedback-modal__body {
	font-size: 13px;
	line-height: 1.5;
	color: var(--fg-muted);
}
.feedback-modal__actions {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
	margin-top: 16px;
}
.feedback-modal__cancel,
.feedback-modal__confirm,
.feedback-modal__confirm--destructive {
	height: 36px;
	padding: 0 18px;
	border: 1px solid var(--border);
	border-radius: 999px;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	background: var(--surface);
	color: var(--fg);
}
.feedback-modal__cancel:hover {
	filter: brightness(0.97);
}
.feedback-modal__confirm {
	background: var(--accent);
	border-color: var(--accent);
	color: #fff;
}
.feedback-modal__confirm--destructive {
	background: #dc2626;
	border-color: #dc2626;
	color: #fff;
}
.feedback-modal__confirm:hover,
.feedback-modal__confirm--destructive:hover {
	filter: brightness(1.06);
}

/* === 弹窗外壳 (showModal 默认 class) — 2026-09-21 遗留修复: 从 replay.css 迁入 ===
   modalConfirm (feedback.js) 走 showModal 默认外壳, 且被 admin/import 页调用,
   而那些页只加载 app.css + admin.css → 外壳样式必须放在全局样式表,
   否则弹窗退化为文档流底部纯文本 (与需求3 同根因)。
   已核实: 无其他样式表定义这两个选择器, 迁移无级联冲突。 */
.replay-modal-backdrop {
	position: fixed;
	inset: 0;
	background: rgba(15, 23, 42, 0.45);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 100;
}
.replay-modal {
	background: var(--surface);
	border-radius: var(--radius);
	padding: 20px 22px;
	max-width: 360px;
	width: calc(100% - 32px);
	box-shadow: var(--shadow);
}
@media (prefers-reduced-motion: no-preference) {
	.replay-modal-backdrop {
		animation: replay-modal-fade-in 120ms ease-out;
	}
	.replay-modal {
		animation: replay-modal-pop-in 180ms cubic-bezier(0.23, 1, 0.32, 1);
	}
	.replay-modal-backdrop.is-closing {
		opacity: 0;
		transition: opacity 120ms ease-in;
	}
	.replay-modal-backdrop.is-closing .replay-modal {
		opacity: 0;
		transform: scale(0.97);
		transition:
			opacity 120ms ease-in,
			transform 120ms ease-in;
	}
}
@keyframes replay-modal-fade-in {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}
@keyframes replay-modal-pop-in {
	from {
		opacity: 0;
		transform: scale(0.96);
	}
	to {
		opacity: 1;
		transform: scale(1);
	}
}

