.helma-ai-chat-root,
.helma-ai-chat-root * {
	box-sizing: border-box;
}

.helma-ai-chat-root {
	--helma-ai-primary: #148f86;
	--helma-ai-primary-dark: #0c726b;
	--helma-ai-ink: #172033;
	--helma-ai-muted: #697386;
	--helma-ai-line: #e2e8f0;
	--helma-ai-soft: #f5f7fa;
	font-family: inherit;
	direction: rtl;
	position: relative;
	z-index: 2147481000;
}

.helma-ai-chat-root [hidden] {
	display: none !important;
}

.helma-ai-launcher {
	position: fixed;
	right: 24px;
	bottom: max(24px, env(safe-area-inset-bottom));
	z-index: 2147481001;
	min-height: 58px;
	max-width: calc(100vw - 48px);
	padding: 10px 18px;
	border: 0;
	border-radius: 999px;
	background: var(--helma-ai-primary);
	color: #fff;
	display: inline-flex;
	align-items: center;
	gap: 9px;
	font: inherit;
	font-weight: 800;
	font-size: 15px;
	cursor: pointer;
	box-shadow: 0 12px 32px rgba(15, 35, 53, .24);
	transition: transform .18s ease, background .18s ease;
}

.helma-ai-launcher:hover,
.helma-ai-launcher:focus-visible {
	background: var(--helma-ai-primary-dark);
	transform: translateY(-2px);
}

.helma-ai-launcher.is-open {
	opacity: 0;
	pointer-events: none;
}

.helma-ai-launcher-icon {
	display: grid;
	place-items: center;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: rgba(255, 255, 255, .17);
	font-size: 20px;
}

.helma-ai-unread {
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	border-radius: 11px;
	background: #d92d20;
	color: #fff;
	font-size: 12px;
	line-height: 22px;
	text-align: center;
}

.helma-ai-panel {
	position: fixed;
	right: 24px;
	bottom: max(24px, env(safe-area-inset-bottom));
	z-index: 2147481002;
	width: min(400px, calc(100vw - 32px));
	height: min(680px, calc(100dvh - 48px));
	min-height: 480px;
	background: #fff;
	border: 1px solid rgba(15, 35, 53, .09);
	border-radius: 20px;
	box-shadow: 0 24px 70px rgba(15, 35, 53, .28);
	display: grid;
	grid-template-rows: auto minmax(160px, 1fr) auto auto auto auto;
	overflow: hidden;
}

.helma-ai-header {
	min-height: 78px;
	padding: 16px 18px;
	background: linear-gradient(135deg, var(--helma-ai-primary-dark), var(--helma-ai-primary));
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.helma-ai-heading {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.helma-ai-heading strong {
	font-size: 17px;
	font-weight: 900;
}

.helma-ai-status {
	font-size: 12px;
	opacity: .88;
}

.helma-ai-status::before {
	content: '';
	display: inline-block;
	width: 7px;
	height: 7px;
	margin-left: 6px;
	border-radius: 50%;
	background: #fdb022;
}

.helma-ai-status.is-online::before {
	background: #75e0a7;
}

.helma-ai-close {
	width: 38px;
	height: 38px;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .16);
	color: #fff;
	font: inherit;
	font-size: 28px;
	line-height: 1;
	cursor: pointer;
}

.helma-ai-messages {
	padding: 16px;
	overflow-y: auto;
	overscroll-behavior: contain;
	background: #fbfcfd;
	display: flex;
	flex-direction: column;
	gap: 11px;
}

.helma-ai-loading {
	margin: auto;
	color: var(--helma-ai-muted);
	font-size: 13px;
}

.helma-ai-message {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 4px;
	max-width: 88%;
}

.helma-ai-message-visitor {
	align-self: flex-start;
	align-items: flex-start;
}

.helma-ai-message-ai,
.helma-ai-message-admin {
	align-self: flex-end;
	align-items: flex-end;
}

.helma-ai-message-system {
	align-self: center;
	max-width: 96%;
}

.helma-ai-bubble {
	padding: 10px 12px;
	border-radius: 14px;
	background: #fff;
	border: 1px solid var(--helma-ai-line);
	color: var(--helma-ai-ink);
	font-size: 14px;
	line-height: 1.8;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.helma-ai-message-visitor .helma-ai-bubble {
	background: var(--helma-ai-primary);
	border-color: var(--helma-ai-primary);
	color: #fff;
	border-bottom-right-radius: 5px;
}

.helma-ai-message-ai .helma-ai-bubble,
.helma-ai-message-admin .helma-ai-bubble {
	border-bottom-left-radius: 5px;
}

.helma-ai-message-admin .helma-ai-bubble {
	background: #ecfdf3;
	border-color: #abefc6;
}

.helma-ai-message-system .helma-ai-bubble {
	background: #fff4ed;
	border-color: #ffd6ae;
	color: #9c2a10;
	font-size: 13px;
}

.helma-ai-bubble a {
	display: inline-block;
	margin-top: 5px;
	color: var(--helma-ai-primary-dark);
	font-weight: 800;
	text-decoration: underline;
}

.helma-ai-message small {
	padding: 0 5px;
	color: var(--helma-ai-muted);
	font-size: 10px;
}

.helma-ai-typing {
	padding: 8px 16px;
	border-top: 1px solid #edf0f3;
	color: var(--helma-ai-muted);
	font-size: 12px;
}

.helma-ai-typing span {
	display: inline-block;
	width: 6px;
	height: 6px;
	margin-left: 3px;
	border-radius: 50%;
	background: var(--helma-ai-primary);
	animation: helma-ai-pulse 1s infinite alternate;
}

.helma-ai-typing span:nth-child(2) { animation-delay: .15s; }
.helma-ai-typing span:nth-child(3) { animation-delay: .3s; }
.helma-ai-typing em { margin-right: 6px; font-style: normal; }

@keyframes helma-ai-pulse {
	from { opacity: .25; transform: translateY(1px); }
	to { opacity: 1; transform: translateY(-1px); }
}

.helma-ai-handoff-area {
	padding: 9px 14px;
	border-top: 1px solid #edf0f3;
	background: #fff;
}

.helma-ai-handoff-button {
	width: 100%;
	padding: 9px 12px;
	border: 1px solid var(--helma-ai-primary);
	border-radius: 10px;
	background: #fff;
	color: var(--helma-ai-primary-dark);
	font: inherit;
	font-size: 13px;
	font-weight: 800;
	cursor: pointer;
}

.helma-ai-profile-wrap {
	padding: 8px 0 0;
}

.helma-ai-profile-wrap > strong {
	display: block;
	margin-bottom: 7px;
	font-size: 12px;
	color: var(--helma-ai-ink);
}

.helma-ai-profile-form {
	display: grid;
	grid-template-columns: 1fr 1fr auto;
	gap: 6px;
}

.helma-ai-profile-form input,
.helma-ai-profile-form button {
	min-width: 0;
	height: 36px;
	border-radius: 8px;
	font: inherit;
	font-size: 11px;
}

.helma-ai-profile-form input {
	padding: 6px 8px;
	border: 1px solid var(--helma-ai-line);
}

.helma-ai-profile-form button {
	padding: 0 10px;
	border: 0;
	background: var(--helma-ai-primary);
	color: #fff;
	font-weight: 700;
	cursor: pointer;
}

.helma-ai-profile-message {
	display: block;
	min-height: 16px;
	margin-top: 4px;
	color: var(--helma-ai-muted);
}

.helma-ai-privacy {
	margin: 0;
	padding: 6px 14px;
	color: var(--helma-ai-muted);
	font-size: 10px;
	line-height: 1.65;
	background: #fff;
}

.helma-ai-composer {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 8px;
	padding: 10px 12px max(10px, env(safe-area-inset-bottom));
	border-top: 1px solid var(--helma-ai-line);
	background: #fff;
}

.helma-ai-composer textarea {
	width: 100%;
	min-height: 42px;
	max-height: 96px;
	resize: vertical;
	padding: 9px 11px;
	border: 1px solid #cfd7e3;
	border-radius: 11px;
	font: inherit;
	font-size: 14px;
	line-height: 1.55;
}

.helma-ai-composer textarea:focus {
	outline: 2px solid rgba(20, 143, 134, .18);
	border-color: var(--helma-ai-primary);
}

.helma-ai-composer button {
	align-self: stretch;
	min-width: 64px;
	border: 0;
	border-radius: 11px;
	background: var(--helma-ai-primary);
	color: #fff;
	font: inherit;
	font-size: 13px;
	font-weight: 800;
	cursor: pointer;
}

.helma-ai-composer button:disabled,
.helma-ai-handoff-button:disabled {
	opacity: .5;
	cursor: not-allowed;
}

.helma-ai-noscript {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 9999;
	padding: 10px;
	background: #fff;
	border: 1px solid #ddd;
}

@media (max-width: 600px) {
	.helma-ai-launcher {
		right: 14px;
		bottom: max(14px, env(safe-area-inset-bottom));
		min-height: 54px;
	}

	.helma-ai-panel {
		right: 0;
		bottom: 0;
		width: 100vw;
		height: 100dvh;
		min-height: 0;
		max-height: 100dvh;
		border: 0;
		border-radius: 0;
	}

	.helma-ai-header {
		padding-top: max(14px, env(safe-area-inset-top));
	}

	.helma-ai-profile-form {
		grid-template-columns: 1fr 1fr;
	}

	.helma-ai-profile-form button {
		grid-column: 1 / -1;
	}
}

@media (prefers-reduced-motion: reduce) {
	.helma-ai-launcher,
	.helma-ai-typing span {
		transition: none;
		animation: none;
	}
}
