/* ── Онлайн-чат: кнопка и окно до подключения виджета ─────────────────
 * Виджет Libredesk рисует своё окно сам; здесь только наш первый экран:
 * приветствие, вопрос, контакты. Токены цвета и радиусов — из main.css.
 */
.yx-chat {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 90;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 12px;
	font-family: var(--body);
	color: var(--ink);
}

/* кнопка */
.yx-chat-launcher {
	display: flex;
	align-items: center;
	gap: 12px;
	min-height: 56px;
	padding: 8px 18px 8px 10px;
	border: 1px solid color-mix(in oklch, var(--paper) 18%, transparent);
	border-radius: 999px;
	background: var(--ink);
	color: var(--paper);
	box-shadow: 0 18px 40px -18px color-mix(in oklch, var(--ink) 60%, transparent);
	cursor: pointer;
	text-align: left;
	transition: transform var(--dur-ui) var(--ease-out), background var(--dur-ui) var(--ease-out);
}
.yx-chat-launcher:hover,
.yx-chat-launcher:focus-visible { background: var(--ink-hover); transform: translateY(-1px); }
.yx-chat-launcher:focus-visible { outline: 2px solid var(--coral); outline-offset: 3px; }
.yx-chat-launcher-icon {
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: var(--coral);
	color: var(--paper);
	flex: none;
}
.yx-chat-launcher-icon svg { width: 22px; height: 22px; }
.yx-chat-launcher-text { display: flex; flex-direction: column; gap: 2px; line-height: 1.15; }
.yx-chat-launcher-text b { font-family: var(--sans); font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.yx-chat-launcher-text small { font-size: 11.5px; opacity: 0.72; }
.yx-chat.is-open .yx-chat-launcher { display: none; }

/* окно */
.yx-chat-panel[hidden] { display: none; }
.yx-chat-panel {
	/* Тема даёт `section` отступ 88px сверху и снизу — окно держим без него. */
	padding: 0;
	margin: 0;
	width: min(400px, calc(100vw - 40px));
	height: min(620px, calc(100vh - 40px));
	display: flex;
	flex-direction: column;
	background: var(--paper);
	border: 1px solid var(--line);
	border-radius: 10px;
	box-shadow: var(--shadow), 0 0 0 1px color-mix(in oklch, var(--ink) 4%, transparent);
	overflow: hidden;
	animation: yx-chat-in var(--dur-enter) var(--ease-out);
}
@keyframes yx-chat-in {
	from { opacity: 0; transform: translateY(12px) scale(0.98); }
	to { opacity: 1; transform: none; }
}
.yx-chat-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 14px 14px 14px 18px;
	background: var(--ink);
	color: var(--paper);
}
.yx-chat-brand { display: flex; align-items: center; gap: 10px; font-family: var(--sans); font-size: 14px; font-weight: 600; letter-spacing: 0.02em; }
.yx-chat-dot { width: 9px; height: 9px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 3px color-mix(in oklch, #4ade80 30%, transparent); }
.yx-chat-close {
	display: grid;
	place-items: center;
	width: 36px;
	height: 36px;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	cursor: pointer;
}
.yx-chat-close:hover,
.yx-chat-close:focus-visible { background: color-mix(in oklch, var(--paper) 14%, transparent); }
.yx-chat-close svg { width: 20px; height: 20px; }

.yx-chat-log {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 18px 16px 8px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: var(--paper-warm);
	overscroll-behavior: contain;
}
.yx-msg { max-width: 86%; padding: 11px 14px; border-radius: 12px; font-size: 14.5px; line-height: 1.45; animation: yx-chat-in var(--dur-ui) var(--ease-out); }
.yx-msg p { margin: 0; }
.yx-msg-bot { align-self: flex-start; background: var(--paper); border: 1px solid var(--line-soft); border-bottom-left-radius: 4px; }
.yx-msg-user { align-self: flex-end; background: var(--ink); color: var(--paper); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.yx-msg-pending { color: var(--ink-faint); font-style: italic; }
.yx-msg-error { border-color: color-mix(in oklch, var(--coral) 45%, transparent); background: color-mix(in oklch, var(--coral) 8%, var(--paper)); }

.yx-chat-foot { flex: none; padding: 12px 16px 16px; border-top: 1px solid var(--line-soft); background: var(--paper); }
.yx-foot-choice { display: flex; flex-direction: column; gap: 10px; }
.yx-choice { width: 100%; justify-content: center; }
.yx-foot-choice .yx-composer { margin-top: 2px; }

/* поле ввода вопроса */
.yx-composer { position: relative; display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.yx-composer textarea {
	flex: 1 1 auto;
	min-width: 0;
	min-height: 46px;
	max-height: 140px;
	padding: 12px 14px;
	border: 1px solid var(--line);
	border-radius: var(--r-control);
	background: var(--paper);
	color: var(--ink);
	font: inherit;
	font-size: 15px;
	line-height: 1.4;
	resize: none;
}
.yx-composer textarea:focus { outline: 2px solid var(--ink); outline-offset: 1px; border-color: transparent; }
.yx-send {
	flex: none;
	display: grid;
	place-items: center;
	width: 46px;
	height: 46px;
	border: 0;
	border-radius: var(--r-control);
	background: var(--coral);
	color: var(--paper);
	cursor: pointer;
}
.yx-send:hover,
.yx-send:focus-visible { background: var(--coral-press); }
.yx-send svg { width: 22px; height: 22px; }

/* форма контактов */
.yx-contacts { display: flex; flex-direction: column; gap: 10px; }
.yx-field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--ink-faint); }
.yx-field input {
	padding: 11px 13px;
	border: 1px solid var(--line);
	border-radius: var(--r-control);
	background: var(--paper);
	color: var(--ink);
	font: inherit;
	font-size: 15px;
}
.yx-field input:focus { outline: 2px solid var(--ink); outline-offset: 1px; border-color: transparent; }
.yx-field input.is-invalid { border-color: var(--coral); }
.yx-consent { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; font-size: 12.5px; line-height: 1.4; color: var(--ink-mute); }
.yx-consent input { margin-top: 2px; accent-color: var(--ink); }
.yx-consent a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
.yx-error { flex-basis: 100%; font-size: 12.5px; color: var(--coral); }
.yx-submit { width: 100%; justify-content: center; }

/* телефон: окно во весь экран, поле ввода не уезжает под клавиатуру */
@media (max-width: 640px) {
	.yx-chat { right: 12px; bottom: 12px; }
	.yx-chat-launcher { min-height: 50px; padding: 6px 14px 6px 7px; }
	.yx-chat-launcher-icon { width: 36px; height: 36px; }
	.yx-chat-launcher-text small { display: none; }
	.yx-chat.is-open { inset: 0; right: 0; bottom: 0; }
	.yx-chat-panel {
		width: 100vw;
		height: 100dvh;
		border-radius: 0;
		border: 0;
		animation: none;
	}
	.yx-chat-head { padding-top: max(14px, env(safe-area-inset-top)); }
	.yx-chat-foot { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
	.yx-chat-panel, .yx-msg { animation: none; }
	.yx-chat-launcher { transition: none; }
}
