:host {
	all: initial;
}

.cjrei-chat {
	--cjrei-accent: #0b3d91;
	--cjrei-on-accent: #ffffff;
	--cjrei-border: #dbe2ee;
	--cjrei-muted: #64748b;
	position: fixed;
	z-index: 2147483000;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 14px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
}

.cjrei-chat *,
.cjrei-chat *::before,
.cjrei-chat *::after {
	box-sizing: border-box;
}

.cjrei-chat [hidden] {
	display: none !important;
}

.cjrei-chat button,
.cjrei-chat input,
.cjrei-chat select,
.cjrei-chat textarea {
	font-family: inherit;
}

/* Launcher */
.cjrei-launcher {
	position: fixed;
	right: 20px;
	bottom: 20px;
	width: auto;
	height: 56px;
	padding: 0 22px 0 17px;
	gap: 9px;
	border: 0;
	border-radius: 999px;
	background: var(--cjrei-accent);
	color: var(--cjrei-on-accent);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	box-shadow: 0 10px 28px rgba(11, 32, 58, 0.32);
	transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.cjrei-chat[data-position="left"] .cjrei-launcher {
	right: auto;
	left: 20px;
}

.cjrei-launcher:hover {
	transform: translateY(-2px);
	box-shadow: 0 14px 34px rgba(11, 32, 58, 0.38);
}

.cjrei-launcher:focus-visible {
	outline: 3px solid rgba(255, 255, 255, 0.9);
	outline-offset: 3px;
}

.cjrei-launcher::after {
	content: "Chat with us";
	font-size: 15px;
	font-weight: 600;
	line-height: 1;
	letter-spacing: 0.01em;
	white-space: nowrap;
}

.cjrei-launcher[aria-expanded="true"]::after {
	content: "Close chat";
}

.cjrei-launcher svg {
	width: 24px;
	height: 24px;
	flex: 0 0 auto;
	fill: currentColor;
	display: block;
}

.cjrei-dot {
	position: absolute;
	top: -4px;
	right: -4px;
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: #e11d48;
	border: 2px solid #ffffff;
}

/* Teaser */
.cjrei-teaser {
	position: fixed;
	right: 20px;
	bottom: 92px;
	width: 252px;
	background: #ffffff;
	border-radius: 14px;
	box-shadow: 0 14px 36px rgba(15, 23, 42, 0.2);
	padding: 12px 28px 12px 14px;
	display: flex;
	flex-direction: column;
	gap: 2px;
	color: #334155;
	animation: cjrei-in 0.22s ease-out;
}

.cjrei-chat[data-position="left"] .cjrei-teaser {
	right: auto;
	left: 20px;
}

.cjrei-teaser strong {
	font-size: 13px;
	color: #0f172a;
}

.cjrei-teaser span {
	font-size: 12px;
	color: var(--cjrei-muted);
	line-height: 1.4;
}

.cjrei-teaser-close {
	position: absolute;
	top: 3px;
	right: 5px;
	border: 0;
	background: transparent;
	color: #94a3b8;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	padding: 2px 4px;
}

/* Panel */
.cjrei-panel {
	position: fixed;
	right: 20px;
	bottom: 92px;
	width: 380px;
	max-width: calc(100vw - 40px);
	height: min(620px, calc(100vh - 120px));
	background: #ffffff;
	border-radius: 18px;
	box-shadow: 0 26px 64px rgba(15, 23, 42, 0.3), 0 4px 14px rgba(15, 23, 42, 0.08);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	animation: cjrei-in 0.22s ease-out;
}

.cjrei-chat[data-position="left"] .cjrei-panel {
	right: auto;
	left: 20px;
}

.cjrei-header {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 13px 14px;
	background: var(--cjrei-accent);
	background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.14), rgba(0, 0, 0, 0.2));
	color: var(--cjrei-on-accent);
	flex-shrink: 0;
}

.cjrei-avatar {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.2);
	color: var(--cjrei-on-accent);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 0.4px;
	overflow: hidden;
	flex-shrink: 0;
}

.cjrei-avatar img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.cjrei-heading {
	display: flex;
	flex-direction: column;
	min-width: 0;
	flex: 1;
}

.cjrei-heading strong {
	font-size: 14.5px;
	font-weight: 700;
	line-height: 1.3;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.cjrei-heading span {
	font-size: 11.5px;
	opacity: 0.82;
	line-height: 1.35;
}

.cjrei-close {
	border: 0;
	background: transparent;
	color: var(--cjrei-on-accent);
	font-size: 24px;
	line-height: 1;
	width: 30px;
	height: 30px;
	border-radius: 8px;
	cursor: pointer;
	opacity: 0.85;
	flex-shrink: 0;
}

.cjrei-close:hover,
.cjrei-close:focus-visible {
	background: rgba(255, 255, 255, 0.16);
	opacity: 1;
	outline: none;
}

/* Messages */
.cjrei-body {
	flex: 1;
	overflow-y: auto;
	overscroll-behavior: contain;
	background: #f5f7fb;
	padding: 16px 13px 10px;
}

.cjrei-body::-webkit-scrollbar {
	width: 8px;
}

.cjrei-body::-webkit-scrollbar-thumb {
	background: #cbd5e1;
	border-radius: 8px;
}

.cjrei-msg {
	display: flex;
	flex-direction: column;
	margin-bottom: 12px;
	animation: cjrei-fade 0.18s ease-out;
}

.cjrei-msg-user {
	align-items: flex-end;
}

.cjrei-bubble {
	max-width: 87%;
	padding: 10px 13px;
	border-radius: 14px;
	font-size: 13.5px;
	line-height: 1.55;
	color: #1f2937;
	background: #ffffff;
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
	overflow-wrap: anywhere;
	word-break: break-word;
}

.cjrei-msg-assistant .cjrei-bubble {
	border-bottom-left-radius: 5px;
}

.cjrei-msg-user .cjrei-bubble {
	background: var(--cjrei-accent);
	color: var(--cjrei-on-accent);
	border-bottom-right-radius: 5px;
}

.cjrei-bubble p {
	margin: 0 0 6px;
}

.cjrei-bubble p:last-child {
	margin-bottom: 0;
}

.cjrei-bubble ul {
	margin: 2px 0 6px;
	padding-left: 18px;
}

.cjrei-bubble li {
	margin: 2px 0;
}

.cjrei-bubble strong {
	font-weight: 650;
}

.cjrei-bubble a {
	color: var(--cjrei-accent);
	text-decoration: underline;
	text-underline-offset: 2px;
}

.cjrei-msg-user .cjrei-bubble a {
	color: inherit;
}

.cjrei-gap {
	height: 6px;
}

.cjrei-sources {
	font-size: 11.5px;
	color: var(--cjrei-muted);
	margin: 5px 4px 0;
}

.cjrei-sources a {
	color: var(--cjrei-accent);
	text-decoration: underline;
}

/* Typing */
.cjrei-typing .cjrei-bubble {
	display: flex;
	gap: 4px;
	align-items: center;
	padding: 12px 14px;
}

.cjrei-dot-anim {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #94a3b8;
	display: inline-block;
	animation: cjrei-bounce 1.1s infinite ease-in-out;
}

.cjrei-dot-anim:nth-child(2) {
	animation-delay: 0.15s;
}

.cjrei-dot-anim:nth-child(3) {
	animation-delay: 0.3s;
}

/* Suggestions */
.cjrei-suggestions {
	display: flex;
	gap: 6px;
	padding: 9px 12px;
	overflow-x: auto;
	background: #ffffff;
	border-top: 1px solid #eef1f6;
	scrollbar-width: none;
	flex-shrink: 0;
}

.cjrei-suggestions::-webkit-scrollbar {
	display: none;
}

.cjrei-chip {
	border: 1px solid var(--cjrei-border);
	background: #ffffff;
	color: #334155;
	font-size: 12px;
	line-height: 1.3;
	padding: 7px 11px;
	border-radius: 999px;
	white-space: nowrap;
	cursor: pointer;
	transition: border-color 0.15s ease, color 0.15s ease;
}

.cjrei-chip:hover,
.cjrei-chip:focus-visible {
	border-color: var(--cjrei-accent);
	color: var(--cjrei-accent);
	outline: none;
}

/* Composer */
.cjrei-form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px;
	background: #ffffff;
	border-top: 1px solid #eef1f6;
	flex-shrink: 0;
}

.cjrei-input {
	flex: 1;
	min-height: 42px;
	max-height: 120px;
	resize: none;
	border: 1px solid var(--cjrei-border);
	border-radius: 12px;
	padding: 10px 12px;
	font-size: 13.5px;
	line-height: 1.4;
	color: #1f2937;
	background: #ffffff;
	outline: none;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cjrei-input::placeholder {
	color: #94a3b8;
}

.cjrei-input:focus {
	border-color: var(--cjrei-accent);
	box-shadow: 0 0 0 3px rgba(11, 61, 145, 0.12);
}

.cjrei-send {
	width: 42px;
	height: 42px;
	border: 0;
	border-radius: 50%;
	background: var(--cjrei-accent);
	color: var(--cjrei-on-accent);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	flex-shrink: 0;
	transition: opacity 0.15s ease, transform 0.15s ease;
}

.cjrei-send svg {
	width: 19px;
	height: 19px;
	fill: currentColor;
	transform: translateX(1px);
}

.cjrei-send:hover {
	transform: translateY(-1px);
}

.cjrei-send:disabled {
	opacity: 0.5;
	cursor: default;
	transform: none;
}

.cjrei-foot {
	display: flex;
	justify-content: space-between;
	gap: 8px;
	padding: 0 13px 9px;
	background: #ffffff;
	font-size: 10.5px;
	line-height: 1.35;
	color: #94a3b8;
	flex-shrink: 0;
}

.cjrei-foot a {
	color: inherit;
	text-decoration: underline;
}

/* Lead form */
.cjrei-lead {
	margin-top: 8px;
	max-width: 87%;
	background: #ffffff;
	border: 1px solid var(--cjrei-border);
	border-radius: 14px;
	padding: 12px;
	box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
	font-size: 12.5px;
	color: #1f2937;
	position: relative;
}

.cjrei-lead strong {
	display: block;
	font-size: 13px;
	margin-bottom: 2px;
}

.cjrei-lead p {
	margin: 0 0 8px;
	color: #475569;
	font-size: 12px;
	line-height: 1.45;
}

.cjrei-lead form {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.cjrei-lead input,
.cjrei-lead select {
	width: 100%;
	height: 36px;
	border: 1px solid var(--cjrei-border);
	border-radius: 9px;
	padding: 0 10px;
	font-size: 12.5px;
	color: #1f2937;
	background: #ffffff;
	outline: none;
}

.cjrei-lead input:focus,
.cjrei-lead select:focus {
	border-color: var(--cjrei-accent);
	box-shadow: 0 0 0 3px rgba(11, 61, 145, 0.1);
}

.cjrei-lead button {
	height: 38px;
	border: 0;
	border-radius: 9px;
	background: var(--cjrei-accent);
	color: var(--cjrei-on-accent);
	font-weight: 650;
	font-size: 12.5px;
	cursor: pointer;
}

.cjrei-lead button:disabled {
	opacity: 0.6;
	cursor: default;
}

.cjrei-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px !important;
	height: 1px !important;
	opacity: 0 !important;
}

.cjrei-lead-note {
	font-size: 10.5px;
	line-height: 1.4;
	color: #94a3b8;
}

.cjrei-lead-note.cjrei-error {
	color: #b91c1c;
}

/* Animations */
@keyframes cjrei-in {
	from {
		opacity: 0;
		transform: translateY(10px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@keyframes cjrei-fade {
	from {
		opacity: 0;
		transform: translateY(4px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@keyframes cjrei-bounce {
	0%,
	80%,
	100% {
		transform: translateY(0);
		opacity: 0.45;
	}
	40% {
		transform: translateY(-4px);
		opacity: 1;
	}
}

/* Mobile */
@media (max-width: 480px) {
	.cjrei-launcher {
		width: auto;
		height: 52px;
		padding: 0 18px 0 14px;
		gap: 8px;
		right: 16px;
		bottom: 16px;
	}

	.cjrei-launcher::after {
		font-size: 14px;
	}

	.cjrei-launcher svg {
		width: 21px;
		height: 21px;
	}

	.cjrei-chat[data-position="left"] .cjrei-launcher {
		left: 16px;
		right: auto;
	}

	.cjrei-panel {
		inset: 0;
		width: 100%;
		max-width: none;
		height: 100dvh;
		border-radius: 0;
	}

	.cjrei-chat[data-position="left"] .cjrei-panel {
		left: 0;
	}

	.cjrei-teaser {
		right: 16px;
		bottom: 84px;
		width: calc(100vw - 32px);
	}

	.cjrei-chat[data-position="left"] .cjrei-teaser {
		left: 16px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.cjrei-chat *,
	.cjrei-chat *::before,
	.cjrei-chat *::after {
		animation: none !important;
		transition: none !important;
	}
}
