/* ============================================================
   站内 AI 助手 —— 右下角悬浮窗
   与站点现有配色一致（蓝 #4a90e2 / 粉 #ffb3c6）
   注意：宠物固定在 right:20 bottom:18（宽 138），球放在它左边并排
   ============================================================ */

.moe-ai-root {
	--ai-blue: #4a90e2;
	--ai-blue-deep: #2f6fd0;
	--ai-pink: #ffb3c6;
	--ai-ink: #1d2433;
	--ai-sub: #8a94a8;
	--ai-line: #e6ecf6;
	position: fixed;
	right: 200px;
	bottom: 30px;
	z-index: 10010;
	font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* ---------- 悬浮球 ---------- */
.moe-ai-ball {
	width: 56px;
	height: 56px;
	border: 0;
	padding: 0;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(140deg, #6aa8ee 0%, #3b7ddd 55%, #7a6fe0 100%);
	box-shadow: 0 10px 26px rgba(58, 116, 208, .42), 0 2px 6px rgba(58, 116, 208, .22);
	color: #fff;
	position: relative;
	transition: transform .28s cubic-bezier(.3, 1.5, .5, 1), box-shadow .25s ease;
	-webkit-tap-highlight-color: transparent;
}

.moe-ai-ball:hover {
	transform: translateY(-2px) scale(1.05);
	box-shadow: 0 14px 32px rgba(58, 116, 208, .5);
}

.moe-ai-ball:active {
	transform: scale(.96);
}

.moe-ai-ball svg {
	width: 26px;
	height: 26px;
	display: block;
}

/* 呼吸光圈 */
.moe-ai-ball::after {
	content: "";
	position: absolute;
	inset: -6px;
	border-radius: 50%;
	border: 2px solid rgba(120, 170, 240, .5);
	animation: moeAiPulse 2.8s ease-out infinite;
	pointer-events: none;
}

@keyframes moeAiPulse {
	0%   { transform: scale(.86); opacity: .75; }
	70%  { transform: scale(1.18); opacity: 0; }
	100% { transform: scale(1.18); opacity: 0; }
}

.moe-ai-dot {
	position: absolute;
	top: 2px;
	right: 2px;
	width: 11px;
	height: 11px;
	border-radius: 50%;
	background: #ff7d9c;
	border: 2px solid #fff;
	display: none;
}

.moe-ai-root.is-unread .moe-ai-dot {
	display: block;
}

/* ---------- 面板 ---------- */
.moe-ai-panel {
	position: absolute;
	right: 0;
	bottom: 70px;
	width: 400px;
	height: 540px;
	max-height: calc(100vh - 120px);
	background: #fff;
	border-radius: 18px;
	box-shadow: 0 24px 64px rgba(30, 48, 82, .26), 0 4px 14px rgba(30, 48, 82, .1);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transform-origin: right bottom;
	opacity: 0;
	transform: translateY(12px) scale(.96);
	pointer-events: none;
	transition: opacity .22s ease, transform .26s cubic-bezier(.3, 1.3, .5, 1);
	border: 1px solid var(--ai-line);
}

.moe-ai-root.is-open .moe-ai-panel {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}

/* 头部 */
.moe-ai-head {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 14px 16px;
	background: linear-gradient(135deg, #eaf3ff 0%, #f7f0ff 100%);
	border-bottom: 1px solid var(--ai-line);
	flex: 0 0 auto;
}

.moe-ai-avatar {
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background: linear-gradient(140deg, #6aa8ee, #7a6fe0);
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	flex: 0 0 auto;
}

.moe-ai-avatar svg {
	width: 19px;
	height: 19px;
}

.moe-ai-title {
	font-size: 14.5px;
	font-weight: 600;
	color: var(--ai-ink);
	line-height: 1.3;
}

.moe-ai-sub {
	font-size: 11.5px;
	color: var(--ai-sub);
	margin-top: 2px;
}

.moe-ai-close {
	margin-left: auto;
	width: 30px;
	height: 30px;
	border: 0;
	background: transparent;
	border-radius: 8px;
	cursor: pointer;
	color: #93a0b6;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background .18s, color .18s;
	flex: 0 0 auto;
}

.moe-ai-close:hover {
	background: rgba(120, 150, 200, .13);
	color: #5a6a85;
}

.moe-ai-close svg {
	width: 16px;
	height: 16px;
}

/* 消息区 */
.moe-ai-body {
	flex: 1 1 auto;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 16px 16px 8px;
	background: #fff;
	scroll-behavior: smooth;
}

.moe-ai-body::-webkit-scrollbar {
	width: 6px;
}

.moe-ai-body::-webkit-scrollbar-thumb {
	background: #dbe3ef;
	border-radius: 3px;
}

.moe-ai-msg {
	display: flex;
	margin-bottom: 14px;
	animation: moeAiIn .26s ease both;
}

@keyframes moeAiIn {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: translateY(0); }
}

.moe-ai-msg.is-user {
	justify-content: flex-end;
}

.moe-ai-bubble {
	max-width: 82%;
	padding: 10px 13px;
	border-radius: 14px;
	font-size: 14px;
	line-height: 1.68;
	word-break: break-word;
	white-space: pre-wrap;
}

.moe-ai-msg.is-user .moe-ai-bubble {
	background: linear-gradient(135deg, #5a9ceb, #3b7ddd);
	color: #fff;
	border-bottom-right-radius: 5px;
	box-shadow: 0 4px 12px rgba(59, 125, 221, .26);
}

.moe-ai-msg.is-bot .moe-ai-bubble {
	background: #f4f7fc;
	color: var(--ai-ink);
	border-bottom-left-radius: 5px;
	border: 1px solid #eaf0f9;
}

.moe-ai-msg.is-bot .moe-ai-bubble strong {
	font-weight: 600;
	color: #2b3a52;
}

.moe-ai-msg.is-bot .moe-ai-bubble code {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 12.5px;
	background: #e9eff9;
	color: #35507a;
	padding: 1px 5px;
	border-radius: 4px;
}

.moe-ai-msg.is-bot .moe-ai-bubble a {
	color: var(--ai-blue-deep);
	text-decoration: underline;
	text-underline-offset: 2px;
}

/* 打字光标 */
.moe-ai-caret {
	display: inline-block;
	width: 2px;
	height: 1em;
	background: var(--ai-blue);
	vertical-align: -2px;
	margin-left: 2px;
	animation: moeAiBlink 1s steps(2) infinite;
}

@keyframes moeAiBlink {
	0%, 50%  { opacity: 1; }
	50.01%, 100% { opacity: 0; }
}

/* 思考中三个点 */
.moe-ai-typing {
	display: inline-flex;
	gap: 4px;
	align-items: center;
	height: 18px;
}

.moe-ai-typing i {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #b9c7dc;
	animation: moeAiBounce 1.1s ease-in-out infinite;
}

.moe-ai-typing i:nth-child(2) { animation-delay: .16s; }
.moe-ai-typing i:nth-child(3) { animation-delay: .32s; }

@keyframes moeAiBounce {
	0%, 60%, 100% { transform: translateY(0); opacity: .55; }
	30%           { transform: translateY(-4px); opacity: 1; }
}

/* 开场提示 */
.moe-ai-hint {
	font-size: 12.5px;
	color: var(--ai-sub);
	text-align: center;
	line-height: 1.7;
	padding: 6px 10px 14px;
}

.moe-ai-hint b {
	color: var(--ai-blue-deep);
	font-weight: 500;
}

/* 快捷问题 */
.moe-ai-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
	padding: 0 0 14px;
}

.moe-ai-chip {
	border: 1px solid #dbe6f7;
	background: #f7faff;
	color: #4a6b96;
	font-size: 12.5px;
	padding: 6px 11px;
	border-radius: 999px;
	cursor: pointer;
	transition: all .18s;
}

.moe-ai-chip:hover {
	background: #eaf3ff;
	border-color: #b9d3f5;
	color: #2f6fd0;
	transform: translateY(-1px);
}

/* 输入区 */
.moe-ai-foot {
	flex: 0 0 auto;
	padding: 10px 12px 12px;
	border-top: 1px solid var(--ai-line);
	background: #fff;
}

.moe-ai-inputwrap {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	background: #f5f8fd;
	border: 1px solid #e2eaf6;
	border-radius: 14px;
	padding: 7px 7px 7px 13px;
	transition: border-color .2s, box-shadow .2s, background .2s;
}

.moe-ai-inputwrap.is-focus {
	border-color: #9dc2f0;
	background: #fff;
	box-shadow: 0 0 0 3px rgba(120, 170, 240, .16);
}

.moe-ai-input {
	flex: 1 1 auto;
	border: 0;
	background: transparent;
	resize: none;
	outline: none;
	font-size: 14px;
	line-height: 1.6;
	color: var(--ai-ink);
	max-height: 96px;
	min-height: 24px;
	padding: 3px 0;
	font-family: inherit;
}

.moe-ai-input::placeholder {
	color: #a8b3c6;
}

.moe-ai-send {
	flex: 0 0 auto;
	width: 34px;
	height: 34px;
	border: 0;
	border-radius: 11px;
	background: linear-gradient(135deg, #5a9ceb, #3b7ddd);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform .18s, opacity .18s, box-shadow .18s;
	box-shadow: 0 4px 12px rgba(59, 125, 221, .3);
}

.moe-ai-send svg {
	width: 17px;
	height: 17px;
}

.moe-ai-send:hover {
	transform: translateY(-1px);
	box-shadow: 0 7px 16px rgba(59, 125, 221, .4);
}

.moe-ai-send:disabled {
	opacity: .45;
	cursor: not-allowed;
	transform: none;
	box-shadow: none;
}

.moe-ai-tip {
	font-size: 11px;
	color: #b3bdcd;
	text-align: center;
	margin-top: 7px;
}

/* 错误气泡 */
.moe-ai-msg.is-error .moe-ai-bubble {
	background: #fff5f7;
	border: 1px solid #ffdde5;
	color: #a8455e;
}

/* ---------- 小屏：铺满 ---------- */
@media (max-width: 860px) {
	.moe-ai-root {
		right: 132px;
		bottom: 22px;
	}

	/* 面板全屏时，宠物会浮在输入框上面挡住发送按钮 */
	body.moe-ai-open #moe-pet {
		opacity: 0 !important;
		pointer-events: none !important;
	}

	body.moe-ai-open {
		overflow: hidden !important;
	}

	.moe-ai-tip {
		display: none;
	}

	.moe-ai-ball {
		width: 50px;
		height: 50px;
	}

	.moe-ai-ball svg {
		width: 23px;
		height: 23px;
	}

	.moe-ai-panel {
		position: fixed;
		inset: 0;
		width: 100%;
		height: 100%;
		max-height: none;
		border-radius: 0;
		border: 0;
		right: auto;
		bottom: auto;
		transform-origin: center;
	}

	.moe-ai-body {
		padding: 14px 14px 8px;
	}

	.moe-ai-foot {
		padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
	}
}

@media (prefers-reduced-motion: reduce) {
	.moe-ai-ball::after,
	.moe-ai-msg,
	.moe-ai-caret,
	.moe-ai-typing i {
		animation: none !important;
	}
	.moe-ai-panel {
		transition: opacity .15s ease;
	}
}
