/* KH Ecosystem — public UI (scoped under theme header actions) */

.kh-eco-header-actions {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	flex-shrink: 0;
	position: relative;
	z-index: 100030;
	margin-left: 0;
}

.kh-hd-v45__actions .kh-eco-header-actions,
.kh-hd-v5__actions .kh-eco-header-actions {
	max-width: min(220px, 28vw);
}

body.kh-max-header-owned .kh-eco-header-actions {
	display: none !important;
}

.kh-eco-balance {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 6px 12px;
	border-radius: 999px;
	font-size: 12px;
	font-weight: 600;
	text-decoration: none;
	color: inherit;
	background: rgba(255, 255, 255, 0.08);
	border: 1px solid rgba(255, 255, 255, 0.12);
	backdrop-filter: blur(12px);
	transition: background 0.2s ease, transform 0.2s ease;
}

.kh-eco-balance:hover {
	background: rgba(255, 255, 255, 0.14);
	transform: translateY(-1px);
}

.kh-eco-balance__sep { opacity: 0.45; }

.kh-eco-ai-trigger {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 14px;
	border: 1px solid rgba(99, 102, 241, 0.45);
	border-radius: 999px;
	background: linear-gradient(135deg, rgba(99, 102, 241, 0.22), rgba(168, 85, 247, 0.18));
	color: inherit;
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
	backdrop-filter: blur(12px);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kh-eco-ai-trigger:hover {
	transform: translateY(-1px);
	box-shadow: 0 8px 24px rgba(99, 102, 241, 0.25);
}

/* Floating panel */
.kh-eco-ai {
	position: fixed;
	inset: 0;
	z-index: 100060;
	display: flex;
	align-items: flex-end;
	justify-content: flex-end;
	padding: 16px;
	pointer-events: none;
}

.kh-eco-ai:not([hidden]) {
	pointer-events: auto;
}

.kh-eco-ai__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(6, 8, 20, 0.45);
	backdrop-filter: blur(4px);
	opacity: 0;
	transition: opacity 0.25s ease;
}

.kh-eco-ai:not([hidden]) .kh-eco-ai__backdrop {
	opacity: 1;
}

.kh-eco-ai__panel {
	position: relative;
	width: min(420px, calc(100vw - 32px));
	height: min(560px, calc(100vh - 32px));
	display: flex;
	flex-direction: column;
	border-radius: 20px;
	overflow: hidden;
	background: rgba(18, 20, 35, 0.82);
	border: 1px solid rgba(255, 255, 255, 0.12);
	box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
	backdrop-filter: blur(24px);
	transform: translateY(16px) scale(0.98);
	opacity: 0;
	transition: transform 0.28s ease, opacity 0.28s ease;
}

.kh-eco-ai:not([hidden]) .kh-eco-ai__panel {
	transform: translateY(0) scale(1);
	opacity: 1;
}

.kh-eco-ai__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 18px;
	border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.kh-eco-ai__brand {
	display: flex;
	align-items: center;
	gap: 10px;
}

.kh-eco-ai__brand h2 {
	margin: 0;
	font-size: 15px;
	font-weight: 700;
	color: #fff;
}

.kh-eco-ai__dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #22c55e;
	box-shadow: 0 0 12px rgba(34, 197, 94, 0.8);
}

.kh-eco-ai__close {
	width: 32px;
	height: 32px;
	border: none;
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.08);
	color: #fff;
	font-size: 20px;
	cursor: pointer;
	line-height: 1;
}

.kh-eco-ai__messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.kh-eco-ai__msg {
	max-width: 88%;
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 14px;
	line-height: 1.5;
	animation: khEcoFadeIn 0.25s ease;
}

.kh-eco-ai__msg--bot {
	align-self: flex-start;
	background: rgba(255, 255, 255, 0.08);
	color: #e8eaf6;
	border-bottom-left-radius: 4px;
}

.kh-eco-ai__msg--user {
	align-self: flex-end;
	background: linear-gradient(135deg, #6366f1, #8b5cf6);
	color: #fff;
	border-bottom-right-radius: 4px;
}

.kh-eco-ai__links {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin-top: 8px;
}

.kh-eco-ai__link {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 10px;
	border-radius: 8px;
	background: rgba(99, 102, 241, 0.18);
	color: #a5b4fc;
	font-size: 12px;
	text-decoration: none;
}

.kh-eco-ai__link:hover {
	background: rgba(99, 102, 241, 0.28);
}

.kh-eco-ai__form {
	display: flex;
	gap: 8px;
	padding: 14px 16px;
	border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.kh-eco-ai__input {
	flex: 1;
	padding: 10px 14px;
	border-radius: 12px;
	border: 1px solid rgba(255, 255, 255, 0.12);
	background: rgba(255, 255, 255, 0.06);
	color: #fff;
	font-size: 14px;
}

.kh-eco-ai__input:focus {
	outline: none;
	border-color: rgba(99, 102, 241, 0.6);
}

.kh-eco-ai__send {
	width: 42px;
	height: 42px;
	border: none;
	border-radius: 12px;
	background: linear-gradient(135deg, #6366f1, #8b5cf6);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
}

.kh-eco-ai__typing,
.kh-eco-portal__typing {
	align-self: flex-start;
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 10px 14px;
	font-size: 13px;
}

.kh-eco-ai__typing span,
.kh-eco-portal__typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: rgba(99, 102, 241, 0.85);
	animation: kh-eco-typing-bounce 1.2s ease-in-out infinite;
}

.kh-eco-ai__typing span:nth-child(2),
.kh-eco-portal__typing span:nth-child(2) {
	animation-delay: 0.15s;
}

.kh-eco-ai__typing span:nth-child(3),
.kh-eco-portal__typing span:nth-child(3) {
	animation-delay: 0.3s;
}

@keyframes kh-eco-typing-bounce {
	0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
	40% { transform: translateY(-4px); opacity: 1; }
}

.kh-eco-ai-fab {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 99998;
	width: 54px;
	height: 54px;
	border: none;
	border-radius: 50%;
	background: linear-gradient(135deg, #6366f1, #8b5cf6);
	color: #fff;
	box-shadow: 0 12px 32px rgba(99, 102, 241, 0.4);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
}

@keyframes khEcoFadeIn {
	from { opacity: 0; transform: translateY(6px); }
	to { opacity: 1; transform: translateY(0); }
}

/* Portal — fixed bottom-right launcher (all sites) */
.kh-eco-portal {
	position: relative;
	z-index: 9999;
}

.kh-eco-portal__launcher {
	position: fixed;
	right: 20px;
	bottom: 20px;
	left: auto;
	top: auto;
	z-index: 9999;
	width: 56px;
	height: 56px;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: linear-gradient(135deg, #6366f1, #a855f7);
	color: #fff;
	box-shadow: 0 12px 36px rgba(99, 102, 241, 0.45);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kh-eco-portal__launcher:hover {
	transform: translateY(-2px) scale(1.04);
	box-shadow: 0 16px 40px rgba(99, 102, 241, 0.55);
}

.kh-eco-portal__pulse {
	position: absolute;
	inset: -4px;
	border-radius: 50%;
	border: 2px solid rgba(99, 102, 241, 0.35);
	animation: khEcoPulse 2.4s ease-out infinite;
	pointer-events: none;
}

@keyframes khEcoPulse {
	0% { transform: scale(1); opacity: 0.8; }
	100% { transform: scale(1.35); opacity: 0; }
}

.kh-eco-portal__backdrop {
	position: fixed;
	inset: 0;
	z-index: 100059;
	background: rgba(6, 8, 20, 0.45);
	backdrop-filter: blur(4px);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.25s ease;
}

.kh-eco-portal.is-open .kh-eco-portal__backdrop {
	opacity: 1;
	pointer-events: auto;
}

.kh-eco-portal__sheet {
	position: fixed;
	right: 20px;
	bottom: 88px;
	z-index: 100060;
	width: min(380px, calc(100vw - 40px));
	max-height: min(520px, calc(100vh - 120px));
	display: flex;
	flex-direction: column;
	border-radius: 20px;
	overflow: hidden;
	background: rgba(18, 20, 35, 0.92);
	border: 1px solid rgba(255, 255, 255, 0.12);
	box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
	backdrop-filter: blur(24px);
	transform: translateY(12px) scale(0.98);
	opacity: 0;
	pointer-events: none;
	transition: transform 0.28s ease, opacity 0.28s ease;
}

.kh-eco-portal.is-open .kh-eco-portal__sheet {
	transform: translateY(0) scale(1);
	opacity: 1;
	pointer-events: auto;
}

.kh-eco-portal__links {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin-top: 8px;
}

.kh-eco-portal__link {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 10px;
	border-radius: 8px;
	background: rgba(99, 102, 241, 0.18);
	color: #a5b4fc;
	font-size: 12px;
	text-decoration: none;
}

.kh-eco-portal__link:hover {
	background: rgba(99, 102, 241, 0.28);
}

.kh-eco-ai.is-open .kh-eco-ai__panel {
	transform: translateY(0) scale(1);
	opacity: 1;
}

@keyframes khEcoSheetIn {
	from { opacity: 0; transform: translateY(12px) scale(0.98); }
	to { opacity: 1; transform: translateY(0) scale(1); }
}

body.kh-eco-portal-open {
	overflow: hidden;
}

.kh-eco-portal__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 16px;
	border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.kh-eco-portal__head h2 {
	margin: 0;
	font-size: 15px;
	font-weight: 700;
	color: #fff;
}

.kh-eco-portal__close {
	width: 32px;
	height: 32px;
	border: none;
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.08);
	color: #fff;
	font-size: 20px;
	cursor: pointer;
	line-height: 1;
}

.kh-eco-portal__tabs {
	display: flex;
	gap: 4px;
	padding: 8px 12px;
	border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.kh-eco-portal__tab {
	flex: 1;
	padding: 8px 10px;
	border: none;
	border-radius: 10px;
	background: transparent;
	color: rgba(255, 255, 255, 0.55);
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
}

.kh-eco-portal__tab.is-active {
	background: rgba(99, 102, 241, 0.22);
	color: #fff;
}

.kh-eco-portal__panel {
	display: none;
	flex-direction: column;
	flex: 1;
	min-height: 0;
	padding: 16px;
}

.kh-eco-portal__panel.is-active {
	display: flex;
}

.kh-eco-portal__guest p {
	margin: 0 0 12px;
	font-size: 14px;
	color: rgba(255, 255, 255, 0.7);
}

.kh-eco-portal__profile {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px;
}

.kh-eco-portal__avatar,
.kh-eco-portal__avatar-fallback {
	width: 56px;
	height: 56px;
	border-radius: 50%;
	object-fit: cover;
}

.kh-eco-portal__avatar-fallback {
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(135deg, #6366f1, #8b5cf6);
	color: #fff;
	font-weight: 700;
	font-size: 18px;
}

.kh-eco-portal__meta {
	flex: 1;
	min-width: 120px;
}

.kh-eco-portal__meta strong {
	display: block;
	color: #fff;
	font-size: 15px;
}

.kh-eco-portal__meta span {
	font-size: 12px;
	color: rgba(255, 255, 255, 0.6);
}

.kh-eco-portal__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 10px 16px;
	border-radius: 12px;
	background: linear-gradient(135deg, #6366f1, #8b5cf6);
	color: #fff;
	font-size: 13px;
	font-weight: 600;
	text-decoration: none;
	border: none;
	cursor: pointer;
}

.kh-eco-portal__btn--ghost {
	background: rgba(255, 255, 255, 0.08);
	width: 100%;
	margin-top: 8px;
}

.kh-eco-portal__messages {
	flex: 1;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 10px;
	min-height: 200px;
	max-height: 280px;
	margin-bottom: 12px;
}

.kh-eco-portal__msg {
	max-width: 90%;
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 14px;
	line-height: 1.5;
}

.kh-eco-portal__msg--bot {
	align-self: flex-start;
	background: rgba(255, 255, 255, 0.08);
	color: #e8eaf6;
}

.kh-eco-portal__msg--user {
	align-self: flex-end;
	background: linear-gradient(135deg, #6366f1, #8b5cf6);
	color: #fff;
}

.kh-eco-portal__form {
	display: flex;
	gap: 8px;
}

.kh-eco-portal__form input {
	flex: 1;
	padding: 10px 14px;
	border-radius: 12px;
	border: 1px solid rgba(255, 255, 255, 0.12);
	background: rgba(255, 255, 255, 0.06);
	color: #fff;
	font-size: 14px;
}

.kh-eco-portal__form button {
	width: 42px;
	height: 42px;
	border: none;
	border-radius: 12px;
	background: linear-gradient(135deg, #6366f1, #8b5cf6);
	color: #fff;
	cursor: pointer;
}

@media (max-width: 640px) {
	.kh-eco-ai {
		padding: 0;
		align-items: stretch;
	}

	.kh-eco-ai__panel {
		width: 100%;
		height: 100%;
		border-radius: 0;
		max-height: none;
	}

	.kh-eco-ai-trigger span { display: none; }

	.kh-eco-portal__sheet {
		right: 0;
		bottom: 0;
		width: 100%;
		max-height: 85vh;
		border-radius: 20px 20px 0 0;
	}

	.kh-eco-portal__launcher {
		right: 16px;
		bottom: 16px;
	}
}


.kh-eco-profile-wallet {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-top: 8px;
	padding-top: 8px;
	border-top: 1px solid rgba(255, 255, 255, 0.08);
	font-size: 12px;
}

.kh-eco-profile-wallet__label {
	opacity: 0.7;
	font-weight: 600;
}

.kh-eco-vip-badge {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	margin-top: 4px;
	padding: 2px 8px;
	border-radius: 999px;
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	border: 1px solid rgba(255, 255, 255, 0.15);
}

.kh-eco-vip-badge--bronze {
	color: #f5d0a8;
	background: rgba(180, 120, 60, 0.22);
	border-color: rgba(205, 150, 90, 0.45);
}

.kh-eco-vip-badge--silver {
	color: #e8eef5;
	background: rgba(148, 163, 184, 0.22);
	border-color: rgba(186, 198, 214, 0.5);
}

.kh-eco-vip-badge--gold {
	color: #fff4cc;
	background: rgba(234, 179, 8, 0.25);
	border-color: rgba(250, 204, 21, 0.55);
}
