#cs-chat-widget, #cs-chat-widget * {
	box-sizing: border-box;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.cs-widget {
	position: fixed;
	bottom: 24px;
	z-index: 999999;
	--cs-color: #2563eb;
}

.cs-pos-right { right: 24px; }
.cs-pos-left { left: 24px; }

/* Launcher button */
.cs-launcher {
	width: 62px;
	height: 62px;
	border-radius: 50%;
	background: var(--cs-color);
	border: none;
	cursor: pointer;
	box-shadow: 0 8px 24px rgba(0,0,0,0.2), 0 2px 6px rgba(0,0,0,0.1);
	display: flex;
	align-items: center;
	justify-content: center;
	position: relative;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.cs-launcher:hover {
	transform: scale(1.06);
	box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}
.cs-launcher svg { width: 26px; height: 26px; transition: opacity 0.15s ease, transform 0.2s ease; position: absolute; }
.cs-icon-close { opacity: 0; transform: rotate(-90deg) scale(0.7); }
.cs-icon-chat { opacity: 1; transform: rotate(0) scale(1); }
.cs-widget.cs-open .cs-icon-chat { opacity: 0; transform: rotate(90deg) scale(0.7); }
.cs-widget.cs-open .cs-icon-close { opacity: 1; transform: rotate(0) scale(1); }

.cs-launcher-dot {
	position: absolute;
	top: 2px;
	right: 2px;
	width: 14px;
	height: 14px;
	background: #ef4444;
	border: 2px solid #fff;
	border-radius: 50%;
}

/* Chat window */
.cs-chat-window {
	position: absolute;
	bottom: 78px;
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 600px;
	max-height: calc(100vh - 140px);
	background: #fff;
	border-radius: 18px;
	box-shadow: 0 20px 60px rgba(0,0,0,0.2), 0 4px 16px rgba(0,0,0,0.08);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	transform: translateY(16px) scale(0.97);
	pointer-events: none;
	transition: opacity 0.22s ease, transform 0.22s ease;
}
.cs-pos-right .cs-chat-window { right: 0; }
.cs-pos-left .cs-chat-window { left: 0; }

.cs-widget.cs-open .cs-chat-window {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: all;
}

/* Header */
.cs-header {
	background: var(--cs-color);
	background-image: linear-gradient(135deg, var(--cs-color), color-mix(in srgb, var(--cs-color) 70%, #000));
	padding: 16px 16px;
	display: flex;
	align-items: center;
	gap: 12px;
	flex-shrink: 0;
}
.cs-header-avatar {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: rgba(255,255,255,0.25);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 600;
	font-size: 16px;
	flex-shrink: 0;
}
.cs-header-info { flex: 1; min-width: 0; }
.cs-header-name {
	color: #fff;
	font-weight: 600;
	font-size: 15px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.cs-header-status {
	color: rgba(255,255,255,0.85);
	font-size: 12px;
	display: flex;
	align-items: center;
	gap: 5px;
	margin-top: 2px;
}
.cs-status-dot {
	width: 7px;
	height: 7px;
	background: #4ade80;
	border-radius: 50%;
	display: inline-block;
}
.cs-minimize-btn {
	background: rgba(255,255,255,0.15);
	border: none;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}
.cs-minimize-btn svg { width: 16px; height: 16px; }

/* Pre-contact form */
.cs-precontact {
	padding: 20px 18px;
	border-bottom: 1px solid #f0f0f0;
}
.cs-precontact-title {
	font-size: 14px;
	color: #374151;
	margin: 0 0 12px 0;
	line-height: 1.4;
}
.cs-input-field {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid #e5e7eb;
	border-radius: 10px;
	font-size: 14px;
	margin-bottom: 8px;
	outline: none;
	transition: border-color 0.15s ease;
}
.cs-input-field:focus { border-color: var(--cs-color); }
.cs-start-btn {
	width: 100%;
	background: var(--cs-color);
	color: #fff;
	border: none;
	padding: 11px;
	border-radius: 10px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	margin-top: 4px;
}
.cs-start-btn:hover { opacity: 0.92; }
.cs-skip-btn {
	width: 100%;
	background: transparent;
	color: #9ca3af;
	border: none;
	font-size: 12px;
	padding: 8px;
	cursor: pointer;
	text-decoration: underline;
}

/* Messages */
.cs-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: #f8f9fb;
}
.cs-chat-bubble {
	max-width: 80%;
	display: flex;
	flex-direction: column;
	animation: cs-fade-in 0.2s ease;
}
@keyframes cs-fade-in {
	from { opacity: 0; transform: translateY(6px); }
	to { opacity: 1; transform: translateY(0); }
}
.cs-bubble-text {
	padding: 10px 14px;
	border-radius: 16px;
	font-size: 14px;
	line-height: 1.45;
	word-wrap: break-word;
	white-space: pre-wrap;
}
.cs-bubble-time {
	font-size: 10px;
	color: #b0b4bb;
	margin-top: 3px;
	padding: 0 4px;
}
.cs-msg-user {
	align-self: flex-end;
	align-items: flex-end;
}
.cs-msg-user .cs-bubble-text {
	background: var(--cs-color);
	color: #fff;
	border-bottom-right-radius: 4px;
}
.cs-msg-bot, .cs-msg-admin {
	align-self: flex-start;
	align-items: flex-start;
}
.cs-msg-bot .cs-bubble-text, .cs-msg-admin .cs-bubble-text {
	background: #fff;
	color: #1f2937;
	border: 1px solid #eef0f3;
	border-bottom-left-radius: 4px;
}
.cs-msg-admin .cs-bubble-text {
	border-color: color-mix(in srgb, var(--cs-color) 30%, #fff);
}

/* Typing indicator */
.cs-typing {
	padding: 0 16px 8px 16px;
	display: flex;
	gap: 4px;
	align-items: center;
}
.cs-typing span {
	width: 6px;
	height: 6px;
	background: #c3c7cf;
	border-radius: 50%;
	animation: cs-bounce 1.2s infinite ease-in-out;
}
.cs-typing span:nth-child(2) { animation-delay: 0.15s; }
.cs-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes cs-bounce {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
	30% { transform: translateY(-5px); opacity: 1; }
}

/* Input area */
.cs-input-area {
	border-top: 1px solid #f0f0f0;
	padding: 10px 12px;
	display: flex;
	align-items: flex-end;
	gap: 8px;
	flex-shrink: 0;
	background: #fff;
}
.cs-honeypot {
	position: absolute;
	left: -9999px;
	opacity: 0;
	height: 0;
	width: 0;
}
.cs-message-input {
	flex: 1;
	border: 1px solid #e5e7eb;
	border-radius: 20px;
	padding: 10px 16px;
	font-size: 14px;
	resize: none;
	outline: none;
	max-height: 90px;
	line-height: 1.4;
	transition: border-color 0.15s ease;
}
.cs-message-input:focus { border-color: var(--cs-color); }
.cs-send-btn {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: var(--cs-color);
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: transform 0.12s ease, opacity 0.12s ease;
}
.cs-send-btn:hover { transform: scale(1.05); }
.cs-send-btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.cs-send-btn svg { width: 17px; height: 17px; }

.cs-footer {
	text-align: center;
	font-size: 10px;
	color: #c3c7cf;
	padding: 6px 0 8px 0;
	background: #fff;
	flex-shrink: 0;
}

/* Mobile */
@media (max-width: 480px) {
	.cs-widget { bottom: 16px; }
	.cs-pos-right { right: 16px; }
	.cs-pos-left { left: 16px; }
	.cs-chat-window {
		width: calc(100vw - 24px);
		height: calc(100vh - 110px);
		bottom: 74px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.cs-launcher, .cs-chat-window, .cs-chat-bubble, .cs-send-btn, .cs-typing span {
		transition: none !important;
		animation: none !important;
	}
}
