/* =========================================================
   站内消息 am_message
   只依赖 bootstrap 4 的基本类和颜色变量，不绑定具体主题
   ========================================================= */

.am-tabbar {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: wrap;
}

.am-tab {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 5px 14px;
	font-size: 14px;
	color: #6c757d;
	background: #f4f4f5;
	border-radius: 16px;
	text-decoration: none;
	transition: background .15s, color .15s;
}

.am-tab:hover {
	background: #ebebee;
	color: #343a40;
	text-decoration: none;
}

.am-tab.is-active {
	background: #343a40;
	color: #fff;
}

.am-tab .am-count {
	min-width: 18px;
	height: 18px;
	padding: 0 5px;
	font-size: 11px;
	line-height: 18px;
	text-align: center;
	color: #fff;
	background: #dc3545;
	border-radius: 9px;
}

.am-tab.is-active .am-count {
	background: rgba(0, 0, 0, .22);
}

/* ---------------- 通知分类 ---------------- */

.am-filter {
	display: flex;
	align-items: center;
	gap: 6px;
	margin: -3px 0 9px;
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scrollbar-width: none;
}
.am-filter::-webkit-scrollbar { display: none; }

.am-filter-item {
	flex: none;
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 3px 10px;
	font-size: 12.5px;
	line-height: 19px;
	color: var(--gs-muted, #6c757d);
	background: var(--gs-card, #fff);
	border: 1px solid var(--gs-line, #e9ecef);
	border-radius: 14px;
	text-decoration: none;
	transition: color .15s, background .15s, border-color .15s;
}
.am-filter-item:hover {
	color: var(--gs-green, #1f7a3d);
	border-color: var(--gs-green, #1f7a3d);
	text-decoration: none;
}
.am-filter-item.is-active {
	color: #fff;
	background: var(--gs-solid, #1f7a3d);
	border-color: transparent;
}
.am-filter-item.is-active:hover { color: #fff; }
.am-filter-count {
	font-size: 11px;
	line-height: 15px;
	font-weight: 600;
}

.am-list-meta {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 0 2px 8px;
	font-size: 12px;
	color: var(--gs-muted, #868e96);
}
.am-list-meta b { font-weight: 600; color: var(--gs-sub, #495057); }
.am-list-unread { color: var(--gs-green, #1f7a3d); }
.am-list-unread b { color: inherit; }

/* ---------------- 通知列表 ---------------- */

.am-noticelist {
	list-style: none;
	margin: 0;
	padding: 0;
}

.am-notice {
	position: relative;
	display: flex;
	gap: 12px;
	padding: 14px 2px;
	border-bottom: 1px solid #f0f0f1;
	box-shadow: inset 3px 0 0 transparent;
	transition: background .15s, box-shadow .15s;
}

.am-notice:last-child {
	border-bottom: 0;
}

.am-notice:hover { background: var(--gs-hover, #fafafa); }

.am-notice.is-unread {
	background: #fbfaf8;
	box-shadow: inset 3px 0 0 var(--gs-green, #2f9e5f);
}

.am-notice.is-unread:hover { background: var(--gs-soft, #f4fbf6); }

.am-notice-avatar {
	flex: 0 0 36px;
}

.am-notice-avatar img {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	object-fit: cover;
	background: #e9ecef;
}

.am-notice-avatar .am-sysicon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	font-size: 16px;
	color: #fff;
	background: #4c6ef5;
	border-radius: 50%;
}

.am-notice-main {
	flex: 1;
	min-width: 0;
}

.am-notice-head {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
	font-size: 13px;
	color: #868e96;
}

.am-notice-name {
	font-weight: 600;
	color: #343a40;
}

.am-notice-type {
	padding: 1px 7px;
	font-size: 11px;
	color: #5c7cfa;
	background: #edf2ff;
	border-radius: 8px;
}

.am-notice-type.is-reply { color: #0b7285; background: #e3fafc; }
.am-notice-type.is-quote { color: #6741d9; background: #f3f0ff; }
.am-notice-type.is-admin { color: #c92a2a; background: #fff5f5; }

.am-notice-dot {
	width: 7px;
	height: 7px;
	background: #dc3545;
	border-radius: 50%;
}

.am-notice-time {
	color: var(--gs-muted, #868e96);
}

.am-notice-link {
	display: block;
	margin: 4px 0 2px;
	color: inherit;
	text-decoration: none;
	border-radius: 4px;
}
.am-notice-link:hover { text-decoration: none; color: inherit; }
.am-notice-link:focus-visible {
	outline: 2px solid var(--gs-green, #2f9e5f);
	outline-offset: 3px;
}

.am-notice-subject {
	font-size: 14.5px;
	font-weight: 600;
	color: #343a40;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	transition: color .15s;
}
.am-notice-link:hover .am-notice-subject { color: var(--gs-green, #2f9e5f); }

.am-notice-subject a {
	color: inherit;
	text-decoration: none;
}

.am-notice-subject a:hover {
	color: #2f9e5f;
	text-decoration: underline;
}

.am-notice-body {
	margin-top: 2px;
	font-size: 13.5px;
	line-height: 1.6;
	color: #495057;
	word-break: break-word;
	overflow-wrap: anywhere;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	overflow: hidden;
}

.am-notice-foot {
	display: flex;
	align-items: center;
	gap: 14px;
	margin-top: 7px;
	font-size: 12.5px;
}

.am-notice-foot a {
	color: #5c7cfa;
}

.am-notice-go { text-decoration: none; }
.am-notice-go:hover { text-decoration: underline; }
.st-theme .am-notice-foot a { color: var(--gs-green, #1f7a3d); }

.am-link-danger:hover { color: #dc3545; }

.am-link-muted {
	color: #adb5bd;
	background: none;
	border: 0;
	padding: 0;
	cursor: pointer;
}

.am-link-muted:hover {
	color: #868e96;
}

/* ---------------- 私信会话列表 ---------------- */

.am-sessions {
	list-style: none;
	margin: 0;
	padding: 0;
}

.am-session {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 13px 2px;
	border-bottom: 1px solid #f0f0f1;
	color: inherit;
	text-decoration: none;
}

.am-session:last-child { border-bottom: 0; }
.am-session:hover { background: #fbfaf8; text-decoration: none; color: inherit; }

.am-session img {
	width: 42px;
	height: 42px;
	border-radius: 50%;
	object-fit: cover;
	background: #e9ecef;
}

.am-session-main { flex: 1; min-width: 0; }

.am-session-top {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 10px;
}

.am-session-name {
	font-size: 14.5px;
	font-weight: 600;
	color: #343a40;
}

.am-session-date {
	font-size: 12px;
	color: #adb5bd;
	flex: none;
}

.am-session-last {
	margin-top: 2px;
	font-size: 13px;
	color: #868e96;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.am-session-unread {
	flex: none;
	min-width: 18px;
	height: 18px;
	padding: 0 5px;
	font-size: 11px;
	line-height: 18px;
	text-align: center;
	color: #fff;
	background: #dc3545;
	border-radius: 9px;
}

/* ---------------- 对话页 ---------------- */

.am-chat-head {
	display: flex;
	align-items: center;
	gap: 10px;
	padding-bottom: 12px;
	margin-bottom: 4px;
	border-bottom: 1px solid #f0f0f1;
}

.am-chat-head img {
	width: 34px;
	height: 34px;
	border-radius: 50%;
	object-fit: cover;
	background: #e9ecef;
}

.am-chat-head b { font-size: 14.5px; color: #343a40; }

.am-chat-scroll {
	/* 固定高度：消息再少也不塌，再多也不撑高，只在框内滚 */
	height: 460px;
	display: flex;
	flex-direction: column;
	overflow-y: auto;
	padding: 14px 2px 6px;
	scroll-behavior: smooth;
	overscroll-behavior: contain;
}

/* 消息少的时候贴底堆叠（和聊天软件一致），而不是浮在顶部 */
.am-chat-scroll > .am-msg:first-child { margin-top: auto; }

/* 还没聊过：图标和文字在框内居中 */
.am-chat-scroll > .am-empty { margin: auto; padding: 0; }

.am-msg {
	display: flex;
	gap: 10px;
	margin-bottom: 14px;
}

.am-msg img {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	object-fit: cover;
	background: #e9ecef;
	flex: none;
}

.am-msg-main { max-width: 76%; }

.am-msg-meta {
	font-size: 12px;
	color: #adb5bd;
	margin-bottom: 3px;
}

.am-bubble {
	padding: 9px 13px;
	font-size: 14px;
	line-height: 1.65;
	color: #343a40;
	background: #f4f4f5;
	border-radius: 4px 12px 12px 12px;
	word-break: break-word;
	white-space: pre-wrap;
}

.am-msg.is-me {
	flex-direction: row-reverse;
}

.am-msg.is-me .am-msg-main { text-align: right; }

.am-msg.is-me .am-bubble {
	text-align: left;
	color: #fff;
	background: #343a40;
	border-radius: 12px 4px 12px 12px;
}

.am-chat-form {
	display: flex;
	gap: 10px;
	align-items: flex-end;
	padding-top: 12px;
	border-top: 1px solid #f0f0f1;
}

.am-chat-form textarea {
	flex: 1;
	min-height: 44px;
	max-height: 140px;
	padding: 11px 13px;
	font-size: 14px;
	line-height: 1.6;
	color: #343a40;
	background: #f8f8f9;
	border: 1px solid #e9ecef;
	border-radius: 10px;
	resize: none;
	outline: 0;
	transition: border-color .15s, background .15s;
}

.am-chat-form textarea:focus {
	background: #fff;
	border-color: #ced4da;
}

.am-btn-send {
	flex: none;
	height: 44px;
	padding: 0 20px;
	font-size: 14px;
	font-weight: 600;
	color: #fff;
	background: #343a40;
	border: 0;
	border-radius: 10px;
	cursor: pointer;
	transition: opacity .15s;
}

.am-btn-send:hover { opacity: .88; }
.am-btn-send:disabled { opacity: .5; cursor: default; }

.am-empty {
	padding: 48px 0;
	text-align: center;
	color: #adb5bd;
	font-size: 14px;
}

.am-empty i { display: block; font-size: 34px; margin-bottom: 10px; opacity: .5; }
.am-empty p { margin: 0 0 3px; font-size: 14px; font-weight: 600; color: var(--gs-sub, #495057); }
.am-empty > span { display: block; font-size: 12.5px; color: var(--gs-muted, #868e96); }
.am-empty .am-empty-actions { margin-top: 12px; }

@media (max-width: 767px) {
	/* 手机上同样固定，按视口扣掉顶栏/对方信息/输入框的高度 */
	.am-chat-scroll { height: calc(100vh - 300px); min-height: 280px; }
	.am-msg-main { max-width: 84%; }
	.am-notice-subject { white-space: normal; }
	.am-notice { padding: 12px 0; gap: 10px; }
	.am-notice-avatar { flex-basis: 32px; }
	.am-notice-avatar img,
	.am-notice-avatar .am-sysicon { width: 32px; height: 32px; }
	.am-notice-avatar .am-sysicon { font-size: 14px; }
	.am-notice-body { -webkit-line-clamp: 2; }
	.am-notice-foot { gap: 16px; }
	.am-notice-foot a,
	.am-notice-foot .am-link-muted { padding: 4px 0; }
	.am-filter { flex-wrap: wrap; margin-bottom: 7px; overflow: visible; }
	.am-tab { padding: 4px 10px; }
	#am-readall { padding: 0 8px; }
}

/* ---------------- 页面外壳：不依赖主题的个人中心模板 ---------------- */

.am-page {
	width: 100%;
	max-width: 880px;
	margin: 0 auto;
	padding: 4px 0 12px;
}

.am-card {
	background: var(--card, #fff);
	border: 1px solid var(--line, #e9ecef);
	border-radius: 8px;
	overflow: hidden;
}

.am-card-head {
	padding: 12px 16px;
	border-bottom: 1px solid var(--line, #f0f0f1);
}

.am-card-body {
	padding: 4px 16px 14px;
}

@media (max-width: 767px) {
	.am-page { padding: 0 10px 10px; }
	.am-card-head { padding: 10px 12px; }
	.am-card-body { padding: 2px 12px 10px; }
}

/* panther 顶栏的消息图标 */
.am-pt-msg { position: relative; text-decoration: none; }

.am-pt-badge {
	position: absolute;
	top: 1px;
	right: 0;
	min-width: 15px;
	height: 15px;
	padding: 0 4px;
	font-family: var(--mono, inherit);
	font-size: 10px;
	font-weight: 700;
	line-height: 15px;
	text-align: center;
	color: #fff;
	background: var(--red, #e03131);
	border-radius: 8px;
}

/* ---------------- 私信增强 ---------------- */

.am-pm-toolbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 4px 2px 10px;
	margin-bottom: 2px;
	font-size: 12.5px;
	color: #868e96;
	border-bottom: 1px solid #f0f0f1;
}
.am-pm-toolbar b { color: #343a40; }
.am-inline-form { margin: 0; }

.am-session.is-unread .am-session-name { color: #212529; font-weight: 700; }
.am-session.is-unread .am-session-last { color: #495057; }
.am-session-me { color: #adb5bd; }

.am-chat-head-links { display: flex; align-items: center; justify-content: flex-end; gap: 12px; flex-wrap: wrap; }
.am-chat-head-links a { text-decoration: none; }
.am-chat-head-links a:hover { color: #343a40; }
.am-chat-back { flex: none; font-size: 18px; line-height: 1; color: #868e96; text-decoration: none; }
.am-chat-back:hover { color: #343a40; text-decoration: none; }

.am-chat-day { margin: 10px 0 14px; text-align: center; }
.am-chat-day span {
	display: inline-block;
	padding: 2px 10px;
	font-size: 11.5px;
	color: #adb5bd;
	background: #f4f4f5;
	border-radius: 10px;
}

.am-chat-input-wrap { flex: 1; min-width: 0; }
.am-chat-form textarea { width: 100%; display: block; }
.am-empty-actions { margin-top: 10px; font-size: 13px; }
.am-empty-actions a { color: #5c7cfa; text-decoration: none; }
.am-empty-actions a:hover { text-decoration: underline; }
/* 有日期分隔时，第一条日期标签也贴底堆叠 */
.am-chat-scroll > .am-chat-day:first-child { margin-top: auto; }
/* 对比度：消息中心的标签、时间、辅助文字 */
.am-tab { color: #495057; font-weight: 500; }
.am-tab:hover { color: #212529; }
.am-session-date { color: #6c757d; }
.am-session-last { color: #6c757d; }
.am-notice-head { color: #6c757d; }
.am-notice-body { color: #343a40; }
.am-msg-meta { color: #6c757d; }
.am-empty { color: #6c757d; }
.am-link-muted { color: #6c757d; }
.am-link-muted:hover { color: #343a40; }
/* 链接色提高对比度 */
.am-notice-foot a,
.am-empty-actions a { color: #3b5bdb; }
/* ---------------- 私信：列表 + 聊天合并成一个大框 ---------------- */

.am-messenger {
	display: flex;
	flex-direction: column;
	height: calc(100vh - 150px);
	min-height: 560px;
	max-height: 820px;
	background: var(--gs-card, #fff);
	border: 1px solid var(--gs-line, #e9ecef);
	border-radius: 12px;
	overflow: hidden;
	box-shadow: 0 3px 12px rgba(0, 0, 0, .06);
}
.am-ms-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	flex-wrap: wrap;
	padding: 14px 20px;
	border-bottom: 1px solid var(--gs-line-light, #f0f0f1);
}
.am-ms-head h1 { margin: 0; font-size: 18px; font-weight: 600; color: var(--gs-text, #343a40); }
.am-ms-body { display: flex; flex: 1; min-height: 0; }

.am-ms-list {
	width: 310px;
	flex: none;
	padding: 8px 12px 12px;
	overflow-y: auto;
	border-right: 1px solid var(--gs-line-light, #f0f0f1);
}
.am-ms-list-head {
	position: sticky;
	top: -8px;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 8px 4px;
	margin: 0 -4px 2px;
	font-size: 12.5px;
	color: var(--gs-muted, #868e96);
	background: var(--gs-card, #fff);
	border-bottom: 1px solid var(--gs-line-light, #f2f2f2);
}
.am-ms-list-head b { color: var(--gs-text, #343a40); font-weight: 600; }
.am-ms-sessions .am-session { padding: 10px 8px; border-radius: 8px; border-bottom: 0; }
.am-ms-sessions .am-session:hover { background: var(--gs-line-light, #f7f7f7); }
.am-ms-sessions .am-session.is-active { background: var(--gs-soft, #eef7ef); }
.am-ms-sessions .am-session.is-active .am-session-name { color: var(--gs-green, #1f7a3d); }
.am-ms-list-pager { margin-top: 8px; font-size: 12px; text-align: center; }
.am-ms-list-pager a { color: var(--gs-muted, #868e96); }
.am-ms-list-empty { padding: 60px 10px; text-align: center; color: var(--gs-muted, #868e96); font-size: 13px; }
.am-ms-list-empty i { display: block; margin-bottom: 8px; font-size: 30px; opacity: .5; }
.am-ms-list-empty p { margin: 0 0 4px; font-weight: 600; color: var(--gs-sub, #495057); }
.am-ms-list-empty span { font-size: 12px; }

.am-ms-chat { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.am-ms-chat .am-chat-head { padding: 12px 16px 10px; margin: 0; }
.am-ms-chat .am-chat-scroll { flex: 1; height: auto; min-height: 0; padding: 10px 16px 6px; }
.am-ms-chat .am-chat-form { padding: 10px 16px 14px; }
.am-ms-placeholder { align-items: center; justify-content: center; text-align: center; color: var(--gs-muted, #adb5bd); }
.am-ms-empty i { display: block; margin-bottom: 10px; font-size: 38px; opacity: .4; }
.am-ms-empty p { margin: 0 0 4px; font-size: 14px; color: var(--gs-sub, #495057); }
.am-ms-empty span { font-size: 12px; color: var(--gs-muted, #868e96); }

@media (max-width: 767px) {
	.am-messenger { height: calc(100vh - 110px); min-height: 480px; border-radius: 10px; }
	.am-ms-head { padding: 10px 12px; }
	.am-ms-head h1 { font-size: 16px; }
	.am-ms-list { width: 100%; border-right: 0; }
	.am-messenger.has-chat .am-ms-list { display: none; }
	.am-messenger:not(.has-chat) .am-ms-chat { display: none; }
	.am-ms-chat .am-chat-head { padding: 10px 12px 8px; }
	.am-ms-chat .am-chat-scroll { padding: 8px 12px 4px; }
	.am-ms-chat .am-chat-form { padding: 8px 12px 10px; }
}
/* 会话列表 */
.am-session-row { display: flex; align-items: center; }
.am-session-row .am-session { flex: 1; min-width: 0; }
/* 删除会话保在右侧聊天头部，列表不再重复放删除按钮 */
.am-chat-del-form { display: inline; margin: 0; }
/* 拉黑状态 */
.am-ms-chat.is-blocked .am-chat-form { display: none; }
.am-chat-blocked {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	flex-wrap: wrap;
	padding: 16px;
	margin: 10px 16px 14px;
	font-size: 13px;
	color: var(--gs-muted, #868e96);
	border-top: 1px solid var(--gs-line-light, #f0f0f1);
}
.am-chat-blocked form { margin: 0; }
.am-chat-block-form { display: inline; margin: 0; }
.am-chat-head-links .am-chat-block-form button { font-size: 12px; }
/* ===== 移动端私信对话优化 ===== */
@media (max-width: 767px) {
	body.route-message .gs-shell { padding-bottom: 0; }
	.am-messenger {
		height: calc(100vh - 125px - env(safe-area-inset-bottom, 0px));
		height: calc(100dvh - 125px - env(safe-area-inset-bottom, 0px));
		min-height: 0;
		max-height: none;
		border-radius: 10px;
	}
	.am-ms-head { padding: 8px 12px; justify-content: center; }
	.am-ms-head h1 { display: none; }
	.am-ms-head .am-tabbar { width: 100%; justify-content: center; }

	.am-chat-head { padding: 10px 12px 8px; gap: 8px; }
	.am-chat-head img { width: 32px; height: 32px; }
	.am-chat-head b { font-size: 14px; }
	.am-chat-head-links { gap: 8px; font-size: 12px; }
	.am-chat-profile-link { display: none; }
	.am-chat-back {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 28px;
		height: 28px;
		margin-left: -4px;
		font-size: 20px;
	}
	.am-ms-chat .am-chat-scroll { padding: 8px 12px 4px; }
	.am-chat-scroll > .am-msg:first-child,
	.am-chat-scroll > .am-chat-day:first-child { margin-top: 0; }

	.am-ms-chat .am-chat-form { padding: 8px 12px 10px; gap: 8px; }
	.am-chat-form textarea {
		min-height: 44px;
		padding: 9px 12px;
		font-size: 16px;
		line-height: 1.5;
	}
	.am-btn-send { height: 44px; padding: 0 16px; }

	body.route-message:has(.am-messenger.has-chat) { overflow: hidden; }
	body.route-message:has(.am-messenger.has-chat) #footer { display: none; }
}