/* ===== AI 阅读助手 ===== */

:root {
	--zc-ai-c1: var(--theme-color, #3b82f6);
	--zc-ai-c2: var(--focus-color, #8b5cf6);
	--zc-ai-radius: 16px;
}

/* ---------- 引言块内的摘要 ---------- */

.zc-ai-summary p { margin: 0 0 .6em; }
.zc-ai-summary p:last-of-type { margin-bottom: 0; }

/* ---------- 长条按钮 ---------- */

.zc-ai-chat-btn,
.quote_q .zc-ai-chat-btn,
.wp-block-zibllblock-quote .zc-ai-chat-btn {
	display: flex !important;
	align-items: center;
	justify-content: center;
	gap: 7px;
	box-sizing: border-box !important;
	width: 100% !important;
	max-width: none !important;
	min-width: 0;
	height: auto !important;
	margin: 14px 0 0 !important;
	padding: 7px 18px !important;
	border: 0 !important;
	border-radius: 999px !important;
	cursor: pointer;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.45;
	text-align: center;
	text-decoration: none !important;
	color: #fff !important;
	background: linear-gradient(100deg, var(--zc-ai-c1), var(--zc-ai-c2)) !important;
	box-shadow: 0 4px 14px -5px var(--zc-ai-c1);
	transition: transform .2s ease, box-shadow .2s ease, filter .2s ease;
	-webkit-appearance: none;
	appearance: none;
	pointer-events: auto !important;
	position: relative;
	z-index: 3;
}

/* .quote_q 的 ::before 装饰层和绝对定位的引号图标会浮在按钮上面挡住鼠标，
   让它们不接收指针事件，按钮整块才点得到 */
.quote_q { position: relative; }
.quote_q::before,
.quote_q > .fa,
.quote_q > i,
.wp-block-zibllblock-quote::before {
	pointer-events: none !important;
}

/* 让点击永远落在按钮本身，而不是里面的文字节点 */
.zc-ai-chat-btn > * { pointer-events: none; }

.zc-ai-chat-btn:hover {
	transform: translateY(-1px);
	box-shadow: 0 8px 22px -6px var(--zc-ai-c1);
	filter: saturate(1.15);
}

.zc-ai-chat-btn:active { transform: translateY(0); }

.zc-ai-chat-btn:focus-visible {
	outline: 2px solid var(--zc-ai-c1);
	outline-offset: 3px;
}

.zc-ai-chat-btn-ico {
	font-size: 13px;
	animation: zc-ai-twinkle 2.6s ease-in-out infinite;
}

@keyframes zc-ai-twinkle {
	0%, 100% { opacity: .55; transform: scale(.9); }
	50%      { opacity: 1;   transform: scale(1.15); }
}

/* ---------- 弹窗 ---------- */

body.zc-ai-lock { overflow: hidden; }

.zc-ai-modal {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: none;
}

.zc-ai-modal.show { display: block; }

.zc-ai-mask {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, .45);
	backdrop-filter: blur(2px);
	animation: zc-ai-fade .2s ease;
}

@keyframes zc-ai-fade { from { opacity: 0; } to { opacity: 1; } }

.zc-ai-panel {
	position: absolute;
	right: 24px;
	bottom: 24px;
	display: flex;
	flex-direction: column;
	width: 400px;
	max-width: calc(100vw - 32px);
	height: 620px;
	max-height: calc(100vh - 48px);
	overflow: hidden;
	border-radius: var(--zc-ai-radius);
	background: var(--main-bg-color, #fff);
	box-shadow: 0 24px 60px -12px rgba(0, 0, 0, .35);
	animation: zc-ai-up .28s cubic-bezier(.22, 1, .36, 1);
}

@keyframes zc-ai-up {
	from { opacity: 0; transform: translateY(24px) scale(.97); }
	to   { opacity: 1; transform: none; }
}

/* 头部 */

.zc-ai-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 16px;
	color: #fff;
	background: linear-gradient(100deg, var(--zc-ai-c1), var(--zc-ai-c2));
}

.zc-ai-head-t {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 15px;
	font-weight: 600;
}

.zc-ai-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #4ade80;
	box-shadow: 0 0 0 0 rgba(74, 222, 128, .7);
	animation: zc-ai-pulse 2s infinite;
}

@keyframes zc-ai-pulse {
	70%  { box-shadow: 0 0 0 7px rgba(74, 222, 128, 0); }
	100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

.zc-ai-close {
	border: 0;
	background: transparent;
	color: #fff;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	opacity: .8;
	padding: 0 4px;
}

.zc-ai-close:hover { opacity: 1; }

/* 消息区 */

.zc-ai-body {
	flex: 1;
	overflow-y: auto;
	padding: 16px 14px;
	background: var(--body-bg-color, #f5f6f7);
	-webkit-overflow-scrolling: touch;
}

.zc-ai-row {
	display: flex;
	margin-bottom: 14px;
}

.zc-ai-row.zc-ai-me { justify-content: flex-end; }

.zc-ai-bubble {
	position: relative;
	max-width: 80%;
	padding: 10px 13px;
	border-radius: 12px;
	font-size: 14.5px;
	line-height: 1.72;
	white-space: pre-wrap;
	word-break: break-word;
	animation: zc-ai-pop .2s ease;
}

@keyframes zc-ai-pop {
	from { opacity: 0; transform: translateY(4px); }
	to   { opacity: 1; transform: none; }
}

.zc-ai-ai .zc-ai-bubble {
	background: var(--main-bg-color, #fff);
	color: var(--main-color, #2c2c2c);
	border-top-left-radius: 3px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, .07);
}

.zc-ai-me .zc-ai-bubble {
	background: linear-gradient(100deg, var(--zc-ai-c1), var(--zc-ai-c2));
	color: #fff;
	border-top-right-radius: 3px;
}

/* 流式光标 */

.zc-ai-bubble.zc-ai-streaming::after {
	content: '';
	display: inline-block;
	width: 2px;
	height: 1em;
	margin-left: 2px;
	vertical-align: -.15em;
	background: currentColor;
	animation: zc-ai-caret 1s steps(2) infinite;
}

@keyframes zc-ai-caret { 50% { opacity: 0; } }

/* 输入中 */

.zc-ai-typing { display: flex; gap: 5px; padding: 14px 15px; }

.zc-ai-typing i {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: currentColor;
	opacity: .35;
	animation: zc-ai-bounce 1.3s infinite;
}

.zc-ai-typing i:nth-child(2) { animation-delay: .18s; }
.zc-ai-typing i:nth-child(3) { animation-delay: .36s; }

@keyframes zc-ai-bounce {
	0%, 60%, 100% { transform: translateY(0);    opacity: .35; }
	30%           { transform: translateY(-5px); opacity: .85; }
}

/* 快捷问题 */

.zc-ai-quick {
	display: flex;
	gap: 8px;
	padding: 0 14px 10px;
	overflow-x: auto;
	background: var(--body-bg-color, #f5f6f7);
	scrollbar-width: none;
}

.zc-ai-quick::-webkit-scrollbar { display: none; }

.zc-ai-quick.hide { display: none; }

.zc-ai-quick button {
	flex: 0 0 auto;
	padding: 6px 13px;
	border: 1px solid var(--main-border-color, rgba(128, 128, 128, .25));
	border-radius: 999px;
	background: transparent;
	color: var(--main-color, #444);
	font-size: 13px;
	cursor: pointer;
	transition: all .18s;
}

.zc-ai-quick button:hover {
	border-color: var(--zc-ai-c1);
	color: var(--zc-ai-c1);
}

/* 输入区 */

.zc-ai-foot {
	display: flex;
	align-items: flex-end;
	gap: 10px;
	padding: 10px 14px 14px;
	background: var(--main-bg-color, #fff);
	border-top: 1px solid var(--main-border-color, rgba(128, 128, 128, .15));
}

.zc-ai-foot textarea {
	flex: 1;
	max-height: 110px;
	min-height: 40px;
	padding: 9px 13px;
	border: 1px solid var(--main-border-color, rgba(128, 128, 128, .25));
	border-radius: 20px;
	background: var(--body-bg-color, #f5f6f7);
	color: var(--main-color, #2c2c2c);
	font-family: inherit;
	font-size: 14.5px;
	line-height: 1.5;
	resize: none;
	outline: none;
	transition: border-color .18s;
}

.zc-ai-foot textarea:focus { border-color: var(--zc-ai-c1); }

.zc-ai-send {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border: 0;
	border-radius: 50%;
	color: #fff;
	background: linear-gradient(100deg, var(--zc-ai-c1), var(--zc-ai-c2));
	cursor: pointer;
	transition: opacity .18s, transform .18s;
}

.zc-ai-send:hover:not(:disabled) { transform: scale(1.06); }
.zc-ai-send:disabled { opacity: .45; cursor: not-allowed; }

/* 移动端：底部抽屉 */

@media (max-width: 768px) {
	.zc-ai-panel {
		right: 0;
		bottom: 0;
		left: 0;
		width: 100%;
		max-width: none;
		height: 82vh;
		border-radius: var(--zc-ai-radius) var(--zc-ai-radius) 0 0;
	}
	.zc-ai-bubble { max-width: 86%; }
}

@media (prefers-reduced-motion: reduce) {
	.zc-ai-panel,
	.zc-ai-bubble,
	.zc-ai-mask,
	.zc-ai-chat-btn-ico,
	.zc-ai-dot { animation: none !important; }
	.zc-ai-chat-btn { transition: none; }
}

/* 文章没有引言块时，自动补的引言框 */
.zc-ai-quote-box {
	position: relative;
	margin: 0 0 24px;
	padding: 20px 22px;
	border-radius: 12px;
	background: var(--body-bg-color, rgba(128, 128, 128, .07));
	border-left: 3px solid var(--zc-ai-c1);
	line-height: 1.85;
}

/* 摘要与按钮现在都在 .quote_q 灰底框内部 */
.quote_q > p:last-of-type { margin-bottom: 0; }

/* ---------- 滚动条：去掉浏览器默认白底 ---------- */

.zc-ai-body,
.zc-ai-foot textarea,
.zc-ai-panel {
	scrollbar-width: thin;
	scrollbar-color: rgba(140, 140, 140, .4) transparent;
}

.zc-ai-body::-webkit-scrollbar,
.zc-ai-foot textarea::-webkit-scrollbar,
.zc-ai-panel::-webkit-scrollbar {
	width: 6px;
	height: 6px;
	background: transparent;
}

.zc-ai-body::-webkit-scrollbar-track,
.zc-ai-foot textarea::-webkit-scrollbar-track,
.zc-ai-panel::-webkit-scrollbar-track,
.zc-ai-body::-webkit-scrollbar-corner,
.zc-ai-foot textarea::-webkit-scrollbar-corner {
	background: transparent;
	box-shadow: none;
	border: 0;
}

.zc-ai-body::-webkit-scrollbar-thumb,
.zc-ai-foot textarea::-webkit-scrollbar-thumb,
.zc-ai-panel::-webkit-scrollbar-thumb {
	background: rgba(140, 140, 140, .4);
	border-radius: 3px;
	border: 0;
}

.zc-ai-body::-webkit-scrollbar-thumb:hover,
.zc-ai-foot textarea::-webkit-scrollbar-thumb:hover,
.zc-ai-panel::-webkit-scrollbar-thumb:hover {
	background: rgba(140, 140, 140, .65);
}

/* 输入框滚动条只在真的溢出时出现 */
.zc-ai-foot textarea { overflow-y: auto; overscroll-behavior: contain; }

/* 正在查权限时的按钮状态 */
.zc-ai-chat-btn.is-checking {
	opacity: .6;
	cursor: progress;
	pointer-events: none !important;
}

/* 没有引言块时，按钮单独成行 */
.zc-ai-btn-wrap { margin: 0 0 35px; }
.zc-ai-btn-wrap .zc-ai-chat-btn { margin-top: 0 !important; }
