.mys-chat {
	--mys-ink: #102018;
	--mys-green: #185f42;
	--mys-green-soft: #e9eee7;
	--mys-line: #e2e8e4;
	--mys-paper: #fbfcfb;
	--mys-muted: #5c6b63;
	--mys-radius: 16px;
	--mys-shadow: 0 18px 48px -12px rgba(16, 32, 24, .34), 0 4px 12px -4px rgba(16, 32, 24, .12);
	font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	font-size: 15px;
	line-height: 1.5;
}

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

/* ---------- Bouton flottant ---------- */

.mys-chat__launcher {
	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: 99998;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 58px;
	height: 58px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--mys-ink);
	color: #fff;
	cursor: pointer;
	box-shadow: 0 10px 28px -6px rgba(16, 32, 24, .45);
	transition: transform .22s ease, background-color .22s ease, box-shadow .22s ease;
}

.mys-chat__launcher:hover {
	background: var(--mys-green);
	transform: translateY(-2px);
	box-shadow: 0 14px 32px -6px rgba(24, 95, 66, .5);
}

.mys-chat__launcher:focus-visible {
	outline: 3px solid var(--mys-green);
	outline-offset: 3px;
}

.mys-chat__launcher svg {
	width: 26px;
	height: 26px;
	transition: opacity .18s ease, transform .18s ease;
}

.mys-chat__launcher .mys-chat__icon-close,
.mys-chat[data-open="true"] .mys-chat__launcher .mys-chat__icon-open {
	position: absolute;
	opacity: 0;
	transform: scale(.6) rotate(-20deg);
}

.mys-chat[data-open="true"] .mys-chat__launcher .mys-chat__icon-close {
	position: static;
	opacity: 1;
	transform: none;
}

/* Pastille d'appel, cachee des que le chat a ete ouvert une fois. */
.mys-chat__badge {
	position: absolute;
	top: 2px;
	right: 2px;
	width: 13px;
	height: 13px;
	border: 2px solid #fff;
	border-radius: 50%;
	background: #e0603a;
}

.mys-chat[data-seen="true"] .mys-chat__badge,
.mys-chat[data-open="true"] .mys-chat__badge {
	display: none;
}

/* ---------- Panneau ---------- */

.mys-chat__panel {
	position: fixed;
	right: 24px;
	bottom: 94px;
	z-index: 99999;
	display: flex;
	flex-direction: column;
	width: 396px;
	max-width: calc(100vw - 32px);
	height: 620px;
	max-height: calc(100vh - 130px);
	overflow: hidden;
	border: 1px solid var(--mys-line);
	border-radius: var(--mys-radius);
	background: #fff;
	box-shadow: var(--mys-shadow);
	opacity: 0;
	transform: translateY(14px) scale(.98);
	transform-origin: bottom right;
	pointer-events: none;
	/* visibility coupe aussi l'ordre de tabulation quand le panneau est ferme */
	visibility: hidden;
	transition: opacity .2s ease, transform .2s ease, visibility .2s;
}

.mys-chat[data-open="true"] .mys-chat__panel {
	opacity: 1;
	transform: none;
	pointer-events: auto;
	visibility: visible;
}

/* ---------- En-tete ---------- */

.mys-chat__header {
	display: flex;
	gap: 12px;
	align-items: center;
	padding: 16px 16px 15px 18px;
	background: linear-gradient(135deg, #102018 0%, #17392a 100%);
	color: #fff;
}

.mys-chat__avatar {
	flex: none;
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: #fff;
	object-fit: contain;
	padding: 4px;
}

.mys-chat__titles {
	flex: 1;
	min-width: 0;
}

.mys-chat__title {
	margin: 0;
	font-size: 15px;
	font-weight: 600;
	letter-spacing: -.01em;
}

.mys-chat__subtitle {
	display: flex;
	gap: 6px;
	align-items: center;
	margin-top: 2px;
	color: rgba(255, 255, 255, .72);
	font-size: 12.5px;
}

.mys-chat__dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #5fd39b;
}

.mys-chat__close {
	flex: none;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: 8px;
	background: rgba(255, 255, 255, .1);
	color: #fff;
	cursor: pointer;
	transition: background-color .18s ease;
}

.mys-chat__close:hover {
	background: rgba(255, 255, 255, .22);
}

.mys-chat__close:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

.mys-chat__close svg {
	width: 17px;
	height: 17px;
}

/* ---------- Fil de discussion ---------- */

.mys-chat__log {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 18px 16px 8px;
	overflow-y: auto;
	background: var(--mys-paper);
	scrollbar-width: thin;
	scrollbar-color: #cfd8d2 transparent;
}

.mys-chat__log::-webkit-scrollbar {
	width: 8px;
}

.mys-chat__log::-webkit-scrollbar-thumb {
	border: 2px solid transparent;
	border-radius: 8px;
	background: #cfd8d2;
	background-clip: content-box;
}

.mys-chat__msg {
	max-width: 86%;
	padding: 10px 14px;
	font-size: 14.5px;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
	animation: mys-chat-in .24s ease both;
}

.mys-chat__msg--bot {
	align-self: flex-start;
	border: 1px solid var(--mys-line);
	border-radius: 14px 14px 14px 5px;
	background: #fff;
	color: #1b2b22;
	box-shadow: 0 1px 2px rgba(16, 32, 24, .04);
}

.mys-chat__msg--user {
	align-self: flex-end;
	border-radius: 14px 14px 5px 14px;
	background: var(--mys-ink);
	color: #fff;
}

.mys-chat__msg--error {
	align-self: flex-start;
	border: 1px solid #f0d4c9;
	border-radius: 14px 14px 14px 5px;
	background: #fdf5f2;
	color: #8a3b1d;
}

.mys-chat__msg b {
	font-weight: 600;
}

.mys-chat__msg a {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 2px;
}

@keyframes mys-chat-in {
	from { opacity: 0; transform: translateY(6px); }
	to { opacity: 1; transform: none; }
}

/* ---------- Indicateur de frappe ---------- */

.mys-chat__typing {
	display: flex;
	gap: 4px;
	align-self: flex-start;
	padding: 13px 15px;
	border: 1px solid var(--mys-line);
	border-radius: 14px 14px 14px 5px;
	background: #fff;
}

.mys-chat__typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #9fb1a7;
	animation: mys-chat-bounce 1.3s infinite ease-in-out;
}

.mys-chat__typing span:nth-child(2) { animation-delay: .16s; }
.mys-chat__typing span:nth-child(3) { animation-delay: .32s; }

@keyframes mys-chat-bounce {
	0%, 60%, 100% { opacity: .35; transform: translateY(0); }
	30% { opacity: 1; transform: translateY(-4px); }
}

/* ---------- Boutons de questions ---------- */

.mys-chat__suggestions {
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
	padding: 6px 16px 14px;
	background: var(--mys-paper);
}

.mys-chat__suggestions[hidden] {
	display: none;
}

.mys-chat__suggestions-label {
	width: 100%;
	margin: 0 0 2px;
	color: var(--mys-muted);
	font-size: 11.5px;
	font-weight: 500;
	letter-spacing: .04em;
	text-transform: uppercase;
}

.mys-chat__chip {
	padding: 8px 13px;
	border: 1px solid #d5ded8;
	border-radius: 999px;
	background: #fff;
	color: var(--mys-ink);
	font: inherit;
	font-size: 13px;
	line-height: 1.25;
	text-align: left;
	cursor: pointer;
	transition: background-color .16s ease, border-color .16s ease, transform .16s ease;
}

.mys-chat__chip:hover {
	border-color: var(--mys-green);
	background: var(--mys-green-soft);
	transform: translateY(-1px);
}

.mys-chat__chip:focus-visible {
	outline: 2px solid var(--mys-green);
	outline-offset: 2px;
}

/* ---------- Saisie ---------- */

.mys-chat__form {
	display: flex;
	gap: 9px;
	align-items: flex-end;
	padding: 12px 14px;
	border-top: 1px solid var(--mys-line);
	background: #fff;
}

.mys-chat__input {
	flex: 1;
	max-height: 110px;
	padding: 10px 13px;
	border: 1px solid #d5ded8;
	border-radius: 11px;
	background: var(--mys-paper);
	color: #1b2b22;
	font: inherit;
	font-size: 14.5px;
	line-height: 1.45;
	resize: none;
	transition: border-color .16s ease, box-shadow .16s ease;
}

.mys-chat__input::placeholder {
	color: #93a39a;
}

.mys-chat__input:focus {
	border-color: var(--mys-green);
	outline: 0;
	box-shadow: 0 0 0 3px rgba(24, 95, 66, .13);
}

.mys-chat__send {
	flex: none;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 11px;
	background: var(--mys-green);
	color: #fff;
	cursor: pointer;
	transition: background-color .16s ease, opacity .16s ease;
}

.mys-chat__send:hover:not(:disabled) {
	background: #114931;
}

.mys-chat__send:disabled {
	opacity: .4;
	cursor: not-allowed;
}

.mys-chat__send:focus-visible {
	outline: 2px solid var(--mys-ink);
	outline-offset: 2px;
}

.mys-chat__send svg {
	width: 19px;
	height: 19px;
}

/* ---------- Images pour la maquette ---------- */

.mys-chat__form {
	position: relative;
}

.mys-chat__attach {
	flex: none;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 1px solid #d5ded8;
	border-radius: 11px;
	background: #fff;
	color: var(--mys-muted);
	cursor: pointer;
	transition: border-color .16s ease, color .16s ease, background-color .16s ease;
}

.mys-chat__attach:hover:not(:disabled),
.mys-chat__attach[aria-expanded="true"] {
	border-color: var(--mys-green);
	background: var(--mys-green-soft);
	color: var(--mys-green);
}

.mys-chat__attach:disabled {
	opacity: .4;
	cursor: not-allowed;
}

.mys-chat__attach:focus-visible {
	outline: 2px solid var(--mys-ink);
	outline-offset: 2px;
}

.mys-chat__attach svg {
	width: 19px;
	height: 19px;
}

.mys-chat__attach-menu {
	position: absolute;
	right: 14px;
	bottom: calc(100% + 6px);
	left: 14px;
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 10px;
	border: 1px solid var(--mys-line);
	border-radius: 12px;
	background: #fff;
	box-shadow: 0 10px 28px -8px rgba(16, 32, 24, .28);
	animation: mys-chat-in .18s ease both;
}

.mys-chat__attach-menu[hidden] {
	display: none;
}

.mys-chat__attach-option {
	padding: 10px 12px;
	border: 1px solid #d5ded8;
	border-radius: 9px;
	background: #fff;
	color: var(--mys-ink);
	font: inherit;
	font-size: 14px;
	font-weight: 500;
	text-align: left;
	cursor: pointer;
	transition: background-color .16s ease, border-color .16s ease;
}

.mys-chat__attach-option:hover {
	border-color: var(--mys-green);
	background: var(--mys-green-soft);
}

.mys-chat__attach-option:focus-visible {
	outline: 2px solid var(--mys-green);
	outline-offset: 2px;
}

.mys-chat__attach-note {
	margin: 2px 2px 0;
	color: var(--mys-muted);
	font-size: 11.5px;
	line-height: 1.4;
}

.mys-chat__msg--images {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 6px;
}

.mys-chat__msg--images img {
	width: 72px;
	height: 72px;
	border-radius: 9px;
	object-fit: cover;
	background: rgba(255, 255, 255, .12);
}

.mys-chat__legal {
	padding: 0 14px 11px;
	background: #fff;
	color: var(--mys-muted);
	font-size: 11px;
	text-align: center;
}

.mys-chat__legal a {
	color: var(--mys-muted);
}

/* ---------- Mobile ---------- */

@media (max-width: 520px) {
	.mys-chat__panel {
		right: 0;
		bottom: 0;
		width: 100%;
		max-width: 100%;
		height: 88vh;
		height: 88dvh;
		max-height: none;
		border-right: 0;
		border-bottom: 0;
		border-left: 0;
		border-radius: 18px 18px 0 0;
	}

	.mys-chat__launcher {
		right: 16px;
		bottom: 16px;
	}

	.mys-chat[data-open="true"] .mys-chat__launcher {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.mys-chat *,
	.mys-chat *::before,
	.mys-chat *::after {
		animation-duration: .01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: .01ms !important;
	}
}
