.cwmia-root {
	--cwmia-color: #4f46e5;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.cwmia-root[data-mode="bubble"] {
	position: fixed;
	bottom: 20px;
	z-index: 999999;
}

.cwmia-position-bottom-right { right: 20px; }
.cwmia-position-bottom-left { left: 20px; }

.cwmia-toggle {
	position: relative;
	width: 60px;
	height: 60px;
	border-radius: 50%;
	background: var(--cwmia-color);
	color: #fff;
	border: none;
	cursor: pointer;
	box-shadow: 0 4px 14px rgba(0,0,0,.2);
	padding: 0;
	overflow: hidden;
	transition: transform .15s ease, box-shadow .15s ease;
}

.cwmia-toggle:hover {
	transform: scale(1.05);
	box-shadow: 0 6px 18px rgba(0,0,0,.28);
}

.cwmia-toggle-icon {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 1;
	transform: rotate(0deg) scale(1);
	transition: opacity .2s ease, transform .2s ease;
}

.cwmia-toggle-icon-close {
	opacity: 0;
	transform: rotate(-45deg) scale(.4);
}

.cwmia-toggle.cwmia-toggle-active .cwmia-toggle-icon-open {
	opacity: 0;
	transform: rotate(45deg) scale(.4);
}

.cwmia-toggle.cwmia-toggle-active .cwmia-toggle-icon-close {
	opacity: 1;
	transform: rotate(0deg) scale(1);
}

.cwmia-toggle.cwmia-toggle-pulse {
	animation: cwmia-pulse 1s ease;
}

@keyframes cwmia-pulse {
	0%   { transform: scale(1);    box-shadow: 0 4px 14px rgba(0,0,0,.2); }
	20%  { transform: scale(1.12) rotate(-8deg); }
	40%  { transform: scale(1.12) rotate(8deg); }
	60%  { transform: scale(1.08) rotate(-4deg); box-shadow: 0 0 0 10px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.2); }
	100% { transform: scale(1);    box-shadow: 0 4px 14px rgba(0,0,0,.2); }
}

.cwmia-teaser {
	position: absolute;
	bottom: 72px;
	right: 0;
	display: flex;
	align-items: flex-start;
	gap: 6px;
	width: max-content;
	max-width: min(260px, 80vw);
	padding: 12px 10px 12px 14px;
	background: #fff;
	color: #1d2327;
	border-radius: 12px;
	box-shadow: 0 6px 24px rgba(0,0,0,.18);
	animation: cwmia-teaser-in .3s ease;
}

.cwmia-teaser::after {
	content: "";
	position: absolute;
	bottom: -6px;
	right: 24px;
	width: 12px;
	height: 12px;
	background: #fff;
	transform: rotate(45deg);
}

.cwmia-position-bottom-left .cwmia-teaser { right: auto; left: 0; }
.cwmia-position-bottom-left .cwmia-teaser::after { right: auto; left: 24px; }

.cwmia-teaser-text {
	background: none;
	border: none;
	padding: 0;
	margin: 0;
	font: inherit;
	font-size: 14px;
	line-height: 1.4;
	color: inherit;
	text-align: left;
	cursor: pointer;
}

.cwmia-teaser-close {
	flex-shrink: 0;
	width: 20px;
	height: 20px;
	border: none;
	border-radius: 50%;
	background: #f0f0f1;
	color: #50575e;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	cursor: pointer;
}

.cwmia-teaser-close:hover { background: #dcdcde; }

@keyframes cwmia-teaser-in {
	from { opacity: 0; transform: translateY(8px); }
	to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
	.cwmia-toggle.cwmia-toggle-pulse,
	.cwmia-teaser { animation: none; }
}

.cwmia-toggle-avatar {
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: 50%;
}

.cwmia-root[data-mode="bubble"] .cwmia-panel {
	position: absolute;
	bottom: 72px;
	width: 380px;
	max-width: 90vw;
	height: 540px;
	max-height: 80vh;
	min-width: 280px;
	min-height: 320px;
}

.cwmia-resize-handle {
	position: absolute;
	width: 28px;
	height: 28px;
	transform: rotate(90deg);
	margin: -4px 0 0 -4px;
	border-radius: 50%;
	background: var(--cwmia-color);
	border: 2px solid #fff;
	box-shadow: 0 2px 8px rgba(0,0,0,.3);
	cursor: nwse-resize;
	z-index: 3;
	touch-action: none;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform .15s ease;
}

.cwmia-resize-handle:hover,
.cwmia-resize-handle:active {
	transform: scale(1.15);
}

.cwmia-resize-handle svg {
	width: 16px;
	height: 16px;
	pointer-events: none;
	display: block;
}

.cwmia-resize-handle-right {
	cursor: nesw-resize;
}

.cwmia-resize-handle-right svg {
	transform: scaleX(-1);
}

.cwmia-position-right .cwmia-panel,
.cwmia-position-bottom-right .cwmia-panel { right: 0; }
.cwmia-position-bottom-left .cwmia-panel { left: 0; }

.cwmia-embed-root .cwmia-panel {
	width: 100%;
	height: 480px;
	position: relative;
}

.cwmia-panel {
	display: flex;
	flex-direction: column;
	background: #fff;
	border-radius: 12px;
	box-shadow: 0 8px 30px rgba(0,0,0,.18);
	overflow: hidden;
}

.cwmia-panel-hidden { display: none; }

.cwmia-header {
	background: var(--cwmia-color);
	color: #fff;
	padding: 20px 10px 15px 20px;
	display: flex;
	align-items: center;
	gap: 8px;
	font-weight: 600;
}

.cwmia-header .cwmia-title {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.cwmia-avatar {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
}

.cwmia-header-close {
	margin-left: auto;
	flex-shrink: 0;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	background: rgba(255,255,255,.15);
	border: none;
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	padding: 0;
	transition: background .15s ease;
}

.cwmia-header-close:hover {
	background: rgba(255,255,255,.3);
}

.cwmia-header-close svg {
	pointer-events: none;
}

.cwmia-position-bottom-left .cwmia-header-close {
	margin-right: 10px;
}

.cwmia-messages {
	flex: 1;
	overflow-y: auto;
	padding: 12px;
	background: #f7f7f8;
}

.cwmia-msg { display: flex; margin-bottom: 10px; }
.cwmia-msg-user { justify-content: flex-end; }

.cwmia-bubble {
	max-width: 80%;
	padding: 8px 12px;
	border-radius: 12px;
	font-size: 14px;
	line-height: 1.4;
	white-space: pre-wrap;
	word-wrap: break-word;
}

.cwmia-msg-assistant .cwmia-bubble { background: #fff; border: 1px solid #e5e5e7; }
.cwmia-msg-user .cwmia-bubble { background: var(--cwmia-color); color: #fff; }

.cwmia-bubble a { color: var(--cwmia-color); text-decoration: underline; }
.cwmia-msg-user .cwmia-bubble a { color: #fff; }

.cwmia-form {
	display: flex;
	gap: 8px;
	padding: 10px;
	border-top: 1px solid #e5e5e7;
	background: #fff;
}

.cwmia-input {
	flex: 1;
	resize: none;
	border: 1px solid #dcdcde;
	border-radius: 8px;
	padding: 8px 10px;
	font-size: 14px;
	max-height: 80px;
}

.cwmia-send {
	background: var(--cwmia-color);
	color: #fff;
	border: none;
	border-radius: 8px;
	padding: 0 16px;
	cursor: pointer;
	font-size: 14px;
}

.cwmia-send:disabled { opacity: .6; cursor: default; }

.cwmia-typing { opacity: .6; }

.cwmia-lead-toggle {
	background: none;
	border: none;
	color: var(--cwmia-color);
	font-size: 12px;
	text-decoration: underline;
	cursor: pointer;
	padding: 6px 10px;
	text-align: left;
}

.cwmia-lead-form {
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 0 10px 10px;
}

.cwmia-lead-form input {
	border: 1px solid #dcdcde;
	border-radius: 8px;
	padding: 6px 10px;
	font-size: 13px;
}

.cwmia-lead-submit {
	background: var(--cwmia-color);
	color: #fff;
	border: none;
	border-radius: 8px;
	padding: 6px 10px;
	cursor: pointer;
	font-size: 13px;
}
