:root {
	--iacm-color: #2563eb;
	--iacm-bg: #ffffff;
	--iacm-text: #111827;
	--iacm-muted: #6b7280;
	--iacm-bubble-bot: #f3f4f6;
	--iacm-radius: 16px;
	--iacm-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
	--iacm-font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.iacm-root { position: fixed; bottom: 20px; z-index: 99999; font-family: var(--iacm-font); }
.iacm-pos-right { right: 20px; }
.iacm-pos-left { left: 20px; }

.iacm-launcher {
	width: 56px; height: 56px; border-radius: 50%; border: 0; cursor: pointer;
	background: var(--iacm-color); color: #fff; box-shadow: var(--iacm-shadow);
	display: flex; align-items: center; justify-content: center; transition: transform .15s ease;
}
.iacm-launcher:hover { transform: scale(1.06); }
.iacm-launcher svg { width: 26px; height: 26px; fill: currentColor; }

.iacm-panel {
	position: absolute; bottom: 70px; width: 370px; max-width: calc(100vw - 40px); height: 540px; max-height: calc(100vh - 110px);
	background: var(--iacm-bg); color: var(--iacm-text); border-radius: var(--iacm-radius); box-shadow: var(--iacm-shadow);
	display: none; flex-direction: column; overflow: hidden;
}
.iacm-pos-right .iacm-panel { right: 0; }
.iacm-pos-left .iacm-panel { left: 0; }
.iacm-panel.iacm-open { display: flex; }

.iacm-inline { position: relative; font-family: var(--iacm-font); }
.iacm-inline .iacm-panel { position: static; display: flex; width: 100%; max-width: none; height: 100%; max-height: none; border: 1px solid #e5e7eb; box-shadow: none; }

.iacm-header {
	background: var(--iacm-color); color: #fff; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.iacm-header strong { font-size: 15px; font-weight: 600; }
.iacm-header-actions { display: flex; gap: 4px; }
.iacm-icon-btn { background: transparent; border: 0; color: #fff; cursor: pointer; padding: 4px; border-radius: 6px; opacity: .85; line-height: 0; }
.iacm-icon-btn:hover { opacity: 1; background: rgba(255,255,255,.15); }
.iacm-icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }

.iacm-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }
.iacm-msg { max-width: 85%; padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.45; word-wrap: break-word; overflow-wrap: anywhere; }
.iacm-msg-user { align-self: flex-end; background: var(--iacm-color); color: #fff; border-bottom-right-radius: 4px; }
.iacm-msg-bot { align-self: flex-start; background: var(--iacm-bubble-bot); border-bottom-left-radius: 4px; }
.iacm-msg-error { align-self: flex-start; background: #fef2f2; color: #991b1b; }
.iacm-msg p { margin: 0 0 8px; }
.iacm-msg p:last-child { margin-bottom: 0; }
.iacm-msg ul { margin: 6px 0 6px 18px; padding: 0; }
.iacm-msg li { margin: 2px 0; }
.iacm-msg a { color: inherit; text-decoration: underline; }
.iacm-msg-bot a { color: var(--iacm-color); }

.iacm-sources { align-self: flex-start; max-width: 85%; font-size: 12px; color: var(--iacm-muted); margin-top: -4px; }
.iacm-sources span { display: block; margin-bottom: 3px; }
.iacm-sources a { display: inline-block; margin: 0 6px 4px 0; color: var(--iacm-color); text-decoration: none; border: 1px solid #e5e7eb; border-radius: 999px; padding: 2px 10px; }
.iacm-sources a:hover { background: var(--iacm-bubble-bot); }

.iacm-typing { align-self: flex-start; display: flex; gap: 4px; padding: 12px 14px; background: var(--iacm-bubble-bot); border-radius: 14px; }
.iacm-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--iacm-muted); animation: iacm-bounce 1.2s infinite ease-in-out; }
.iacm-typing i:nth-child(2) { animation-delay: .15s; }
.iacm-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes iacm-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-5px); opacity: 1; } }

.iacm-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid #e5e7eb; background: var(--iacm-bg); }
.iacm-input {
	flex: 1; resize: none; border: 1px solid #d1d5db; border-radius: 12px; padding: 10px 12px; font: inherit; font-size: 14px;
	color: var(--iacm-text); background: #fff; min-height: 40px; max-height: 120px; outline: none;
}
.iacm-input:focus { border-color: var(--iacm-color); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
.iacm-send {
	border: 0; border-radius: 12px; background: var(--iacm-color); color: #fff; padding: 0 14px; cursor: pointer; font: inherit; font-size: 14px; font-weight: 600;
}
.iacm-send:disabled { opacity: .5; cursor: default; }

@media (max-width: 480px) {
	.iacm-root .iacm-panel { position: fixed; inset: 0; width: 100%; max-width: none; height: 100%; max-height: none; border-radius: 0; bottom: 0; }
}

@media (prefers-color-scheme: dark) {
	.iacm-root, .iacm-inline { --iacm-bg: #1f2937; --iacm-text: #f9fafb; --iacm-muted: #9ca3af; --iacm-bubble-bot: #374151; }
	.iacm-root .iacm-input, .iacm-inline .iacm-input { background: #111827; color: #f9fafb; border-color: #4b5563; }
	.iacm-root .iacm-form, .iacm-inline .iacm-form { border-top-color: #374151; }
	.iacm-root .iacm-sources a, .iacm-inline .iacm-sources a { border-color: #4b5563; }
}
