#icb-chat-wrapper {
	position: fixed;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: var(--icb-font-size, 14px);
	color: #1f2937;
}
#icb-chat-wrapper.icb-pos-bottom-right { right: 20px; bottom: 20px; }
#icb-chat-wrapper.icb-pos-bottom-left  { left: 20px;  bottom: 20px; }

/* Launcher */
#icb-launcher {
	width: 56px; height: 56px;
	border-radius: 50%;
	border: none; cursor: pointer;
	background: var(--icb-primary, #2563eb);
	color: #fff;
	display: flex; align-items: center; justify-content: center;
	box-shadow: 0 6px 18px rgba(0,0,0,0.18);
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}
#icb-launcher:hover  { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0,0,0,0.22); }
#icb-launcher:active { transform: translateY(0); }
#icb-launcher:focus  { outline: 3px solid rgba(37, 99, 235, 0.4); outline-offset: 2px; }

/* Window */
#icb-window {
	position: absolute;
	bottom: 72px;
	width: var(--icb-width, 360px);
	height: var(--icb-height, 520px);
	max-width: calc(100vw - 32px);
	max-height: calc(100vh - 100px);
	background: var(--icb-bg, #ffffff);
	border-radius: var(--icb-radius, 12px);
	box-shadow: 0 14px 38px rgba(0,0,0,0.22);
	display: flex; flex-direction: column;
	overflow: hidden;
	transform-origin: bottom right;
	opacity: 0;
	transform: scale(0.95);
	transition: opacity 0.2s ease, transform 0.2s ease;
}
.icb-pos-bottom-right #icb-window { right: 0; transform-origin: bottom right; }
.icb-pos-bottom-left  #icb-window { left: 0;  transform-origin: bottom left; }

#icb-chat-wrapper.icb-open #icb-window {
	opacity: 1;
	transform: scale(1);
}

/* Header */
#icb-header {
	background: var(--icb-primary, #2563eb);
	color: var(--icb-header-text, #ffffff);
	padding: 12px 14px;
	display: flex; align-items: center; gap: 10px;
	flex: 0 0 auto;
}
#icb-avatar {
	width: 28px; height: 28px;
	border-radius: 50%;
	object-fit: cover;
	background: rgba(255,255,255,0.25);
}
#icb-bot-name { font-weight: 600; flex: 1; }
#icb-close {
	background: transparent; border: none; cursor: pointer;
	color: var(--icb-header-text, #ffffff);
	font-size: 16px; padding: 4px 6px; border-radius: 4px;
}
#icb-close:hover { background: rgba(255,255,255,0.18); }

/* Messages */
#icb-messages {
	flex: 1 1 auto;
	overflow-y: auto;
	scroll-behavior: smooth;
	padding: 12px 14px;
	background: var(--icb-bg, #ffffff);
}

.icb-msg {
	display: flex;
	margin-bottom: 10px;
}
.icb-msg-user      { justify-content: flex-end; }
.icb-msg-assistant { justify-content: flex-start; }
.icb-msg-error     { justify-content: flex-start; }

.icb-msg-bubble {
	max-width: 78%;
	padding: 8px 12px;
	border-radius: 14px;
	line-height: 1.4;
	white-space: pre-wrap;
	word-wrap: break-word;
}
.icb-msg-user .icb-msg-bubble {
	background: var(--icb-user-bubble, #2563eb);
	color: #ffffff;
	border-bottom-right-radius: 4px;
}
.icb-msg-assistant .icb-msg-bubble {
	background: var(--icb-bot-bubble, #f1f5f9);
	color: #111827;
	border-bottom-left-radius: 4px;
}
.icb-msg-error .icb-msg-bubble {
	background: #fee2e2;
	color: #991b1b;
	border: 1px solid #fecaca;
}

.icb-cache-badge {
	display: inline-block;
	margin-left: 6px;
	font-size: 10px;
	opacity: 0.55;
	vertical-align: middle;
}

/* Typing dots */
#icb-typing {
	padding: 6px 16px 0;
	display: flex; gap: 4px;
}
#icb-typing[hidden] { display: none; }
#icb-typing span {
	width: 6px; height: 6px;
	border-radius: 50%;
	background: #94a3b8;
	animation: icb-bounce 1s infinite ease-in-out;
}
#icb-typing span:nth-child(2) { animation-delay: 0.15s; }
#icb-typing span:nth-child(3) { animation-delay: 0.30s; }
@keyframes icb-bounce {
	0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
	40%           { transform: translateY(-4px); opacity: 1; }
}

/* Input */
#icb-input-area {
	flex: 0 0 auto;
	display: flex; align-items: flex-end; gap: 6px;
	border-top: 1px solid #e5e7eb;
	padding: 8px 10px;
	background: var(--icb-bg, #ffffff);
}
#icb-input {
	flex: 1;
	resize: none;
	border: 1px solid #d1d5db;
	border-radius: 10px;
	padding: 8px 10px;
	font: inherit;
	color: inherit;
	max-height: 120px;
	background: #fff;
}
#icb-input:focus {
	outline: none;
	border-color: var(--icb-primary, #2563eb);
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
#icb-send {
	background: var(--icb-primary, #2563eb);
	color: #fff;
	border: none;
	border-radius: 10px;
	width: 38px; height: 38px;
	display: flex; align-items: center; justify-content: center;
	cursor: pointer;
}
#icb-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* Mobile */
@media (max-width: 480px) {
	#icb-chat-wrapper.icb-pos-bottom-right,
	#icb-chat-wrapper.icb-pos-bottom-left {
		right: 12px; left: 12px; bottom: 12px;
	}
	#icb-window {
		position: fixed;
		left: 0; right: 0; top: 0; bottom: 0;
		width: 100vw; height: 100vh;
		max-width: 100vw; max-height: 100vh;
		border-radius: 0;
	}
	#icb-launcher {
		position: absolute;
		right: 0; bottom: 0;
	}
	.icb-pos-bottom-left #icb-launcher {
		left: 0; right: auto;
	}
}
