/* ==========================================================================
   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;
}

/* Forumlist (index) only – rounded square to match viewforum avatars */
body.section-index .topic-avatars .avatar-main img,
body.section-index .forabg .topic-avatars .avatar-main img,
body.section-index .forumbg .topic-avatars .avatar-main img {
	border-radius: 10px !important;
}

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

/* Forumlist only – shape change only, sizes stay the same */
body.section-index .topic-avatars .avatar-last img,
body.section-index .forabg .topic-avatars .avatar-last img,
body.section-index .forumbg .topic-avatars .avatar-last img {
	border-radius: 7px !important;
}

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: -6px !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;
}

body.section-viewforum ul.topiclist.topics li.row dt .list-inner {
	padding-left: 70px !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: 8px;
	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 BASE & AVATAR STYLING
   ========================================================================== */

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

body.section-viewforum dd.lastpost .last-post-avatar-large img {
	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;
}

/* ==========================================================================
   DESKTOP & TABLET (>= 769px): 2-Line Right-Aligned Meta + Right Avatar
   ========================================================================== */

@media (min-width: 769px) {
	body.section-viewforum dd.lastpost {
		white-space: normal !important;
	}

	body.section-viewforum dd.lastpost br {
		display: none !important;
	}

	body.section-viewforum dd.lastpost > span.rs-lastpost-wrap,
	body.section-viewforum dd.lastpost .rs-lastpost-wrap {
		display: flex !important;
		align-items: center !important;
		justify-content: flex-end !important;
		gap: 8px !important;
		min-height: 42px !important;
		padding: 4px 4px 4px 0 !important;
		transform: none !important;
		white-space: nowrap !important;
		box-sizing: border-box !important;
	}

	body.section-viewforum dd.lastpost .rs-lastpost-meta {
		display: flex !important;
		flex-direction: column !important;
		align-items: flex-end !important;
		order: 1 !important;
		line-height: 1.25 !important;
		text-align: right !important;
	}

	body.section-viewforum dd.lastpost .rs-lastpost-author {
		display: inline-flex !important;
		align-items: center !important;
		justify-content: flex-end !important;
		white-space: nowrap !important;
	}

	body.section-viewforum dd.lastpost .rs-lastpost-author .username,
	body.section-viewforum dd.lastpost .rs-lastpost-author a.username,
	body.section-viewforum dd.lastpost .rs-lastpost-author .username-coloured,
	body.section-viewforum dd.lastpost .rs-lastpost-author a.username-coloured,
	body.section-viewforum dd.lastpost .rs-lastpost-author span.username-coloured {
		display: inline !important;
		white-space: nowrap !important;
		vertical-align: middle !important;
		max-width: none !important;
		margin: 0 !important;
	}

	body.section-viewforum dd.lastpost .rs-lastpost-author a[title="Go to last post"] {
		display: inline-flex !important;
		align-items: center !important;
		vertical-align: middle !important;
		margin-left: 3px !important;
		white-space: nowrap !important;
	}

	body.section-viewforum dd.lastpost .rs-lastpost-meta time {
		display: block !important;
		margin-top: 2px !important;
		line-height: 1.2 !important;
		white-space: nowrap !important;
	}

	body.section-viewforum dd.lastpost .last-post-avatar-large {
		position: static !important;
		transform: none !important;
		order: 2 !important;
		flex-shrink: 0 !important;
		width: 42px !important;
		height: 42px !important;
		margin: 0 !important;
	}

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

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

@media (min-width: 769px) and (max-width: 985px) {
	dd.lastpost {
		position: relative;
		width: 234px !important;
		right: calc(-59px - (100vw - 769px)) !important;
		left: auto !important;
		margin-top: 0 !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;
	}
}

/* ==========================================================================
   <= 985px — FIRST AVATAR ALIGNMENT
   ========================================================================== */

@media (max-width: 985px) {
	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: 0;
		top: 10px;
	}

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

	body.section-viewforum ul.topiclist.topics li.row .topictitle,
	body.section-viewforum ul.topiclist.topics li.row .topic-poster {
		margin-top: 2px;
	}
}

/* ==========================================================================
   MOBILE (<= 768px): 2-Line Right-Aligned Meta + Right Avatar
   ========================================================================== */

@media (max-width: 768px) {
	/* Shared mini .topic-avatars on mobile */
	.topic-avatars {
		display: block !important;
		width: 21px !important;
		height: 21px !important;
		margin: 1px 0 0 5px !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 {
		right: -6px !important;
	}

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

	/* First avatar on mobile */

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

	body.section-viewforum ul.topiclist.topics li.row .first-post-avatar {
		left: -8px;
		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;
		margin-top: 2px;
	}

/* Uniform mobile grid row: dt spans full top row, stats on bottom-left, lastpost on bottom-right */
	body.section-viewforum ul.topiclist.topics li.row dl {
		display: grid !important;
		grid-template-columns: 1fr auto !important;
		align-items: center !important;
		row-gap: 6px !important;
		overflow: visible !important;
	}

	body.section-viewforum ul.topiclist.topics li.row dt {
		grid-column: 1 / -1 !important;
		grid-row: 1 !important;
		width: 100% !important;
		float: none !important;
	}

	body.section-viewforum ul.topiclist.topics li.row dd.posts,
	body.section-viewforum ul.topiclist.topics li.row dd.views {
		grid-column: 1 !important;
		grid-row: 2 !important;
		float: none !important;
		text-align: left !important;
		align-self: center !important;
	}

	body.section-viewforum ul.topiclist.topics li.row dd.views {
		margin-left: 72px !important;
	}

	/* Lastpost container stays in flow on bottom-right — never clipped, always aligned */
	ul.topiclist li.row dd.lastpost,
	.forabg dd.lastpost,
	body.section-viewforum ul.topiclist li.row dd.lastpost,
	body.section-viewforum dd.lastpost {
		grid-column: 2 !important;
		grid-row: 2 !important;
		justify-self: end !important;
		align-self: center !important;
		position: relative !important;
		float: none !important;
		right: auto !important;
		left: auto !important;
		top: auto !important;
		bottom: auto !important;
		transform: translateY(-21px) !important;
		width: auto !important;
		max-width: none !important;
		margin: 0 !important;
		padding: 0 !important;
		box-sizing: border-box !important;
		overflow: visible !important;
		display: block !important;
		visibility: visible !important;
	}

	body.section-viewforum dd.lastpost br {
		display: none !important;
	}

	body.section-viewforum dd.lastpost > span.rs-lastpost-wrap,
	body.section-viewforum dd.lastpost .rs-lastpost-wrap {
		display: flex !important;
		align-items: center !important;
		justify-content: flex-end !important;
		gap: 8px !important;
		white-space: nowrap !important;
		box-sizing: border-box !important;
		margin-bottom: -8px;
		padding-top: 16px !important;
	}

	body.section-viewforum dd.lastpost .rs-lastpost-meta {
		display: flex !important;
		flex-direction: column !important;
		align-items: flex-end !important;
		order: 1 !important;
		line-height: 1.2 !important;
		text-align: right !important;
	}

	body.section-viewforum dd.lastpost .rs-lastpost-author {
		display: inline-flex !important;
		align-items: center !important;
		justify-content: flex-end !important;
		white-space: nowrap !important;
	}

	body.section-viewforum dd.lastpost .rs-lastpost-author .username,
	body.section-viewforum dd.lastpost .rs-lastpost-author a.username,
	body.section-viewforum dd.lastpost .rs-lastpost-author .username-coloured,
	body.section-viewforum dd.lastpost .rs-lastpost-author a.username-coloured,
	body.section-viewforum dd.lastpost .rs-lastpost-author span.username-coloured {
		display: inline !important;
		white-space: nowrap !important;
		vertical-align: middle !important;
		max-width: none !important;
		margin: 0 !important;
	}

	body.section-viewforum dd.lastpost .rs-lastpost-author a[title="Go to last post"] {
		display: inline-flex !important;
		align-items: center !important;
		vertical-align: middle !important;
		margin-left: 3px !important;
		white-space: nowrap !important;
	}

	body.section-viewforum dd.lastpost .rs-lastpost-meta time {
		display: block !important;
		margin-top: 1px !important;
		white-space: nowrap !important;
		line-height: 1.2 !important;
	}

	body.section-viewforum dd.lastpost .last-post-avatar-large {
		position: static !important;
		transform: none !important;
		order: 2 !important;
		flex-shrink: 0 !important;
		width: 36px !important;
		height: 36px !important;
		margin: 0 !important;
		visibility: visible !important;
		opacity: 1 !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;
		border-radius: 8px;
	}
}
@media (max-width: 768px) {
    body.section-viewforum ul.topiclist.topics li.row {
        min-height: 0 !important;
        padding-bottom: 0 !important;
    }
}