/**
 * AI Sales Console front-end image character chat widget.
 */

.aisc-chat-widget {
	position: fixed;
	right: 24px;
	bottom: 0;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
	color: #172033;
	display: flex;
	flex-direction: column;
	align-items: center;
	max-width: calc(100vw - 24px);
}

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

/* =============================================
   STANDING SOPHIE LAUNCHER (replaces pill button)
   ============================================= */

.aisc-launcher {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	max-width: min(360px, calc(100vw - 48px));
	cursor: pointer;
	isolation: isolate;
	user-select: none;
}

/* Hidden state: collapsed */
.aisc-launcher[hidden] {
	display: none;
}

/* Sophie's character image — standing on page bottom */
.aisc-launcher-character {
	position: relative;
	width: 160px !important;
	height: 280px !important;
	max-width: 160px !important;
	max-height: 280px !important;
	flex: 0 0 auto;
	overflow: visible;
	z-index: 2;
}

.aisc-launcher-character-wrap {
	position: absolute;
	left: 50%;
	bottom: 0;
	width: 160px !important;
	height: 280px !important;
	max-width: 160px !important;
	max-height: 280px !important;
	transform: translateX(-50%);
	transform-origin: 50% 100%;
	animation: aisc-launcher-float 4s ease-in-out infinite;
	overflow: visible;
}

.aisc-chat-widget .aisc-launcher-img {
	position: absolute;
	left: 50%;
	bottom: 0;
	display: block;
	width: auto !important;
	height: 100% !important;
	min-height: 100% !important;
	max-width: none !important;
	max-height: 100% !important;
	transform: translateX(-50%);
	filter: drop-shadow(0 16px 18px rgba(15, 23, 42, 0.22));
	pointer-events: none;
	user-select: none;
	object-fit: contain !important;
}

/* Launcher entrance now swaps image frames in JavaScript; keep the old class calm. */
.aisc-launcher-waving .aisc-launcher-character-wrap {
	animation: aisc-launcher-float 4s ease-in-out infinite;
}

/* Greeting speech bubble */
.aisc-launcher-bubble {
	position: absolute;
	bottom: 300px;
	right: 8px;
	left: auto;
	transform: none;
	width: 360px;
	max-width: min(360px, calc(100vw - 48px));
	white-space: pre-line;
	text-align: left;
	padding: 10px 16px;
	border-radius: 20px 20px 4px 20px;
	background: #ffffff;
	border: 1px solid rgba(37, 99, 235, 0.18);
	box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
	font-size: 13px;
	font-weight: 700;
	color: #172033;
	line-height: 1.4;
	opacity: 0;
	pointer-events: none;
	z-index: 5;
	animation: aisc-bubble-appear 0.4s ease-out 1.2s both;
}

.aisc-launcher-bubble::after {
	content: "";
	position: absolute;
	bottom: -8px;
	right: 52px;
	left: auto;
	width: 16px;
	height: 16px;
	background: #ffffff;
	border-right: 1px solid rgba(37, 99, 235, 0.18);
	border-bottom: 1px solid rgba(37, 99, 235, 0.18);
	transform: rotate(45deg);
}

/* Click-to-chat CTA label */
.aisc-launcher-cta {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin-top: -4px;
	padding: 7px 14px;
	border-radius: 999px;
	background: linear-gradient(135deg, #13213f 0%, #2563eb 100%);
	color: #ffffff;
	font-size: 12px;
	font-weight: 800;
	letter-spacing: 0.01em;
	box-shadow: 0 8px 22px rgba(17, 24, 39, 0.22);
	cursor: pointer;
	border: 0;
	transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
	line-height: 1;
	white-space: nowrap;
}

.aisc-launcher-cta:hover,
.aisc-launcher-cta:focus {
	filter: brightness(1.08);
	transform: translateY(-2px);
	box-shadow: 0 14px 32px rgba(17, 24, 39, 0.3);
	outline: none;
}

/* Minimise X button — top-right of Sophie */
.aisc-launcher-minimize {
	position: absolute;
	top: 0;
	right: -4px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	border-radius: 999px;
	border: 2px solid #ffffff;
	background: #6b7280;
	color: #ffffff;
	font-size: 13px;
	line-height: 1;
	cursor: pointer;
	box-shadow: 0 4px 10px rgba(15, 23, 42, 0.18);
	transition: background 0.15s ease, transform 0.15s ease;
	z-index: 6;
}

.aisc-launcher-minimize:hover,
.aisc-launcher-minimize:focus {
	background: #374151;
	transform: scale(1.1);
	outline: none;
}

/* Shadow under Sophie's feet */
.aisc-launcher-shadow {
	width: 90px;
	height: 12px;
	border-radius: 999px;
	background: rgba(15, 23, 42, 0.12);
	filter: blur(4px);
	margin-top: -6px;
	flex: 0 0 auto;
}

/* Minimised restore pill (shows when Sophie is hidden) */
.aisc-restore-btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 16px;
	padding: 9px 16px;
	border: 0;
	border-radius: 999px;
	background: linear-gradient(135deg, #13213f 0%, #2563eb 100%);
	color: #ffffff;
	font-size: 13px;
	font-weight: 800;
	cursor: pointer;
	box-shadow: 0 10px 28px rgba(17, 24, 39, 0.24);
	transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
	line-height: 1;
}

.aisc-restore-btn[hidden] {
	display: none;
}

.aisc-restore-btn:hover,
.aisc-restore-btn:focus {
	filter: brightness(1.06);
	transform: translateY(-2px);
	outline: none;
}

/* =============================================
   CHAT PANEL
   ============================================= */

.aisc-chat-panel {
	position: absolute;
	right: 0;
	bottom: 72px;
	width: 740px;
	max-width: calc(100vw - 32px);
	height: 610px;
	max-height: calc(100vh - 116px);
	overflow: hidden;
	border: 1px solid rgba(37, 99, 235, 0.12);
	border-radius: 30px;
	background: #ffffff;
	box-shadow: 0 34px 95px rgba(15, 23, 42, 0.24);
}

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

/* Hide the closed launcher while the full chat panel is open.
   The .aisc-chat-open class is the mobile-safe fallback; :has() is kept for browsers that support it. */
.aisc-chat-widget.aisc-chat-open .aisc-launcher,
.aisc-chat-widget:has(.aisc-chat-panel:not([hidden])) .aisc-launcher {
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
}

.aisc-chat-panel-opening .aisc-chat-panel {
	animation: aisc-panel-pop 0.42s ease-out both;
}

.aisc-chat-scene,
.aisc-chat-stage {
	width: 100%;
	height: 100%;
}

.aisc-chat-stage {
	display: flex;
	flex-direction: column;
	background:
		radial-gradient(circle at 16% 18%, rgba(96, 165, 250, 0.18) 0, rgba(96, 165, 250, 0) 30%),
		radial-gradient(circle at 88% 12%, rgba(236, 72, 153, 0.08) 0, rgba(236, 72, 153, 0) 24%),
		linear-gradient(180deg, #f9fbff 0%, #eef4ff 100%);
}

.aisc-chat-header {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 16px 18px;
	background: linear-gradient(135deg, #13213f 0%, #1d4ed8 100%);
	color: #ffffff;
}

.aisc-chat-header-text {
	display: flex;
	flex-direction: column;
	gap: 3px;
	min-width: 0;
}

.aisc-chat-title {
	display: block;
	margin: 0;
	font-size: 17px;
	font-weight: 900;
	line-height: 1.2;
	color: #ffffff;
}

.aisc-chat-role {
	display: block;
	font-size: 12px;
	font-weight: 700;
	line-height: 1.2;
	color: rgba(255, 255, 255, 0.78);
}

.aisc-chat-close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	padding: 0;
	border: 1px solid rgba(255, 255, 255, 0.22);
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.14);
	color: #ffffff;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.aisc-chat-close:hover,
.aisc-chat-close:focus {
	background: rgba(255, 255, 255, 0.23);
	border-color: rgba(255, 255, 255, 0.35);
	transform: rotate(4deg);
	outline: none;
}

.aisc-chat-scene-body {
	position: relative;
	flex: 1;
	display: grid;
	grid-template-columns: 270px minmax(0, 1fr);
	gap: 16px;
	min-height: 0;
	padding: 18px;
}

.aisc-chat-character-side {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: flex-end;
	min-height: 0;
	padding-top: 18px;
}

.aisc-chat-bubbles-side {
	display: flex;
	flex-direction: column;
	gap: 8px;
	min-width: 0;
	min-height: 0;
	overflow: visible;
}

/**
 * Image character (inside open panel).
 */

.aisc-character {
	position: relative;
	width: 238px;
	height: 414px;
	flex: 0 0 auto;
}

.aisc-character-glow {
	position: absolute;
	left: 50%;
	top: 42px;
	width: 194px;
	height: 294px;
	border-radius: 999px;
	background: radial-gradient(circle, rgba(37, 99, 235, 0.14) 0, rgba(37, 99, 235, 0) 70%);
	transform: translateX(-50%);
	pointer-events: none;
}

.aisc-character-image-wrap {
	position: absolute;
	left: 50%;
	bottom: 8px;
	width: 238px;
	height: 414px;
	transform: translateX(-50%);
	transform-origin: 50% 100%;
	animation: aisc-character-idle 4s ease-in-out infinite;
}

.aisc-character-image {
	position: absolute;
	left: 50%;
	bottom: 0;
	display: block;
	width: auto;
	height: 100%;
	max-width: none;
	transform: translateX(-50%);
	filter: drop-shadow(0 20px 18px rgba(15, 23, 42, 0.18));
	transition: opacity 0.1s linear;
	pointer-events: none;
	user-select: none;
	object-fit: contain;
}

.aisc-character-image-idle {
	opacity: 1;
}

.aisc-character-image-talking {
	opacity: 0;
}

.aisc-chat-speaking .aisc-character-image-wrap {
	animation: none;
	transform: translateX(-50%);
}

.aisc-chat-speaking .aisc-character-image {
	transition: none;
}

.aisc-chat-speaking .aisc-character-image-idle {
	opacity: 1;
	animation: aisc-mouth-closed-frame 0.34s steps(1, end) infinite;
}

.aisc-chat-speaking .aisc-character-image-talking {
	opacity: 0;
	animation: aisc-mouth-open-frame 0.34s steps(1, end) infinite;
}

.aisc-chat-talk-frame-two .aisc-character-image-wrap {
	transform: translateX(-50%);
}

.aisc-character-speaking-dots {
	position: absolute;
	left: 48px;
	top: 72px;
	display: flex;
	gap: 5px;
	opacity: 0;
	transform: translateY(6px);
	transition: opacity 0.18s ease, transform 0.18s ease;
}

.aisc-character-speaking-dots span {
	display: block;
	width: 7px;
	height: 7px;
	border-radius: 999px;
	background: #2563eb;
	box-shadow: 0 5px 12px rgba(37, 99, 235, 0.22);
	animation: aisc-speaking-dot 0.8s ease-in-out infinite;
}

.aisc-character-speaking-dots span:nth-child(2) {
	animation-delay: 0.12s;
}

.aisc-character-speaking-dots span:nth-child(3) {
	animation-delay: 0.24s;
}

.aisc-chat-speaking .aisc-character-speaking-dots {
	opacity: 1;
	transform: translateY(0);
}

.aisc-character-shadow {
	position: absolute;
	left: 50%;
	bottom: 4px;
	width: 136px;
	height: 18px;
	border-radius: 999px;
	background: rgba(15, 23, 42, 0.14);
	filter: blur(3px);
	transform: translateX(-50%);
}

.aisc-chat-character-label {
	position: relative;
	z-index: 2;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 3px;
	width: 150px;
	margin-top: 2px;
	padding: 10px 10px 9px;
	border: 1px solid rgba(37, 99, 235, 0.12);
	border-radius: 18px;
	background: rgba(255, 255, 255, 0.88);
	box-shadow: 0 10px 26px rgba(15, 23, 42, 0.08);
	backdrop-filter: blur(8px);
}

.aisc-chat-character-name {
	font-size: 13px;
	font-weight: 900;
	line-height: 1.1;
	color: #111827;
}

.aisc-chat-character-status {
	font-size: 11px;
	font-weight: 700;
	line-height: 1.1;
	color: #2563eb;
}

/**
 * Assistant bubble.
 */

.aisc-chat-assistant-bubble-wrap {
	position: relative;
	flex: 1;
	min-height: 0;
}

.aisc-chat-assistant-pointer {
	position: absolute;
	left: -12px;
	top: 56px;
	width: 30px;
	height: 30px;
	background: #ffffff;
	border-left: 1px solid rgba(37, 99, 235, 0.12);
	border-bottom: 1px solid rgba(37, 99, 235, 0.12);
	transform: rotate(45deg);
	z-index: 1;
}

.aisc-chat-assistant-bubble {
	position: relative;
	z-index: 2;
	display: flex;
	flex-direction: column;
	height: 100%;
	min-height: 270px;
	max-height: 365px;
	overflow: hidden;
	border: 1px solid rgba(37, 99, 235, 0.12);
	border-radius: 28px;
	background: #ffffff;
	box-shadow: 0 18px 44px rgba(15, 23, 42, 0.11);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.aisc-chat-speaking .aisc-chat-assistant-bubble {
	box-shadow: 0 22px 54px rgba(37, 99, 235, 0.16);
	transform: translateY(-1px);
}

.aisc-chat-messages {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 18px;
	overflow-y: auto;
	scroll-behavior: smooth;
}

.aisc-chat-message-row {
	display: flex;
	width: 100%;
}

.aisc-chat-message-new {
	animation: aisc-message-in 0.32s ease-out both;
}

.aisc-chat-message-row-assistant {
	justify-content: flex-start;
}

.aisc-chat-message-row-user {
	justify-content: flex-end;
}

.aisc-chat-message-stack {
	display: flex;
	flex-direction: column;
	gap: 5px;
	max-width: 90%;
}

.aisc-chat-message-row-user .aisc-chat-message-stack {
	align-items: flex-end;
}

.aisc-chat-message-name {
	display: inline-block;
	padding-left: 3px;
	font-size: 11px;
	font-weight: 900;
	line-height: 1.2;
	color: #2563eb;
}

.aisc-chat-message-row-user .aisc-chat-message-name {
	padding-right: 3px;
	padding-left: 0;
	color: #c2410c;
}

.aisc-chat-message {
	width: fit-content;
	max-width: 100%;
	padding: 12px 14px;
	border-radius: 18px;
	font-size: 14px;
	line-height: 1.55;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
	box-shadow: 0 8px 20px rgba(15, 23, 42, 0.07);
}

.aisc-chat-message-assistant {
	border-bottom-left-radius: 7px;
	background: #f8fbff;
	color: #172033;
	border: 1px solid rgba(37, 99, 235, 0.1);
}

.aisc-chat-message-user {
	border-bottom-right-radius: 7px;
	background: linear-gradient(135deg, #f97316 0%, #ec4899 100%);
	color: #ffffff;
}

.aisc-chat-message a,
.aisc-chat-message .aisc-chat-link {
	color: #1d4ed8;
	font-weight: 800;
	text-decoration: underline;
	text-underline-offset: 3px;
	overflow-wrap: anywhere;
	word-break: break-word;
}

.aisc-chat-message a:hover,
.aisc-chat-message a:focus,
.aisc-chat-message .aisc-chat-link:hover,
.aisc-chat-message .aisc-chat-link:focus {
	color: #0f172a;
	text-decoration-thickness: 2px;
}

.aisc-chat-message-user a,
.aisc-chat-message-user .aisc-chat-link {
	color: #ffffff;
	text-decoration-color: rgba(255, 255, 255, 0.78);
}

/**
 * Customer bubble.
 */

.aisc-chat-customer-bubble-wrap {
	position: relative;
	flex: 0 0 auto;
}

.aisc-chat-customer-pointer {
	position: absolute;
	right: 34px;
	bottom: -8px;
	width: 22px;
	height: 22px;
	background: #fff7ed;
	border-right: 1px solid rgba(249, 115, 22, 0.16);
	border-bottom: 1px solid rgba(249, 115, 22, 0.16);
	transform: rotate(45deg);
	z-index: 1;
}

.aisc-chat-form {
	position: relative;
	z-index: 2;
	margin: 0;
}

.aisc-chat-customer-bubble {
	padding: 13px;
	border: 1px solid rgba(249, 115, 22, 0.18);
	border-radius: 24px;
	background: #fff7ed;
	box-shadow: 0 16px 36px rgba(15, 23, 42, 0.1);
	transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.aisc-chat-customer-turn .aisc-chat-customer-bubble {
	border-color: rgba(249, 115, 22, 0.36);
	box-shadow: 0 18px 42px rgba(249, 115, 22, 0.14);
	transform: translateY(-1px);
}

.aisc-chat-customer-heading {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 10px;
	margin-bottom: 8px;
}

.aisc-chat-customer-name {
	font-size: 12px;
	font-weight: 900;
	line-height: 1.2;
	color: #9a3412;
}

.aisc-chat-customer-prompt {
	font-size: 11px;
	font-weight: 800;
	line-height: 1.2;
	color: #c2410c;
}

.aisc-chat-input {
	display: block;
	width: 100%;
	min-height: 54px;
	max-height: 180px;
	margin: 0;
	padding: 12px 13px;
	resize: none;
	border: 1px solid rgba(249, 115, 22, 0.24);
	border-radius: 17px;
	background: #ffffff;
	color: #172033;
	font-family: inherit;
	font-size: 14px;
	line-height: 1.45;
	box-shadow: inset 0 1px 0 rgba(15, 23, 42, 0.03);
}

.aisc-chat-input:focus {
	border-color: #f97316;
	box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.13);
	outline: none;
}

.aisc-chat-input:disabled {
	background: #f3f4f6;
	color: #6b7280;
	cursor: not-allowed;
}

.aisc-chat-form-actions {
	display: flex;
	justify-content: flex-end;
	margin-top: 9px;
}

.aisc-chat-send {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 40px;
	padding: 10px 16px;
	border: 0;
	border-radius: 999px;
	background: linear-gradient(135deg, #f97316 0%, #ec4899 100%);
	color: #ffffff;
	font-family: inherit;
	font-size: 13px;
	font-weight: 900;
	line-height: 1;
	cursor: pointer;
	box-shadow: 0 12px 24px rgba(249, 115, 22, 0.22);
	transition: filter 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.aisc-chat-send:hover,
.aisc-chat-send:focus {
	filter: brightness(1.04);
	transform: translateY(-1px);
	box-shadow: 0 16px 30px rgba(249, 115, 22, 0.28);
	outline: none;
}

.aisc-chat-send:disabled {
	background: #cbd5e1;
	box-shadow: none;
	transform: none;
	cursor: not-allowed;
	filter: none;
}

.aisc-chat-widget .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/**
 * Animations.
 */

@keyframes aisc-panel-pop {
	0% {
		opacity: 0;
		transform: translateY(10px) scale(0.98);
	}

	100% {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

/* Sophie launcher float */
@keyframes aisc-launcher-float {
	0%, 100% {
		transform: translateX(-50%) translateY(0);
	}
	50% {
		transform: translateX(-50%) translateY(-6px);
	}
}

/* Wave animation — rotates around bottom-centre */
@keyframes aisc-wave {
	0%   { transform: translateX(-50%) rotate(0deg); }
	25%  { transform: translateX(-50%) rotate(8deg); }
	75%  { transform: translateX(-50%) rotate(-5deg); }
	100% { transform: translateX(-50%) rotate(0deg); }
}

/* Bubble pop-in */
@keyframes aisc-bubble-appear {
	0% {
		opacity: 0;
		transform: translateY(6px) scale(0.95);
	}
	100% {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

@keyframes aisc-character-idle {
	0%, 100% {
		transform: translateX(-50%) translateY(0) rotate(0deg) scale(1);
	}
	50% {
		transform: translateX(-50%) translateY(-3px) rotate(-0.25deg) scale(1.001);
	}
}

@keyframes aisc-mouth-closed-frame {
	0%, 44% {
		opacity: 1;
	}
	45%, 100% {
		opacity: 0;
	}
}

@keyframes aisc-mouth-open-frame {
	0%, 44% {
		opacity: 0;
	}
	45%, 100% {
		opacity: 1;
	}
}

@keyframes aisc-speaking-dot {
	0%, 100% {
		transform: translateY(0);
		opacity: 0.45;
	}
	50% {
		transform: translateY(-5px);
		opacity: 1;
	}
}

@keyframes aisc-message-in {
	0% {
		opacity: 0;
		transform: translateY(7px) scale(0.98);
	}
	100% {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

/**
 * Responsive.
 */

@media (max-width: 760px) {
	.aisc-chat-widget {
		right: 12px;
		bottom: 0;
		left: auto;
	}

	.aisc-chat-widget.aisc-chat-open .aisc-launcher {
		display: none;
	}

	.aisc-launcher-character {
		width: 120px !important;
		height: 210px !important;
		max-width: 120px !important;
		max-height: 210px !important;
	}

	.aisc-launcher-character-wrap {
		width: 120px !important;
		height: 210px !important;
		max-width: 120px !important;
		max-height: 210px !important;
	}

	.aisc-launcher-bubble {
		bottom: 228px;
		right: 0;
		width: 290px;
		max-width: min(290px, calc(100vw - 32px));
		font-size: 12px;
	}

	.aisc-chat-panel {
		position: fixed;
		right: 8px;
		left: 8px;
		bottom: max(8px, env(safe-area-inset-bottom));
		width: auto;
		height: calc(100vh - 16px);
		height: calc(100dvh - 16px);
		max-width: none;
		max-height: none;
		border-radius: 24px;
	}

	.aisc-chat-scene-body {
		grid-template-columns: 200px minmax(0, 1fr);
		gap: 12px;
		min-height: 0;
		padding: 14px;
	}

	.aisc-chat-bubbles-side,
	.aisc-chat-assistant-bubble-wrap {
		height: 100%;
		min-height: 0;
	}

	.aisc-character {
		width: 184px;
		height: 342px;
	}

	.aisc-character-image-wrap {
		width: 184px;
		height: 342px;
	}

	.aisc-chat-character-label {
		width: 132px;
		padding: 8px;
	}

	.aisc-chat-assistant-bubble {
		height: 100%;
		min-height: 0;
		max-height: none;
	}

	.aisc-chat-messages {
		padding: 14px;
	}

	.aisc-chat-message {
		font-size: 13px;
	}

	.aisc-chat-customer-bubble {
		padding: 11px;
	}

	.aisc-chat-input {
		min-height: 46px;
		max-height: 96px;
	}
}

@media (max-width: 520px) {
	.aisc-chat-panel {
		right: 6px;
		left: 6px;
		bottom: max(6px, env(safe-area-inset-bottom));
		height: calc(100vh - 12px);
		height: calc(100dvh - 12px);
		border-radius: 20px;
	}

	.aisc-chat-header {
		padding: 12px 14px;
	}

	.aisc-chat-scene-body {
		grid-template-columns: 1fr;
		grid-template-rows: minmax(0, 1fr);
		gap: 10px;
		padding: 10px;
	}

	.aisc-chat-character-side {
		display: none;
	}

	.aisc-chat-assistant-pointer {
		display: none;
	}

	.aisc-chat-assistant-bubble {
		height: 100%;
		min-height: 0;
		max-height: none;
	}

	.aisc-launcher-bubble {
		bottom: 228px;
		right: 0;
		left: auto;
		width: min(280px, calc(100vw - 24px));
		max-width: min(280px, calc(100vw - 24px));
		white-space: pre-line;
		text-align: left;
	}
}



@media (max-height: 560px) and (max-width: 960px) {
	.aisc-chat-widget {
		right: 0;
		bottom: 0;
		left: 0;
		align-items: stretch;
	}

	.aisc-chat-widget.aisc-chat-open .aisc-launcher {
		display: none;
	}

	.aisc-launcher {
		align-self: flex-end;
		margin-right: 10px;
		max-width: min(160px, calc(100vw - 20px));
	}

	.aisc-launcher-character {
		width: 86px !important;
		height: 150px !important;
		max-width: 86px !important;
		max-height: 150px !important;
	}

	.aisc-launcher-character-wrap {
		width: 86px !important;
		height: 150px !important;
		max-width: 86px !important;
		max-height: 150px !important;
	}

	.aisc-launcher-bubble {
		display: none;
	}

	.aisc-launcher-cta {
		padding: 6px 11px;
		font-size: 11px;
	}

	.aisc-launcher-shadow {
		width: 62px;
	}

	.aisc-chat-panel {
		position: fixed;
		top: max(6px, env(safe-area-inset-top));
		right: 6px;
		bottom: max(6px, env(safe-area-inset-bottom));
		left: 6px;
		width: auto;
		height: auto;
		max-width: none;
		max-height: none;
		border-radius: 18px;
	}

	.aisc-chat-header {
		padding: 9px 12px;
	}

	.aisc-chat-title {
		font-size: 15px;
	}

	.aisc-chat-role {
		font-size: 11px;
	}

	.aisc-chat-close {
		width: 34px;
		height: 34px;
	}

	.aisc-chat-scene-body {
		grid-template-columns: 1fr;
		grid-template-rows: minmax(0, 1fr);
		gap: 8px;
		min-height: 0;
		padding: 8px;
	}

	.aisc-chat-character-side,
	.aisc-chat-assistant-pointer,
	.aisc-chat-customer-pointer {
		display: none;
	}

	.aisc-chat-bubbles-side,
	.aisc-chat-assistant-bubble-wrap {
		height: 100%;
		min-height: 0;
	}

	.aisc-chat-assistant-bubble {
		height: 100%;
		min-height: 0;
		max-height: none;
		border-radius: 18px;
	}

	.aisc-chat-messages {
		gap: 8px;
		padding: 10px;
	}

	.aisc-chat-message {
		padding: 9px 11px;
		font-size: 13px;
		line-height: 1.42;
	}

	.aisc-chat-customer-bubble {
		padding: 8px;
		border-radius: 18px;
	}

	.aisc-chat-customer-heading {
		margin-bottom: 5px;
	}

	.aisc-chat-input {
		min-height: 38px;
		max-height: 72px;
		padding: 8px 10px;
		font-size: 13px;
	}

	.aisc-chat-form-actions {
		margin-top: 6px;
	}

	.aisc-chat-send {
		min-height: 32px;
		padding: 8px 12px;
		font-size: 12px;
	}

	.aisc-chat-quick-actions {
		gap: 5px;
		margin-top: 6px;
	}

	.aisc-chat-quick-action {
		min-height: 28px;
		padding: 5px 8px;
		font-size: 10.5px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.aisc-chat-close,
	.aisc-chat-send,
	.aisc-chat-customer-bubble,
	.aisc-chat-assistant-bubble,
	.aisc-character-image,
	.aisc-launcher-cta {
		transition: none;
	}

	.aisc-launcher-character-wrap,
	.aisc-character-image-wrap,
	.aisc-character-speaking-dots span,
	.aisc-chat-message-new,
	.aisc-chat-panel-opening .aisc-chat-panel,
	.aisc-chat-speaking .aisc-character-image-idle,
	.aisc-chat-speaking .aisc-character-image-talking,
	.aisc-launcher-bubble {
		animation: none;
		opacity: 1;
	}

	.aisc-chat-messages {
		scroll-behavior: auto;
	}
}

/**
 * Firefox layout correction.
 */
@-moz-document url-prefix() {
	.aisc-chat-panel {
		height: 590px;
		max-height: calc(100vh - 128px);
	}

	.aisc-chat-scene-body {
		grid-template-columns: 250px minmax(0, 1fr);
		gap: 14px;
		padding: 16px;
	}

	.aisc-chat-character-side {
		padding-top: 34px;
	}

	.aisc-character {
		width: 218px;
		height: 382px;
	}

	.aisc-character-image-wrap {
		width: 218px;
		height: 382px;
	}

	.aisc-character-glow {
		width: 178px;
		height: 272px;
	}

	.aisc-chat-character-label {
		margin-top: 0;
	}

	.aisc-chat-assistant-bubble {
		max-height: 382px;
	}

	.aisc-chat-messages {
		scrollbar-gutter: stable;
	}
}

/**
 * Quick action buttons inside Sophie message area.
 */
.aisc-chat-quick-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	gap: 8px;
	max-width: 100%;
	margin-top: 8px;
	padding-bottom: 2px;
}

.aisc-chat-quick-action {
	appearance: none;
	-webkit-appearance: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 34px;
	max-width: 100%;
	padding: 8px 12px;
	border: 1px solid rgba(37, 99, 235, 0.26);
	border-radius: 999px;
	background: linear-gradient(135deg, #183572 0%, #2451d8 100%);
	box-shadow: 0 8px 18px rgba(37, 99, 235, 0.18);
	color: #ffffff;
	font-family: inherit;
	font-size: 12px;
	font-weight: 900;
	line-height: 1.2;
	text-align: center;
	text-transform: none;
	white-space: normal;
	cursor: pointer;
	transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

.aisc-chat-quick-action:hover,
.aisc-chat-quick-action:focus {
	box-shadow: 0 10px 22px rgba(37, 99, 235, 0.25);
	filter: brightness(1.04);
	outline: none;
	transform: translateY(-1px);
}

.aisc-chat-quick-action:active {
	box-shadow: 0 5px 14px rgba(37, 99, 235, 0.2);
	transform: translateY(0);
}

.aisc-chat-form-busy ~ .aisc-chat-quick-actions,
.aisc-chat-quick-action:disabled {
	cursor: not-allowed;
	opacity: 0.68;
}

@media (max-width: 640px) {
	.aisc-chat-quick-actions {
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 6px;
	}

	.aisc-chat-quick-action {
		min-height: 32px;
		padding: 7px 10px;
		font-size: 11px;
	}
}
