/* ==========================================================================
   FIRST / LAST AVATARS — VIEWFORUM TOPIC ICON + LASTPOST AVATAR
   ========================================================================== */

/* Shared index / Recent Topics block (.topic-avatars) */
.topic-avatars {
	float: right;
	position: relative;
	width: 42px;
	height: 42px;
	margin-left: 10px;
	margin-top: 2px;
}

.topic-avatars .avatar-main {
	position: relative;
	left: 0;
}

.topic-avatars .avatar-main img {
	width: 42px;
	height: 42px;
	aspect-ratio: 1 / 1;
	border-radius: 50%;
	object-fit: cover;
	object-position: center;
	border: 1px solid #c8d0d3;
	display: block;
	background: #fff;
	transition: transform 0.15s ease;
}

.topic-avatars .avatar-last {
	position: absolute;
	bottom: -2px;
	right: -8px;
}

.topic-avatars .avatar-last img {
	width: 24px;
	height: 24px;
	aspect-ratio: 1 / 1;
	border-radius: 7px;
	object-fit: cover;
	object-position: center;
	border: 1px solid #c8d0d3;
	box-shadow: 1px 1.5px 3px rgba(0, 0, 0, 0.08);
	background: #fff;
	transition: transform 0.15s ease;
}

html.darkmode .topic-avatars .avatar-main img,
html.darkmode .topic-avatars .avatar-last img {
	border: 1px solid #2b2f32 !important;
	background: #1e2224;
}

html.darkmode .topic-avatars .avatar-last img {
	box-shadow: 1.5px 1.5px 3px rgba(0, 0, 0, 0.28);
}

/* Keep index forumlist avatars untouched */
body.section-index .forumbg .topic-avatars,
body.section-index .forabg .topic-avatars {
	left: auto !important;
	right: 4px !important;
	top: 4px !important;
}

/* ==========================================================================
   VIEWFORUM: First Avatar (52x52) as Rounded-Square Topic Icon
   ========================================================================== */

body.section-viewforum ul.topiclist.topics li.row dl {
	position: relative;
	overflow: visible !important;
}

body.section-viewforum ul.topiclist.topics li.row dt {
	position: relative;
	min-height: 54px;
}

body.section-viewforum ul.topiclist.topics li.row dt .list-inner {
	padding-left: 64px !important;
	min-height: 52px;
	box-sizing: border-box;
}

/* Hide default topic icon in viewforum rows so first avatar acts as topic icon */
body.section-viewforum ul.topiclist.topics li.row dt > a.row-item-link,
body.section-viewforum ul.topiclist.topics li.row dt .list-inner > a.row-item-link,
body.section-viewforum ul.topiclist.topics li.row dl.row-item:before {
	display: none !important;
}

body.section-viewforum ul.topiclist.topics li.row .first-post-avatar {
	position: absolute;
	left: 2px;
	top: 2px;
	z-index: 2;
	line-height: 1;
}

body.section-viewforum ul.topiclist.topics li.row .first-post-avatar img {
	width: 52px !important;
	height: 52px !important;
	max-width: none !important;
	aspect-ratio: 1 / 1;
	border-radius: 10px;
	object-fit: cover;
	object-position: center;
	border: 1px solid #c8d0d3;
	display: block;
	background: #fff;
	transition: transform 0.15s ease;
}

html.darkmode body.section-viewforum ul.topiclist.topics li.row .first-post-avatar img {
	border: 1px solid #2b2f32 !important;
	background: #1e2224;
}

/* ==========================================================================
   LASTPOST LAYOUT
   ========================================================================== */

dd.lastpost {
	text-overflow: ellipsis;
	white-space: nowrap;
}

dd.lastpost > span,
.forabg dd.lastpost > span {
	display: block;
	position: relative;
	min-height: 42px;
	padding-left: 0 !important;
	padding-right: 52px !important;
	padding-top: 8px;
	text-align: right;
	box-sizing: border-box;
}

dd.lastpost .topic-avatars,
.forabg dd.lastpost .topic-avatars,
body.section-viewforum dd.lastpost .last-post-avatar-large {
	position: absolute !important;
	float: none !important;
	left: auto !important;
	right: 4px !important;
	top: 0;
	width: 42px;
	height: 42px;
	margin: 0 !important;
	z-index: 2;
}

body.section-viewforum dd.lastpost .last-post-avatar-large img {
	width: 42px !important;
	height: 42px !important;
	max-width: none !important;
	aspect-ratio: 1 / 1;
	border-radius: 10px;
	object-fit: cover;
	object-position: center;
	border: 1px solid #c8d0d3;
	box-shadow: 1px 1.5px 3px rgba(0, 0, 0, 0.08);
	display: block;
	background: #fff;
	transition: transform 0.15s ease;
}

html.darkmode body.section-viewforum dd.lastpost .last-post-avatar-large img {
	border: 1px solid #2b2f32 !important;
	box-shadow: 1.5px 1.5px 3px rgba(0, 0, 0, 0.28);
	background: #1e2224;
}

dd.lastpost dfn {
	display: none;
}

dd.lastpost .username {
	display: inline;
	vertical-align: baseline;
}

dd.lastpost br {
	display: block;
}

dd.lastpost time {
	display: inline-block;
	margin-top: 2px;
}

.forumbg dd.lastpost > span {
	transform: translateX(92px);
}

/* ==========================================================================
   TABLET (769px - 985px)
   ========================================================================== */

@media (min-width: 769px) and (max-width: 985px) {
	dd.lastpost {
		position: relative;
		width: 234px !important;
		right: calc(-18px - (100vw - 769px)) !important;
		left: auto !important;
		margin-top: 10px !important;
	}

	ul.topiclist dd.lastpost {
		margin-top: 0px !important;
	}

	body.section-viewforum ul.topiclist.topics li.row dt .list-inner {
		padding-left: 58px !important;
		margin-left: 0 !important;
	}

	body.section-viewforum ul.topiclist.topics li.row .first-post-avatar {
		left: 6px;
		top: 6px;
	}

	body.section-viewforum ul.topiclist.topics li.row .first-post-avatar img {
		width: 48px !important;
		height: 48px !important;
	}

	body.section-viewforum dd.lastpost .last-post-avatar-large,
	body.section-viewforum dd.lastpost .last-post-avatar-large img {
		width: 40px !important;
		height: 40px !important;
	}
}

/* ==========================================================================
   MOBILE (<= 768px)
   ========================================================================== */

@media (max-width: 768px) {
	ul.topiclist dd.lastpost br {
		display: none !important;
	}

	.topic-avatars {
		display: block !important;
		width: 21px !important;
		height: 21px !important;
		margin-left: 5px !important;
		margin-right: 0 !important;
		margin-top: 1px !important;
	}

	.topic-avatars .avatar-main {
		left: 0;
	}

	.topic-avatars .avatar-main img {
		width: 21px !important;
		height: 21px !important;
		border-radius: 6px;
	}

	.topic-avatars .avatar-last img {
		width: 12px !important;
		height: 12px !important;
		border-radius: 4px;
	}

	/* Last avatar — larger, still in the right slot */
	dd.lastpost .topic-avatars,
	.forabg dd.lastpost .topic-avatars,
	body.section-viewforum dd.lastpost .last-post-avatar-large {
		display: block !important;
		visibility: visible !important;
		opacity: 1 !important;
		position: absolute !important;
		top: 4px !important;
		left: auto !important;
		right: 4px !important;
		width: 36px !important;
		height: 36px !important;
		margin: 0 !important;
		z-index: 5 !important;
	}

	body.section-viewforum dd.lastpost .last-post-avatar-large img {
		width: 36px !important;
		height: 36px !important;
		min-width: 36px !important;
		min-height: 36px !important;
		max-width: none !important;
		aspect-ratio: 1 / 1;
		border-radius: 8px;
		object-fit: cover;
		object-position: center;
		display: block !important;
	}

	.topic-avatars .avatar-last {
		right: -6px !important;
	}

	dd.lastpost > span,
	.forabg dd.lastpost > span {
		min-height: 40px !important;
		padding-left: 0 !important;
		padding-right: 44px !important;
		padding-top: 4px !important;
		text-align: right !important;
		white-space: normal !important;
	}

	/* Keep lastpost visible */
	ul.topiclist li.row dd.lastpost,
	.forabg dd.lastpost,
	body.section-viewforum ul.topiclist li.row dd.lastpost {
		position: relative !important;
		float: none !important;
		right: auto !important;
		left: auto !important;
		top: auto !important;
		bottom: auto !important;
		transform: none !important;
		width: auto !important;
		max-width: none !important;
		margin: 6px 0 0 0 !important;
		padding: 0 !important;
		box-sizing: border-box !important;
		white-space: normal !important;
		overflow: visible !important;
		display: block !important;
		visibility: visible !important;
	}

	ul.topiclist dd.lastpost,
	dd.lastpost {
		white-space: normal !important;
	}

	ul.topiclist dd.lastpost br,
	dd.lastpost br {
		display: block !important;
	}

	dd.lastpost time {
		display: block !important;
		margin-top: 0px !important;
	}

	.forumbg dd.lastpost > span {
		transform: none !important;
	}

	.forumbg dd.lastpost > span > a[title="Go to last post"],
	.forumbg dd.lastpost > span > a[title="Go to last post"] time {
		margin-left: 0 !important;
		padding-left: 0 !important;
		text-indent: 0 !important;
	}

	dd.lastpost .username,
	dd.lastpost a.username,
	.forabg dd.lastpost .username {
		display: inline-block !important;
		max-width: 86px !important;
		overflow: hidden !important;
		text-overflow: ellipsis !important;
		white-space: nowrap !important;
		vertical-align: middle !important;
	}

	dd.lastpost .lastpost-by {
		display: none !important;
	}

	.forumbg dd.lastpost > span > a[title="Go to last post"],
	dd.lastpost a[title="Go to last post"] {
		display: inline-block !important;
		max-width: none !important;
		overflow: visible !important;
		text-overflow: clip !important;
		white-space: nowrap !important;
		vertical-align: middle !important;
		margin-left: 2px !important;
	}

	/* First avatar on mobile — larger to match taller rows */
	body.section-viewforum ul.topiclist.topics li.row dt {
		min-height: 52px;
	}

	body.section-viewforum ul.topiclist.topics li.row dt .list-inner {
		width: auto !important;
		margin-left: 0 !important;
		padding-left: 56px !important;
		min-height: 48px;
	}

	body.section-viewforum ul.topiclist.topics li.row .first-post-avatar {
		left: 4px;
		top: 6px;
	}

	body.section-viewforum ul.topiclist.topics li.row .first-post-avatar img {
		width: 48px !important;
		height: 48px !important;
		min-width: 48px !important;
		min-height: 48px !important;
		max-width: none !important;
		aspect-ratio: 1 / 1;
		border-radius: 10px;
		object-fit: cover;
		object-position: center;
	}
}