/*
 * CG Helper Chat. Uses the theme's --mp-* tokens when present, with fallbacks
 * so it still looks right under another theme.
 */
.cgc {
	--cgc-bg: var(--mp-surface-1, #121218);
	--cgc-surface: var(--mp-surface-2, #191921);
	--cgc-line: var(--mp-line, rgba(255, 255, 255, .08));
	--cgc-text: var(--mp-text, #f2efea);
	--cgc-muted: var(--mp-muted, #918f9e);
	--cgc-brand: var(--mp-brand-grad, linear-gradient(135deg, #ffb23f 0%, #f0801a 58%, #ff5a1f 100%));
	--cgc-on-brand: var(--mp-on-brand, #1a1208);
	--cgc-accent: var(--mp-amber-1, #ffb23f);
	bottom: 20px;
	font-family: var(--mp-font-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif);
	position: fixed;
	right: 20px;
	z-index: 9990;
}

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

.cgc-sr {
	clip-path: inset(50%);
	height: 1px;
	overflow: hidden;
	position: absolute;
	white-space: nowrap;
	width: 1px;
}

/* Launcher ------------------------------------------------------------- */
.cgc-launch {
	align-items: center;
	background: var(--cgc-brand);
	border: 0;
	border-radius: 999px;
	box-shadow: 0 14px 34px -14px rgba(240, 128, 26, .7);
	color: var(--cgc-on-brand);
	cursor: pointer;
	display: flex;
	font: inherit;
	font-size: 14px;
	font-weight: 800;
	gap: 10px;
	margin-left: auto;
	min-height: 52px;
	padding: 0 20px 0 16px;
	transition: transform .15s ease;
}

.cgc-launch:hover {
	transform: translateY(-2px);
}

.cgc-launch:focus-visible,
.cgc-close:focus-visible,
.cgc-send:focus-visible,
.cgc-input:focus-visible,
.cgc-log:focus-visible {
	outline: 2px solid var(--cgc-accent);
	outline-offset: 3px;
}

.cgc-launch__icon,
.cgc-send__icon {
	background-color: currentColor;
	display: block;
	flex: none;
	height: 22px;
	width: 22px;
}

.cgc-launch__icon {
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12a8 8 0 0 1-11.6 7.1L4 20.5l1.4-4.9A8 8 0 1 1 21 12z'/%3E%3Cpath d='M8.5 11h.01M12 11h.01M15.5 11h.01'/%3E%3C/svg%3E") center/contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12a8 8 0 0 1-11.6 7.1L4 20.5l1.4-4.9A8 8 0 1 1 21 12z'/%3E%3Cpath d='M8.5 11h.01M12 11h.01M15.5 11h.01'/%3E%3C/svg%3E") center/contain no-repeat;
}

.cgc.is-open .cgc-launch__label {
	display: none;
}

.cgc.is-open .cgc-launch {
	padding: 0 15px;
}

/* Teaser --------------------------------------------------------------- */
.cgc-teaser {
	align-items: flex-start;
	background: var(--cgc-bg);
	border: 1px solid var(--cgc-line);
	border-radius: 16px;
	box-shadow: 0 18px 44px -18px rgba(0, 0, 0, .75);
	color: var(--cgc-text);
	display: flex;
	gap: 10px;
	margin: 0 0 12px auto;
	opacity: 0;
	padding: 14px;
	position: relative;
	transform: translateY(8px);
	transition: opacity .25s ease, transform .25s ease;
	width: min(300px, calc(100vw - 40px));
}

.cgc-teaser.is-visible {
	opacity: 1;
	transform: none;
}

.cgc-teaser::after {
	background: var(--cgc-bg);
	border-bottom: 1px solid var(--cgc-line);
	border-right: 1px solid var(--cgc-line);
	bottom: -7px;
	content: "";
	height: 12px;
	position: absolute;
	right: 36px;
	transform: rotate(45deg);
	width: 12px;
}

.cgc-teaser__avatar {
	background: var(--cgc-brand);
	border-radius: 50%;
	flex: none;
	height: 30px;
	position: relative;
	width: 30px;
}

.cgc-teaser__avatar::after {
	background-color: var(--cgc-on-brand);
	content: "";
	height: 16px;
	left: 7px;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12a8 8 0 0 1-11.6 7.1L4 20.5l1.4-4.9A8 8 0 1 1 21 12z'/%3E%3Cpath d='M8.5 11h.01M12 11h.01M15.5 11h.01'/%3E%3C/svg%3E") center/contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12a8 8 0 0 1-11.6 7.1L4 20.5l1.4-4.9A8 8 0 1 1 21 12z'/%3E%3Cpath d='M8.5 11h.01M12 11h.01M15.5 11h.01'/%3E%3C/svg%3E") center/contain no-repeat;
	position: absolute;
	top: 7px;
	width: 16px;
}

.cgc-teaser__body {
	flex: 1;
	min-width: 0;
	padding-right: 16px;
}

.cgc-teaser__text {
	font-size: 13px;
	line-height: 1.45;
	margin: 0 0 9px;
}

.cgc-teaser__cta {
	background: var(--cgc-brand);
	border: 0;
	border-radius: 999px;
	color: var(--cgc-on-brand);
	cursor: pointer;
	font: inherit;
	font-size: 13px;
	font-weight: 800;
	padding: 8px 14px;
}

.cgc-teaser__dismiss {
	background: transparent;
	border: 0;
	color: var(--cgc-muted);
	cursor: pointer;
	font-size: 18px;
	height: 24px;
	line-height: 1;
	padding: 0;
	position: absolute;
	right: 10px;
	top: 8px;
	width: 24px;
}

.cgc-teaser__dismiss:hover {
	color: var(--cgc-text);
}

.cgc-teaser__cta:focus-visible,
.cgc-teaser__dismiss:focus-visible {
	outline: 2px solid var(--cgc-accent);
	outline-offset: 3px;
}

/* Panel ---------------------------------------------------------------- */
.cgc-panel {
	background: var(--cgc-bg);
	border: 1px solid var(--cgc-line);
	border-radius: 18px;
	box-shadow: 0 30px 70px -20px rgba(0, 0, 0, .85);
	color: var(--cgc-text);
	display: flex;
	flex-direction: column;
	height: min(560px, calc(100vh - 110px));
	margin-bottom: 12px;
	overflow: hidden;
	width: min(380px, calc(100vw - 40px));
}

.cgc-panel[hidden] {
	display: none;
}

.cgc-head {
	align-items: center;
	background: var(--cgc-surface);
	border-bottom: 1px solid var(--cgc-line);
	display: flex;
	gap: 12px;
	padding: 14px 14px 14px 18px;
}

.cgc-head__text {
	flex: 1;
	min-width: 0;
}

.cgc-head__title {
	color: var(--cgc-text);
	font-family: var(--mp-font-display, inherit);
	font-size: 16px;
	font-weight: 800;
	letter-spacing: -.01em;
	line-height: 1.2;
	margin: 0;
}

.cgc-head__sub {
	color: var(--cgc-muted);
	font-size: 12px;
	margin: 2px 0 0;
}

.cgc-close {
	background: transparent;
	border: 1px solid var(--cgc-line);
	border-radius: 50%;
	color: var(--cgc-text);
	cursor: pointer;
	font-size: 22px;
	height: 36px;
	line-height: 1;
	width: 36px;
}

.cgc-close:hover {
	background: rgba(255, 255, 255, .06);
}

/* Messages ------------------------------------------------------------- */
.cgc-log {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 10px;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 16px;
}

.cgc-msg {
	max-width: 86%;
}

.cgc-msg__text {
	border-radius: 14px;
	font-size: 14px;
	line-height: 1.5;
	margin: 0;
	overflow-wrap: anywhere;
	padding: 10px 13px;
	white-space: pre-wrap;
}

.cgc-msg--assistant .cgc-msg__text,
.cgc-msg--error .cgc-msg__text {
	background: var(--cgc-surface);
	border: 1px solid var(--cgc-line);
	border-bottom-left-radius: 4px;
}

.cgc-msg--user {
	align-self: flex-end;
}

.cgc-msg--user .cgc-msg__text {
	background: var(--cgc-brand);
	border-bottom-right-radius: 4px;
	color: var(--cgc-on-brand);
	font-weight: 600;
}

.cgc-msg--error .cgc-msg__text {
	border-color: rgba(255, 90, 31, .5);
}

.cgc-msg.is-pending .cgc-msg__text {
	color: var(--cgc-muted);
	font-style: italic;
}

/* Notice + form -------------------------------------------------------- */
.cgc-notice {
	border-top: 1px solid var(--cgc-line);
	color: var(--cgc-muted);
	font-size: 11px;
	line-height: 1.45;
	margin: 0;
	padding: 10px 16px 0;
}

.cgc-form {
	align-items: flex-end;
	display: flex;
	gap: 8px;
	padding: 10px 12px 12px;
}

.cgc-input {
	background: var(--cgc-surface);
	border: 1px solid var(--cgc-line);
	border-radius: 12px;
	color: var(--cgc-text);
	flex: 1;
	font: inherit;
	font-size: 16px; /* 16px stops iOS zooming into the field. */
	line-height: 1.4;
	max-height: 120px;
	min-height: 44px;
	padding: 11px 13px;
	resize: none;
}

.cgc-input::placeholder {
	color: var(--cgc-muted);
}

.cgc-send {
	align-items: center;
	background: var(--cgc-brand);
	border: 0;
	border-radius: 12px;
	color: var(--cgc-on-brand);
	cursor: pointer;
	display: flex;
	flex: none;
	height: 44px;
	justify-content: center;
	width: 44px;
}

.cgc-send:disabled {
	cursor: wait;
	opacity: .55;
}

.cgc-send__icon {
	height: 20px;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E") center/contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E") center/contain no-repeat;
	width: 20px;
}

/* Small screens: panel fills the width, launcher becomes icon-only. ---- */
@media (max-width: 560px) {
	.cgc {
		bottom: 12px;
		right: 12px;
	}

	.cgc-panel {
		height: calc(100dvh - 90px);
		width: calc(100vw - 24px);
	}

	.cgc-launch {
		padding: 0 15px;
	}

	.cgc-launch__label {
		display: none;
	}
}

/* Keep clear of the theme's off-canvas drawer and scrim when it is open. */
body:has(.mp-sidebar.is-open) .cgc {
	display: none;
}

@media (prefers-reduced-motion: reduce) {
	.cgc-launch,
	.cgc-teaser {
		transition: none;
	}
}
