/* Лофтовик — онлайн-чат. Все классы с префиксом lchat-, чтобы не конфликтовать с темой. */
.lchat-root {
	--lc-accent: #c8742c;
	--lc-dark: #232323;
	--lc-bg: #f6f3ef;
	--lc-bubble: #ffffff;
	--lc-text: #1f1f1f;
	--lc-muted: #8a8580;
	--lc-line: #e6e0d8;
	--lc-bottom: 90px;
	--lc-side: 20px;
	position: fixed;
	bottom: var(--lc-bottom);
	z-index: 99990;
	font-family: inherit;
	font-size: 15px;
	line-height: 1.45;
	color: var(--lc-text);
	-webkit-font-smoothing: antialiased;
}
.lchat-root.lchat-right { right: var(--lc-side); }
.lchat-root.lchat-left { left: var(--lc-side); }
.lchat-root *, .lchat-root *::before, .lchat-root *::after { box-sizing: border-box; }
.lchat-root button { font-family: inherit; }

/* Кнопка */
.lchat-launcher {
	position: relative;
	width: 62px; height: 62px;
	border-radius: 50%;
	border: 0;
	padding: 0;
	cursor: pointer;
	background: var(--lc-accent);
	color: #fff;
	box-shadow: 0 8px 24px rgba(0,0,0,.22), 0 2px 6px rgba(0,0,0,.12);
	display: flex; align-items: center; justify-content: center;
	transition: transform .2s ease, box-shadow .2s ease;
}
.lchat-launcher:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(0,0,0,.26); }
.lchat-launcher:focus-visible { outline: 3px solid var(--lc-dark); outline-offset: 3px; }
.lchat-launcher svg { width: 28px; height: 28px; transition: transform .25s ease, opacity .2s ease; position: absolute; }
.lchat-launcher .lchat-ico-close { opacity: 0; transform: rotate(-90deg) scale(.6); }
.lchat-open .lchat-launcher .lchat-ico-chat { opacity: 0; transform: rotate(90deg) scale(.6); }
.lchat-open .lchat-launcher .lchat-ico-close { opacity: 1; transform: none; }
.lchat-launcher::after {
	content: ""; position: absolute; inset: 0; border-radius: 50%;
	border: 2px solid var(--lc-accent);
	animation: lchat-pulse 2.6s ease-out infinite;
	pointer-events: none;
}
.lchat-open .lchat-launcher::after, .lchat-touched .lchat-launcher::after { display: none; }
@keyframes lchat-pulse { 0% { transform: scale(1); opacity: .7; } 70%,100% { transform: scale(1.45); opacity: 0; } }

.lchat-badge {
	position: absolute; top: -2px; right: -2px;
	min-width: 20px; height: 20px; padding: 0 6px;
	border-radius: 10px; background: #e0392b; color: #fff;
	font-size: 12px; font-weight: 700; line-height: 20px; text-align: center;
	border: 2px solid #fff;
	display: none;
}
.lchat-badge.lchat-show { display: block; }

/* Подсказка у кнопки */
.lchat-teaser {
	position: absolute; bottom: 8px;
	width: max-content; max-width: 240px;
	background: #fff; color: var(--lc-text);
	padding: 10px 30px 10px 14px; border-radius: 14px;
	box-shadow: 0 6px 24px rgba(0,0,0,.16);
	font-size: 14px; cursor: pointer;
	opacity: 0; transform: translateY(6px); pointer-events: none;
	transition: opacity .25s ease, transform .25s ease;
}
.lchat-right .lchat-teaser { right: 76px; border-bottom-right-radius: 4px; }
.lchat-left .lchat-teaser { left: 76px; border-bottom-left-radius: 4px; }
.lchat-teaser.lchat-show { opacity: 1; transform: none; pointer-events: auto; }
.lchat-teaser-x {
	position: absolute; top: 4px; right: 4px; width: 22px; height: 22px;
	border: 0; background: none; color: var(--lc-muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 0;
}

/* Окно */
.lchat-window {
	position: absolute; bottom: 76px;
	width: 370px; height: min(600px, calc(100vh - var(--lc-bottom) - 100px));
	min-height: 360px;
	background: var(--lc-bg);
	border-radius: 18px;
	box-shadow: 0 18px 50px rgba(0,0,0,.28), 0 4px 12px rgba(0,0,0,.1);
	display: flex; flex-direction: column; overflow: hidden;
	opacity: 0; transform: translateY(14px) scale(.98); pointer-events: none; visibility: hidden;
	transition: opacity .22s ease, transform .22s ease, visibility 0s linear .22s;
}
.lchat-right .lchat-window { right: 0; transform-origin: bottom right; }
.lchat-left .lchat-window { left: 0; transform-origin: bottom left; }
.lchat-open .lchat-window {
	opacity: 1; transform: none; pointer-events: auto; visibility: visible;
	transition: opacity .22s ease, transform .22s ease, visibility 0s;
}

/* Шапка */
.lchat-head {
	background: var(--lc-dark);
	/* Фактура «кирпич/металл» лёгкими линиями — под стиль лофт */
	background-image:
		linear-gradient(135deg, rgba(255,255,255,.04) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.04) 50%, rgba(255,255,255,.04) 75%, transparent 75%);
	background-size: 14px 14px;
	color: #fff;
	padding: 14px 12px 14px 16px;
	display: flex; align-items: center; gap: 12px;
	flex-shrink: 0;
	border-bottom: 3px solid var(--lc-accent);
}
.lchat-avatar {
	width: 42px; height: 42px; border-radius: 50%;
	background: var(--lc-accent); color: #fff;
	display: flex; align-items: center; justify-content: center;
	font-weight: 800; font-size: 19px; flex-shrink: 0;
	position: relative; overflow: visible;
}
.lchat-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.lchat-avatar::after {
	content: ""; position: absolute; right: 0; bottom: 1px;
	width: 11px; height: 11px; border-radius: 50%;
	background: #3ecf6e; border: 2px solid var(--lc-dark);
}
.lchat-titles { flex: 1; min-width: 0; }
.lchat-title { font-weight: 700; font-size: 16px; letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lchat-sub { font-size: 12.5px; opacity: .72; margin-top: 1px; }
.lchat-head-actions { display: flex; align-items: center; gap: 2px; }
.lchat-hbtn {
	width: 34px; height: 34px; border-radius: 50%;
	display: inline-flex; align-items: center; justify-content: center;
	color: rgba(255,255,255,.82); background: transparent; border: 0; cursor: pointer;
	text-decoration: none; transition: background .15s ease, color .15s ease;
}
.lchat-hbtn:hover { background: rgba(255,255,255,.12); color: #fff; }
.lchat-hbtn svg { width: 19px; height: 19px; }
.lchat-hbtn-close { display: none; }

/* Лента сообщений */
.lchat-body {
	flex: 1; overflow-y: auto; overscroll-behavior: contain;
	padding: 16px 14px 8px;
	display: flex; flex-direction: column; gap: 6px;
	scroll-behavior: smooth;
}
.lchat-msg { display: flex; flex-direction: column; max-width: 85%; animation: lchat-in .22s ease; }
@keyframes lchat-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.lchat-msg.lchat-bot { align-self: flex-start; }
.lchat-msg.lchat-me { align-self: flex-end; align-items: flex-end; }
.lchat-bubble {
	padding: 9px 13px; border-radius: 16px;
	white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere;
}
.lchat-bot .lchat-bubble { background: var(--lc-bubble); border: 1px solid var(--lc-line); border-bottom-left-radius: 5px; }
.lchat-me .lchat-bubble { background: var(--lc-dark); color: #fff; border-bottom-right-radius: 5px; }
.lchat-bubble a { color: var(--lc-accent); text-decoration: underline; text-underline-offset: 2px; }
.lchat-me .lchat-bubble a { color: #fff; }
.lchat-time { font-size: 11px; color: var(--lc-muted); margin: 3px 6px 4px; }
.lchat-msg.lchat-err .lchat-bubble { background: #fff4f2; border-color: #f2c9c2; }
.lchat-retry { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }

/* Быстрые вопросы */
.lchat-quick { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 6px; }
.lchat-chip {
	border: 1px solid var(--lc-accent); color: var(--lc-accent); background: #fff;
	border-radius: 18px; padding: 6px 12px; font-size: 13.5px; cursor: pointer;
	transition: background .15s ease, color .15s ease; text-align: left; line-height: 1.3;
}
.lchat-chip:hover { background: var(--lc-accent); color: #fff; }

/* «Печатает…» */
.lchat-typing { align-self: flex-start; background: var(--lc-bubble); border: 1px solid var(--lc-line); border-radius: 16px; border-bottom-left-radius: 5px; padding: 12px 14px; display: none; gap: 4px; }
.lchat-typing.lchat-show { display: inline-flex; }
.lchat-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--lc-muted); animation: lchat-dot 1.2s infinite ease-in-out; }
.lchat-typing i:nth-child(2) { animation-delay: .15s; }
.lchat-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes lchat-dot { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }

/* Поле ввода */
.lchat-foot { flex-shrink: 0; background: #fff; border-top: 1px solid var(--lc-line); padding: 10px 10px 6px; }
.lchat-form { display: flex; align-items: flex-end; gap: 8px; }
.lchat-input {
	flex: 1; resize: none; border: 1px solid var(--lc-line); border-radius: 20px;
	padding: 9px 14px; font: inherit; font-size: 15px; line-height: 1.4; color: var(--lc-text);
	max-height: 120px; min-height: 40px; background: #fbfaf8; outline: none;
	transition: border-color .15s ease, background .15s ease; margin: 0; box-shadow: none;
}
.lchat-input:focus { border-color: var(--lc-accent); background: #fff; }
.lchat-send {
	width: 40px; height: 40px; border-radius: 50%; border: 0; flex-shrink: 0;
	background: var(--lc-accent); color: #fff; cursor: pointer; padding: 0;
	display: flex; align-items: center; justify-content: center;
	transition: opacity .15s ease, transform .1s ease;
}
.lchat-send:disabled { opacity: .4; cursor: default; }
.lchat-send:not(:disabled):active { transform: scale(.94); }
.lchat-send svg { width: 19px; height: 19px; margin-left: 2px; }
.lchat-legal { font-size: 11px; color: var(--lc-muted); text-align: center; margin: 6px 4px 0; line-height: 1.3; }
.lchat-legal a { color: var(--lc-muted); text-decoration: underline; }

/* Телефоны */
@media (max-width: 520px) {
	.lchat-root.lchat-open { inset: 0; bottom: 0; right: 0; left: 0; }
	.lchat-open .lchat-launcher { display: none; }
	.lchat-window {
		position: fixed; inset: 0; width: 100%; height: 100%;
		min-height: 0; border-radius: 0; bottom: 0;
	}
	.lchat-open .lchat-window { height: 100dvh; }
	.lchat-hbtn-close { display: inline-flex; }
	.lchat-input { font-size: 16px; } /* iOS не зумит */
	.lchat-teaser { max-width: calc(100vw - 120px); }
}

@media (prefers-reduced-motion: reduce) {
	.lchat-root *, .lchat-root *::after { animation: none !important; transition: none !important; }
}


/* Защита от стилей темы (main.css: form input/textarea/[type=submit] { width:100% ... }) */
#lchat-root .lchat-form .lchat-input{width:auto!important;flex:1 1 auto!important;min-width:0!important;max-width:none!important;height:40px;min-height:40px!important;padding:9px 14px!important;margin:0!important;border:1px solid var(--lc-line)!important;border-radius:20px!important;font-size:15px!important;line-height:1.4!important;background:#fbfaf8!important;color:var(--lc-text)!important;box-shadow:none!important;resize:none!important;overflow-y:hidden}
#lchat-root .lchat-form .lchat-input:focus{border-color:var(--lc-accent)!important;background:#fff!important}
#lchat-root .lchat-form .lchat-send{width:40px!important;min-width:40px!important;height:40px!important;padding:0!important;margin:0!important;border:0!important;border-radius:50%!important;background:var(--lc-accent)!important;color:#fff!important;display:flex!important;align-items:center!important;justify-content:center!important;font-size:0!important;line-height:1!important;flex:0 0 40px!important}
#lchat-root .lchat-form .lchat-send svg{width:19px!important;height:19px!important}
#lchat-root button.lchat-chip,#lchat-root button.lchat-hbtn,#lchat-root button.lchat-launcher,#lchat-root button.lchat-teaser-x{width:auto;transition:background .15s ease,color .15s ease,transform .2s ease}
#lchat-root button.lchat-launcher{width:62px!important;height:62px!important;padding:0!important;border-radius:50%!important}
#lchat-root button.lchat-hbtn{width:34px!important;height:34px!important;padding:0!important}
@media (max-width:520px){#lchat-root .lchat-form .lchat-input{font-size:16px!important}}
