:root {
	--ts-bg1: #ECF3F7;
	--ts-bg1-rgb: 236, 243, 247;
	--ts-bg2: #E1EBF2;
	--ts-radius: 7px;
	--ts-max-h: 60px;
	--ts-author-size: 32px;
	--ts-poster-size: 24px;
	--ts-item-w: 64px;
	--ts-item-gap: 6px;
}
/* Main container — hard 90px cap */
.topic_stats_main {
	position: relative;
	display: flex;
	align-items: stretch;
	background-color: var(--ts-bg1);
	border-radius: var(--ts-radius);
	margin-bottom: 4px;
	height: var(--ts-max-h);
	overflow: hidden;
}
/* ---- Author block ---- */
.topic_stats_author {
	background-color: var(--ts-bg1);
	border-radius: var(--ts-radius) 0 0 var(--ts-radius);
	padding: 6px 10px;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 70px;
}
.author_avatar img {
	width: var(--ts-author-size);
	height: var(--ts-author-size);
	border-radius: 50%;
	object-fit: cover;
	display: block;
}
.author_username {
	margin-top: 3px;
	font-size: 11px;
	font-weight: bold;
	text-align: center;
	max-width: 120px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	line-height: 1.2;
}
.author_username a { text-decoration: none; }
/* ---- Stats block ---- */
.topic_stats_left {
	background-color: var(--ts-bg2);
	padding: 6px 4px;
	display: flex;
	align-items: center;
	flex: 0 0 auto;
}
.topic_stats_ul {
	display: flex;
	padding: 0 8px;
	margin: 0 !important;
}
.topic_stat_item {
	padding: 0 10px;
	text-align: center;
	display: flex;
	flex-direction: column;
	justify-content: center;
	min-width: 0;
}
.topic_stat_value {
	display: block;
	font-weight: bold;
	font-size: 12px;
	line-height: 1.1;
}
.topic_stat_title {
	display: block;
	font-size: 10px;
	color: #555;
	white-space: nowrap;
	letter-spacing: 0.3px;
}

/* ---- Top posters row ---- */
.topic_stats_middle {
	position: relative;
	flex: 1 1 auto;
	min-width: 0;
	padding: 8px;
	overflow: hidden;
	display: flex;
	align-items: center;
}
.topic_stats_ulist {
	display: flex;
	gap: var(--ts-item-gap);
	overflow: hidden;
	flex-wrap: nowrap;
	align-items: center;
	width: 100%;
}
/* Vertical tile: avatar / name (count in tooltip) */
.stats_user {
	display: flex;
	flex-direction: column;
	align-items: center;
	flex: 0 0 var(--ts-item-w);
	min-width: 0;
	line-height: 1;
	cursor: default;
	margin-top: 10px;
}
.ts_avatar img {
	width: var(--ts-poster-size);
	height: var(--ts-poster-size);
	border-radius: 50%;
	object-fit: cover;
	display: block;
}
.ts_name {
	margin-top: 4px;
	font-size: 9px;
	max-width: var(--ts-item-w);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	line-height: 1.1;
}
.ts_name a { text-decoration: none; }
.ts_empty { margin: 0; font-size: 12px; color: #666; }
/* Fade mask on right edge of the row */
.topic_stats_middle::after {
	content: '';
	pointer-events: none;
	position: absolute;
	top: 0; bottom: 0; right: 0;
	width: 220px;
	background: linear-gradient(to right, rgba(var(--ts-bg1-rgb), 0) 0%, rgba(var(--ts-bg1-rgb), 1) 100%);
}
/* ---- Top-right corner: header + chevron ---- */
.topic_stats_corner {
	position: absolute;
	top: 6px;
	right: 6px;
	z-index: 2;
	display: flex;
	align-items: center;
	gap: 6px;
}
.topic_stats_header {
	font-size: 10px;
	font-weight: bold;
	position: absolute;
	top: 1px;
	left: 8px;
}
.topic_stats_toggle {
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.6);
	display: flex;
	align-items: center;
	justify-content: center;
	color: #333;
	font-size: 11px;
	transition: background 0.15s;
	text-decoration: none;
}
.topic_stats_toggle:hover,
.topic_stats_toggle:focus {
	background: #fff;
	text-decoration: none;
}

/* ---- Modal grid (rendered inside phpBB's #phpbb_alert) ---- */
.ts_modal_grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
	gap: 1px;
	padding: 10px 0;
}
.ts_modal_item {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	background-color: var(--ts-bg1);
	min-width: 0;
	border: 1px solid #ccc;
	border-radius: var(--ts-radius);
	margin: 5px;
	padding: 5px 0px;
}
.ts_modal_count {
	font-size: 12px;
	color: #333;
	margin-bottom: 4px;
}
.ts_modal_count_nr {
	font-weight: bold;
}
.ts_modal_avatar img {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	object-fit: cover;
	display: block;
}
.ts_modal_name {
	margin-top: 4px;
	font-size: 12px;
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.ts_modal_name a { text-decoration: none; }
/* Dark mode */
html.phpbb-dark-mode .topic_stats_main { --ts-bg1: #1e2a32; --ts-bg1-rgb: 30, 42, 50; --ts-bg2: #172028; }
html.phpbb-dark-mode .topic_stats_left { background-color: var(--ts-bg2); }
html.phpbb-dark-mode .topic_stat_title { color: #9ab; }
html.phpbb-dark-mode .topic_stats_toggle { background: rgba(0, 0, 0, 0.35); color: #ccc; }
html.phpbb-dark-mode .topic_stats_toggle:hover,
html.phpbb-dark-mode .topic_stats_toggle:focus { background: rgba(0, 0, 0, 0.6); }
html.phpbb-dark-mode .ts_empty { color: #9ab; }
html.phpbb-dark-mode .ts_modal_item { background-color: var(--ts-bg1); border-color: #3a4a55; }
html.phpbb-dark-mode .ts_modal_count { color: #bcd; }
/* ---- Mobile ---- */
@media (max-width: 700px) {
	.topic_stats_main {
		margin-right: -5px;
		margin-left: -5px;
		border-radius: 0;
	}
	.topic_stats_author {
		border-radius: 0;
		width: 80px;
		padding: 6px 8px;
	}
	.author_avatar img {
		width: 24px;
		height: 24px;
	}
	.topic_stat_item { padding: 0 8px; }
	.topic_stat_value { font-size: 10px; }
	.topic_stat_title, .topic_stats_header { font-size: 9px; }
	.ts_avatar img {
		width: 20px;
		height: 20px;
	}
}
@media (max-width: 600px) {
	.topic_stats_main {
		max-height: 50px;
	}
	.topic_stat_item { padding: 0 4px; }
	.topic_stats_middle { display: none; }
	.topic_stats_author { flex: 0 0 auto; width: 70px; }
	.topic_stats_left { flex: 1 1 auto; justify-content: center; }
	.topic_stats_ul { justify-content: center; width: 100%; padding: 0 4px; }
	.ts_modal_grid {
		max-height: 40vh;
		overflow-y: auto;
	}
}