.xsis-chat {
	--xsis-chat-bg: var(--it-bg, #000000);
	--xsis-chat-panel: var(--it-bg-elevated, #0a0a0a);
	--xsis-chat-panel-2: var(--it-panel, #111111);
	--xsis-chat-border: var(--it-border, rgba(255, 255, 255, 0.1));
	--xsis-chat-text: var(--it-text, #ededed);
	--xsis-chat-muted: var(--it-muted, #888888);
	--xsis-chat-accent: var(--it-accent, #ffffff);
	--xsis-chat-accent-hover: var(--it-accent-hover, #e5e5e5);
	--xsis-chat-accent-soft: var(--it-accent-soft, rgba(255, 255, 255, 0.08));
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 9999;
	font-family: var(--it-font, "Inter", system-ui, -apple-system, sans-serif);
	color: var(--xsis-chat-text);
}

.xsis-chat__panel {
	position: absolute;
	right: 0;
	bottom: 72px;
	display: flex;
	flex-direction: column;
	width: min(380px, calc(100vw - 32px));
	height: min(560px, calc(100dvh - 120px));
	border-radius: 16px;
	overflow: hidden;
	border: 1px solid var(--xsis-chat-border);
	background: var(--xsis-chat-panel);
	box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
	opacity: 0;
	visibility: hidden;
	transform: translateY(12px) scale(0.98);
	transform-origin: right bottom;
	transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s ease;
}

.xsis-chat.is-open .xsis-chat__panel {
	opacity: 1;
	visibility: visible;
	transform: translateY(0) scale(1);
}

.xsis-chat__header {
	padding: 14px 16px 12px;
	border-bottom: 1px solid rgba(255, 255, 255, 0.08);
	background:
		linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 100%),
		rgba(10, 11, 13, 0.96);
	backdrop-filter: blur(12px);
}

.xsis-chat__pill {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: fit-content;
	margin: 0 auto 12px;
	padding: 7px 14px;
	border: 1px solid var(--xsis-chat-border);
	border-radius: 999px;
	background: var(--xsis-chat-accent-soft);
	color: var(--xsis-chat-text);
	font: inherit;
	font-size: 0.82rem;
	font-weight: 600;
	cursor: default;
}

.xsis-chat__pill svg {
	width: 16px;
	height: 16px;
	flex-shrink: 0;
	color: var(--xsis-chat-muted);
}

.xsis-chat__agent {
	display: flex;
	align-items: center;
	gap: 10px;
}

.xsis-chat__agent-avatar {
	width: 34px;
	height: 34px;
	border-radius: 50%;
	border: 1px solid var(--xsis-chat-border);
	background: rgba(255, 255, 255, 0.04);
	object-fit: contain;
	padding: 4px;
}

.xsis-chat__agent-meta {
	flex: 1;
	min-width: 0;
}

.xsis-chat__agent-name {
	display: block;
	font-size: 0.92rem;
	font-weight: 600;
	line-height: 1.2;
}

.xsis-chat__agent-status {
	display: block;
	margin-top: 2px;
	font-size: 0.72rem;
	color: var(--xsis-chat-muted);
}

.xsis-chat__close {
	display: grid;
	place-items: center;
	width: 30px;
	height: 30px;
	padding: 0;
	border: 1px solid var(--xsis-chat-border);
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.04);
	color: var(--xsis-chat-text);
	cursor: pointer;
	transition: background 0.15s ease, border-color 0.15s ease;
}

.xsis-chat__close:hover {
	background: rgba(255, 255, 255, 0.08);
	border-color: rgba(255, 255, 255, 0.16);
}

.xsis-chat__notice {
	padding: 10px 14px;
	font-size: 0.74rem;
	line-height: 1.45;
	color: var(--xsis-chat-muted);
	background: rgba(255, 255, 255, 0.03);
	border-bottom: 1px solid var(--xsis-chat-border);
}

.xsis-chat__messages {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	padding: 16px 14px;
	background:
		linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
		linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
		var(--xsis-chat-bg);
	background-size: 20px 20px, 20px 20px, auto;
	scroll-behavior: smooth;
}

.xsis-chat__messages::-webkit-scrollbar {
	width: 6px;
}

.xsis-chat__messages::-webkit-scrollbar-thumb {
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.14);
}

.xsis-chat__msg {
	display: flex;
	gap: 8px;
	margin-bottom: 14px;
	max-width: 92%;
}

.xsis-chat__msg--user {
	margin-left: auto;
	flex-direction: row-reverse;
}

.xsis-chat__msg-avatar {
	width: 28px;
	height: 28px;
	flex-shrink: 0;
	border-radius: 50%;
	border: 1px solid var(--xsis-chat-border);
	background: rgba(255, 255, 255, 0.04);
	object-fit: contain;
	padding: 3px;
}

.xsis-chat__msg-body {
	min-width: 0;
}

.xsis-chat__msg-name {
	display: block;
	margin-bottom: 4px;
	font-size: 0.68rem;
	font-weight: 600;
	color: var(--xsis-chat-muted);
}

.xsis-chat__msg--user .xsis-chat__msg-name {
	text-align: right;
}

.xsis-chat__bubble {
	padding: 10px 12px;
	border-radius: 14px;
	font-size: 0.84rem;
	line-height: 1.5;
	word-break: break-word;
}

.xsis-chat__msg--agent .xsis-chat__bubble {
	border-top-left-radius: 4px;
	background: var(--xsis-chat-panel-2);
	border: 1px solid var(--xsis-chat-border);
	color: var(--xsis-chat-text);
}

.xsis-chat__msg--user .xsis-chat__bubble {
	border-bottom-right-radius: 4px;
	background: var(--xsis-chat-accent);
	color: #111318;
}

.xsis-chat__composer {
	padding: 12px 14px 14px;
	border-top: 1px solid var(--xsis-chat-border);
	background: var(--xsis-chat-panel);
}

.xsis-chat__form {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 10px 12px;
	border: 1px solid var(--xsis-chat-border);
	border-radius: 12px;
	background: rgba(255, 255, 255, 0.02);
	transition: border-color 0.15s ease, background 0.15s ease;
}

.xsis-chat__form:focus-within {
	border-color: rgba(255, 255, 255, 0.18);
	background: rgba(255, 255, 255, 0.04);
}

.xsis-chat__input {
	width: 100%;
	min-height: 72px;
	max-height: 120px;
	padding: 0;
	border: 0;
	resize: none;
	background: transparent;
	color: var(--xsis-chat-text);
	font: inherit;
	font-size: 0.84rem;
	line-height: 1.45;
}

.xsis-chat__input:focus {
	outline: none;
}

.xsis-chat__input::placeholder {
	color: var(--xsis-chat-muted);
}

.xsis-chat__form-actions {
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.xsis-chat__hint {
	font-size: 0.68rem;
	color: var(--xsis-chat-muted);
}

.xsis-chat__send {
	display: grid;
	place-items: center;
	width: 34px;
	height: 34px;
	padding: 0;
	border: 1px solid rgba(255, 255, 255, 0.12);
	border-radius: 10px;
	background: var(--xsis-chat-accent);
	color: #111318;
	cursor: pointer;
	transition: background 0.15s ease, border-color 0.15s ease;
}

.xsis-chat__send:hover {
	background: var(--xsis-chat-accent-hover);
	border-color: rgba(255, 255, 255, 0.2);
}

.xsis-chat__send:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.xsis-chat__send svg {
	width: 16px;
	height: 16px;
}

.xsis-chat__launcher {
	position: relative;
	display: grid;
	place-items: center;
	width: 56px;
	height: 56px;
	padding: 0;
	border: 1px solid var(--xsis-chat-border);
	border-radius: 50%;
	background: var(--xsis-chat-panel);
	box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
	cursor: pointer;
	transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.xsis-chat__launcher:hover {
	transform: translateY(-2px);
	border-color: rgba(255, 255, 255, 0.16);
	box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5);
}

.xsis-chat__launcher img {
	width: 28px;
	height: auto;
	animation: it-logo-glitch 2s steps(1, end) infinite;
}

.xsis-chat__launcher-dot {
	position: absolute;
	right: 4px;
	bottom: 4px;
	width: 12px;
	height: 12px;
	border: 2px solid var(--xsis-chat-panel);
	border-radius: 50%;
	background: #3ddc84;
	box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.xsis-chat.is-open .xsis-chat__launcher {
	transform: scale(0.96);
}

@media (max-width: 480px) {
	.xsis-chat {
		right: 14px;
		bottom: 14px;
	}

	.xsis-chat__panel {
		width: calc(100vw - 28px);
		bottom: 68px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.xsis-chat__panel,
	.xsis-chat__launcher {
		transition: none;
	}

	.xsis-chat__launcher img {
		animation: none;
	}
}
