:root {
	--sa-ink: #16232F;
	--sa-ink-2: #1E3040;
	--sa-amber: #F2A93B;
	--sa-steel: #8B98A6;
	--sa-paper: #F6F4EF;
	--sa-green: #3FA66B;
	--sa-line: #2E4356;
}

#sa-widget-root { position: fixed; bottom: 20px; right: 20px; z-index: 999999; font-family: 'Inter', sans-serif; }

/* Bubble - hex bolt-head with a slowly rotating ratchet ring (signature element) */
.sa-bubble-wrap { position: relative; width: 76px; height: 76px; }

.sa-bubble {
	position: absolute; inset: 0; border-radius: 50%;
	background: #E8875A; border: none; cursor: pointer;
	box-shadow: 0 8px 20px rgba(30,15,5,0.28);
	display: flex; align-items: center; justify-content: center;
	transition: transform 0.2s ease;
	animation: sa-bob 3.2s ease-in-out infinite;
	transform-origin: 50% 85%;
}
.sa-bubble:hover { animation-play-state: paused; transform: translateY(-3px) scale(1.04); }
@keyframes sa-bob { 0%, 100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-3px) rotate(-1.2deg); } }

.sa-bubble svg { width: 66px; height: 66px; }
.sa-face-eyes { animation: sa-blink 4.5s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }
@keyframes sa-blink { 0%, 92%, 100% { transform: scaleY(1); } 96% { transform: scaleY(0.1); } }
.sa-face-eyes { animation: sa-blink 4.5s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }
@keyframes sa-blink {
	0%, 92%, 100% { transform: scaleY(1); }
	95% { transform: scaleY(0.15); }
}

/* Proactive speech bubble - pops up next to the character */
.sa-teaser {
	position: absolute; bottom: 8px; right: 74px;
	max-width: 200px; background: #fff; color: #23303B;
	padding: 10px 14px; border-radius: 14px;
	font-size: 13.5px; line-height: 1.4;
	box-shadow: 0 6px 18px rgba(30,15,5,0.18);
	opacity: 0; transform: translateY(6px) scale(0.96);
	transition: opacity 0.2s ease, transform 0.2s ease;
	pointer-events: none;
	white-space: normal;
}
.sa-teaser.sa-teaser-show { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; cursor: pointer; }
.sa-teaser::after {
	content: ''; position: absolute; right: -6px; bottom: 14px;
	width: 12px; height: 12px; background: #fff;
	clip-path: polygon(0 0, 100% 50%, 0 100%);
}
.sa-teaser-close {
	position: absolute; top: -6px; right: -6px; width: 18px; height: 18px;
	background: var(--sa-steel); color: #fff; border: 2px solid var(--sa-paper);
	border-radius: 50%; font-size: 11px; line-height: 1; cursor: pointer;
	display: flex; align-items: center; justify-content: center;
}

.sa-status-dot {
	position: absolute; bottom: 1px; right: 1px;
	width: 13px; height: 13px; border-radius: 50%;
	background: var(--sa-green); border: 2px solid var(--sa-paper);
	z-index: 2;
}
.sa-status-dot::after {
	content: ''; position: absolute; inset: -4px; border-radius: 50%;
	border: 1px solid var(--sa-green); opacity: 0; animation: sa-ring 2.4s ease-out infinite;
}
@keyframes sa-ring { 0% { opacity: 0.6; transform: scale(0.6); } 100% { opacity: 0; transform: scale(1.6); } }

/* Window - scanner-frame corner brackets */
.sa-window {
	display: none;
	width: 368px; max-width: 92vw; height: 490px; max-height: 74vh;
	background: var(--sa-paper); border-radius: 4px;
	box-shadow: 0 20px 50px rgba(10,16,22,0.35);
	position: absolute; bottom: 76px; right: 0;
	flex-direction: column; overflow: visible;
	opacity: 0; transform: translateY(14px) scale(0.97);
	transition: opacity 0.2s ease, transform 0.2s ease;
}
.sa-window.sa-open { display: flex; opacity: 1; transform: translateY(0) scale(1); }
@media (prefers-reduced-motion: reduce) {
	.sa-window, .sa-bubble, .sa-status-dot::after { transition: none; animation: none; }
}

.sa-window-inner { display: flex; flex-direction: column; flex: 1; overflow: hidden; border-radius: 4px; }

.sa-window::before, .sa-window::after,
.sa-window-inner::before, .sa-window-inner::after { display: none; }

.sa-corner { position: absolute; width: 16px; height: 16px; border-color: var(--sa-amber); z-index: 2; pointer-events: none; }
.sa-corner.tl { top: -6px; left: -6px; border-top: 2px solid; border-left: 2px solid; }
.sa-corner.br { bottom: -6px; right: -6px; border-bottom: 2px solid; border-right: 2px solid; }

/* Header - scan-line texture */
.sa-header {
	background:
		repeating-linear-gradient(180deg, rgba(255,255,255,0.025) 0px, rgba(255,255,255,0.025) 1px, transparent 1px, transparent 4px),
		linear-gradient(135deg, var(--sa-ink-2), var(--sa-ink));
	color: #fff; padding: 15px 16px;
	display: flex; justify-content: space-between; align-items: flex-start;
	border-bottom: 2px solid var(--sa-amber);
	gap: 8px;
}
.sa-header-title { display: flex; flex-direction: column; gap: 3px; }
.sa-header-eyebrow {
	font-family: 'IBM Plex Mono', monospace; font-size: 10px; letter-spacing: 0.16em;
	color: var(--sa-amber); text-transform: uppercase; display: flex; align-items: center; gap: 6px;
}
.sa-header-eyebrow::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--sa-green); display: inline-block; }
.sa-header-name { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 17px; letter-spacing: -0.01em; }
.sa-header button { background: none; border: none; color: #fff; font-size: 20px; cursor: pointer; opacity: 0.65; line-height: 1; padding: 2px; }
.sa-header button:hover { opacity: 1; }

.sa-lang-select {
	font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: 0.03em;
	background: rgba(255,255,255,0.08); color: var(--sa-amber);
	border: 1px solid rgba(242,169,59,0.4); border-radius: 4px;
	padding: 5px 6px; cursor: pointer; margin-top: 1px; margin-left: auto;
	max-width: 58px;
}
.sa-lang-select:focus { outline: none; border-color: var(--sa-amber); }
.sa-lang-select option { color: var(--sa-ink); background: #fff; }

/* Messages */
.sa-messages { flex: 1; overflow-y: auto; padding: 16px 14px; background: var(--sa-paper); }
.sa-msg { margin-bottom: 11px; max-width: 86%; padding: 10px 13px; border-radius: 3px; font-size: 14px; line-height: 1.5; word-break: break-word; overflow-wrap: anywhere; white-space: pre-line; }
.sa-msg.user {
	background: var(--sa-ink); color: #fff; margin-left: auto;
	border-radius: 8px 8px 2px 8px;
}
.sa-msg.assistant {
	background: #fff; color: #23303B; margin-right: auto;
	border-left: 2px solid var(--sa-amber);
	border-radius: 2px 8px 8px 2px;
	box-shadow: 0 1px 3px rgba(22,35,47,0.08);
}

/* RTL adjustments (Arabic) - mirror the accent border and bubble corners */
.sa-window.sa-rtl .sa-msg.assistant {
	border-left: none;
	border-right: 2px solid var(--sa-amber);
	border-radius: 8px 2px 2px 8px;
}
.sa-window.sa-rtl .sa-msg.user {
	border-radius: 8px 8px 8px 2px;
}
.sa-window.sa-rtl .sa-input-row input {
	text-align: right;
}

.sa-typing { display: flex; gap: 4px; padding: 11px 13px; }
.sa-typing span {
	width: 5px; height: 5px; border-radius: 50%; background: var(--sa-steel);
	animation: sa-typing-bounce 1.2s infinite ease-in-out;
}
.sa-typing span:nth-child(2) { animation-delay: 0.15s; }
.sa-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes sa-typing-bounce { 0%, 60%, 100% { opacity: 0.25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-2px); } }

/* Quick-action chips with icons */
.sa-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 14px; }
.sa-chip {
	display: flex; align-items: center; gap: 5px;
	font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: 0.01em;
	background: #fff; border: 1px solid #E1DACB; color: var(--sa-ink);
	padding: 7px 11px; border-radius: 5px; cursor: pointer;
	transition: border-color 0.12s ease, color 0.12s ease;
}
.sa-chip svg { width: 12px; height: 12px; flex-shrink: 0; }
.sa-chip:hover { border-color: var(--sa-amber); color: #B8791F; }

/* Input row */
.sa-input-row { display: flex; border-top: 1px solid #E1DACB; background: #fff; }
.sa-input-row input { flex: 1; border: none; padding: 14px; font-size: 14px; outline: none; background: transparent; color: var(--sa-ink); }
.sa-input-row input::placeholder { color: var(--sa-steel); }
.sa-input-row button {
	background: var(--sa-ink); color: var(--sa-amber); border: none; padding: 0 20px; cursor: pointer;
	font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 13px;
	display: flex; align-items: center; gap: 6px;
}
.sa-input-row button svg { width: 14px; height: 14px; }
.sa-input-row button:hover { background: var(--sa-ink-2); }