/* Chat widget (#37): launcher, greeting bubble and panel, after the app's support panel. */

.ei-chat {
	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: 1000;
	font-family: PT Sans, system-ui, sans-serif;
	color: var(--contrast);
}

.ei-chat svg {
	display: block;
	width: 20px;
	height: 20px;
}

/* Launcher: 52 px circle in accent; the icon turns to close while the panel is open. */
.ei-chat .ei-chat-launcher {
	display: grid;
	place-items: center;
	width: 52px;
	height: 52px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background-color: var(--accent);
	color: var(--on-accent);
	cursor: pointer;
}
.ei-chat .ei-chat-launcher svg {
	width: 26px;
	height: 26px;
}
.ei-chat-launcher-close,
.ei-chat.is-open .ei-chat-launcher-open {
	display: none;
}
.ei-chat.is-open .ei-chat-launcher-close {
	display: block;
}

/* Neutral icon buttons and chips: the theme's button hover would paint them in accent. */
.ei-chat .ei-chat-greet-x,
.ei-chat .ei-chat-x {
	display: grid;
	place-items: center;
	flex: none;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background-color: transparent;
	color: var(--contrast-2);
	cursor: pointer;
}
.ei-chat .ei-chat-greet-x:hover,
.ei-chat .ei-chat-chips button:hover {
	background-color: var(--base);
	color: var(--contrast);
	filter: none;
}

/* Greeting bubble, to the left of the launcher. */
.ei-chat-greet {
	position: absolute;
	right: calc(100% + 12px);
	bottom: 4px;
	display: flex;
	align-items: flex-start;
	gap: 4px;
	width: max-content;
	max-width: min(260px, calc(100vw - 112px));
	padding: 10px 6px 10px 13px;
	border: 1px solid var(--outline-variant);
	border-radius: 12px 12px 4px 12px;
	background-color: var(--base-3);
}
.ei-chat-greet-text {
	margin: 0;
	font-size: 14px;
	line-height: 1.4;
}
.ei-chat .ei-chat-greet-x {
	width: 24px;
	height: 24px;
}
.ei-chat .ei-chat-greet-x svg {
	width: 16px;
	height: 16px;
}

/* Panel: 380 wide, between 320 and 560 high, above the launcher. */
.ei-chat-panel {
	position: absolute;
	right: 0;
	bottom: calc(100% + 12px);
	display: flex;
	flex-direction: column;
	width: 380px;
	height: clamp(320px, calc(100vh - 112px), 560px);
	overflow: hidden;
	border: 1px solid var(--outline-variant);
	border-radius: 12px;
	background-color: var(--base-3);
}
.ei-chat-panel[hidden] {
	display: none;
}

.ei-chat-head {
	display: flex;
	align-items: center;
	gap: 11px;
	padding: 12px 8px 12px 14px;
}
.ei-chat-avatar {
	display: grid;
	place-items: center;
	flex: none;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background-color: var(--coral-90);
	color: var(--coral-10);
}
.ei-chat-avatar svg {
	width: 18px;
	height: 18px;
}
.ei-chat-names {
	flex: 1;
	min-width: 0;
}
.ei-chat-title {
	margin: 0;
	letter-spacing: 0.15px;
	font-size: 16px;
	font-weight: 700;
	line-height: 1.3;
}
.ei-chat-subtitle {
	margin: 0;
	letter-spacing: 0.5px;
	font-size: 11px;
	line-height: 1.3;
	color: var(--contrast-2);
}
.ei-chat .ei-chat-x {
	width: 36px;
	height: 36px;
	border-radius: 9px;
	color: var(--accent);
}
.ei-chat .ei-chat-x:hover,
.ei-chat .ei-chat-copy:hover {
	background-color: color-mix(in srgb, var(--accent) 6%, transparent);
	color: var(--accent);
	filter: none;
}

.ei-chat-thread {
	flex: 1;
	overflow-y: auto;
	padding: 12px 14px 8px;
}
.ei-chat-notice {
	margin: 0 0 8px;
	letter-spacing: 0.4px;
	padding: 6px 8px;
	font-size: 13px;
	line-height: 1.4;
	text-align: center;
	color: var(--contrast-2);
}
/* Thread, after the app's support panel: bodyMedium 14/20 bubbles, labelSmall typing, bodySmall error. */
.ei-chat {
	--ei-chat-highest: #E9E5E3;     /* surfaceContainerHighest */
	--ei-chat-surface: #FCF9F5;     /* surface */
	--ei-chat-on-error: #410014;    /* onErrorContainer */
}
@media (prefers-color-scheme: dark) {
	.ei-chat {
		--ei-chat-highest: #383635;
		--ei-chat-surface: #1A1918;
		--ei-chat-on-error: #FFD9DF;
	}
}
.ei-chat-list {
	display: flex;
	flex-direction: column;
	gap: 8px;
}
.ei-chat-msg {
	width: fit-content;
	max-width: 80%;
	padding: 10px 13px;
	border: 1px solid var(--outline-variant);
	border-radius: 12px 12px 12px 4px;
	background-color: var(--base);
	font-size: 14px;
	line-height: 20px;
	letter-spacing: 0.25px;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}
.ei-chat-msg.is-user {
	align-self: flex-end;
	border: 0;
	border-radius: 12px 12px 4px 12px;
	background-color: var(--ei-chat-highest);
}
.ei-chat-msg a {
	color: var(--accent);
}
.ei-chat-msg code {
	font-family: PT Mono, ui-monospace, monospace;
	font-size: 13px;
}
.ei-chat-msg:has(.ei-chat-code) {
	width: 80%;
}
.ei-chat-code {
	display: flex;
	flex-direction: column;
	margin: 8px 0;
	white-space: normal;
}
.ei-chat-code pre {
	order: 1;
	margin: 0;
	padding: 10px 12px;
	overflow-x: auto;
	border: 1px solid var(--outline-variant);
	border-radius: 10px;
	background-color: var(--base-3);
	white-space: pre;
}
/* Copy: the app's text button, compact. */
.ei-chat .ei-chat-copy {
	align-self: flex-end;
	height: auto;
	padding: 4px 8px;
	border: 0;
	border-radius: 8px;
	background-color: transparent;
	color: var(--accent);
	font-size: 13px;
	font-weight: 700;
	line-height: 16px;
	cursor: pointer;
}
.ei-chat-handoff {
	margin: 8px 0 0;
}
/* Start free / Open contact form: the app's filled button, 40 high, radius 12. */
.ei-chat .ei-chat-action {
	display: block;
	width: fit-content;
	margin-top: 10px;
	padding: 10px 16px;
	border: 1px solid var(--accent);
	border-radius: 12px;
	background-color: var(--accent);
	color: var(--on-accent);
	font-size: 14px;
	font-weight: 700;
	line-height: 18px;
	text-decoration: none;
}
.ei-chat .ei-chat-action:hover {
	color: var(--on-accent);
	filter: brightness(1.06);
}
.ei-chat-typing {
	margin: 0;
	padding: 4px 8px;
	font-size: 11px;
	line-height: 16px;
	letter-spacing: 0.5px;
	color: var(--contrast-2);
}
.ei-chat-error {
	margin-top: 6px;
	padding: 9px 12px;
	border-radius: 10px;
	background-color: var(--error-container);
	color: var(--ei-chat-on-error);
	font-size: 13px;
	line-height: 1.33;
	letter-spacing: 0.4px;
}
.ei-chat-error a {
	color: inherit;
}
.ei-chat-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
	margin-top: 10px;
}
.ei-chat .ei-chat-chips button {
	height: auto;
	min-height: 32px;
	padding: 6px 13px;
	border: 1px solid var(--outline-variant);
	border-radius: 16px;
	background-color: var(--ei-chat-surface);
	letter-spacing: 0.4px;
	color: var(--contrast);
	font-size: 13px;
	font-weight: 400;
	line-height: 1.3;
	text-align: left;
	cursor: pointer;
}

/* Thumb under a model's reply (#38, mockup A): the app's small icon button (32, radius 8, icon 16), neutral like the greeting's X. */
.ei-chat-rate {
	display: flex;
	align-items: center;
	gap: 2px;
}
.ei-chat .ei-chat-rate button {
	display: grid;
	place-items: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: 8px;
	background-color: transparent;
	color: var(--contrast-2);
	cursor: pointer;
	filter: none;
}
.ei-chat .ei-chat-rate button:not(:disabled, .is-chosen):hover {
	background-color: var(--base);
	color: var(--contrast);
}
.ei-chat .ei-chat-rate button:disabled {
	opacity: 0.4;
	cursor: default;
}
.ei-chat .ei-chat-rate button.is-chosen {
	background-color: transparent;
	color: var(--accent);
}
.ei-chat .ei-chat-rate svg {
	width: 16px;
	height: 16px;
}

.ei-chat-composer {
	display: flex;
	gap: 8px;
	padding: 8px 12px 12px;
}
.ei-chat-composer input[type="text"] {
	flex: 1;
	min-width: 0;
	height: 40px;
	padding: 0 12px;
	border-radius: 12px;
}
.ei-chat .ei-chat-send {
	display: grid;
	place-items: center;
	flex: none;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 12px;
	background-color: var(--accent);
	color: var(--on-accent);
	cursor: pointer;
}

/* Phone, or a window too low for the 320 px panel above the launcher (#73): the whole screen. */
@media (max-width: 620px), (max-height: 431px) {
	.ei-chat {
		right: 16px;
		bottom: 16px;
	}
	/* The full-screen panel covers the cookie bar (z-index 1002), which waits underneath (Leo, 2026-11-20). */
	.ei-chat.is-open {
		z-index: 1003;
	}
	.ei-chat-panel {
		position: fixed;
		inset: 0;
		width: auto;
		height: auto;
		border: 0;
		border-radius: 0;
	}
	.ei-chat.is-open .ei-chat-launcher {
		display: none;
	}
	.ei-chat-greet {
		max-width: min(260px, calc(100vw - 96px));
	}
}
