.qtg {
	--qtg-primary: #007C89;
	--qtg-on-primary: #FFFFFF;
	--qtg-bg: #FFFFFF;
	--qtg-visitor: #E6F4F5;
	--qtg-operator: #F2F3F5;
	--qtg-radius: 16px;
	--qtg-button: 60px;
	--qtg-width: 380px;
	--qtg-height: 560px;
	--qtg-x: 24px;
	--qtg-y: 24px;
	--qtg-y-mobile: 80px;
	--qtg-font: inherit;
	--qtg-ink: #22262E;
	--qtg-muted: #6B7079;
	--qtg-line: #E3E5E8;
	--qtg-accent: #FFC233;
	--qtg-danger: #B42318;

	position: fixed;
	z-index: 2147483000;
	bottom: var(--qtg-y);
	right: var(--qtg-x);
	font-family: var(--qtg-font);
	font-size: 15px;
	line-height: 1.45;
	color: var(--qtg-ink);
	-webkit-font-smoothing: antialiased;
}
.qtg[data-side="left"] { right: auto; left: var(--qtg-x); }
.qtg *, .qtg *::before, .qtg *::after { box-sizing: border-box; }
.qtg button { font: inherit; cursor: pointer; }
.qtg :focus-visible { outline: 2px solid var(--qtg-primary); outline-offset: 2px; }

/* Кнопка запуска */
.qtg__launcher {
	position: relative;
	width: var(--qtg-button);
	height: var(--qtg-button);
	border: 0;
	border-radius: 50%;
	background: var(--qtg-primary);
	color: var(--qtg-on-primary);
	display: grid;
	place-items: center;
	box-shadow: 0 6px 20px rgba(0, 76, 84, .28);
	transition: transform .18s ease;
}
.qtg__launcher:hover { transform: scale(1.04); }
.qtg__launcher svg, .qtg__launcher img { width: 46%; height: 46%; }
.qtg__badge {
	position: absolute;
	top: -2px;
	right: -2px;
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	border-radius: 11px;
	background: var(--qtg-accent);
	color: var(--qtg-ink);
	font-size: 12px;
	font-weight: 700;
	line-height: 22px;
	text-align: center;
	box-shadow: 0 0 0 2px var(--qtg-bg);
}
.qtg__badge[hidden] { display: none; }

/* Приглашение рядом с кнопкой */
.qtg__teaser {
	position: absolute;
	bottom: calc(var(--qtg-button) + 12px);
	right: 0;
	width: max-content;
	max-width: 260px;
	padding: 12px 36px 12px 14px;
	border-radius: var(--qtg-radius) var(--qtg-radius) 4px var(--qtg-radius);
	background: var(--qtg-bg);
	border-left: 4px solid var(--qtg-accent);
	box-shadow: 0 8px 28px rgba(34, 38, 46, .16);
	cursor: pointer;
}
.qtg[data-side="left"] .qtg__teaser { right: auto; left: 0; border-radius: var(--qtg-radius) var(--qtg-radius) var(--qtg-radius) 4px; }
.qtg__teaser-close {
	position: absolute;
	top: 6px;
	right: 6px;
	width: 26px;
	height: 26px;
	border: 0;
	background: none;
	color: var(--qtg-muted);
	font-size: 18px;
	line-height: 1;
}

/* Окно */
.qtg__panel {
	position: absolute;
	bottom: calc(var(--qtg-button) + 14px);
	right: 0;
	width: var(--qtg-width);
	height: min(var(--qtg-height), calc(100vh - var(--qtg-button) - var(--qtg-y) - 40px));
	display: flex;
	flex-direction: column;
	background: var(--qtg-bg);
	border-radius: var(--qtg-radius);
	box-shadow: 0 18px 48px rgba(34, 38, 46, .22);
	overflow: hidden;
	transform-origin: bottom right;
	animation: qtg-open .18s ease-out;
}
.qtg[data-side="left"] .qtg__panel { right: auto; left: 0; transform-origin: bottom left; }
.qtg__panel[hidden] { display: none; }
@keyframes qtg-open { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

.qtg__head {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 12px 14px 16px;
	border-bottom: 1px solid var(--qtg-line);
}
.qtg__mark {
	flex: none;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: var(--qtg-primary);
	color: var(--qtg-on-primary);
	display: grid;
	place-items: center;
}
.qtg__mark svg { width: 20px; height: 20px; }
.qtg__title { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.25; }
.qtg__status { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--qtg-muted); }
.qtg__status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #9AA0A6; }
.qtg__status[data-online="1"]::before { background: #1F9D55; }
.qtg__head-text { flex: 1; min-width: 0; }
.qtg__close {
	flex: none;
	width: 40px;
	height: 40px;
	border: 0;
	border-radius: 50%;
	background: none;
	color: var(--qtg-muted);
	display: grid;
	place-items: center;
}
.qtg__close:hover { background: var(--qtg-operator); }

/* Лента */
.qtg__extra { flex: none; max-height: 50%; overflow-y: auto; }
.qtg__extra:empty { display: none; }
.qtg__head, .qtg__composer, .qtg__chips, .qtg__consent, .qtg__notice { flex: none; }
.qtg__feed {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 6px;
	overscroll-behavior: contain;
}
.qtg__msg { max-width: 84%; display: flex; flex-direction: column; }
.qtg__msg--visitor { align-self: flex-end; align-items: flex-end; }
.qtg__msg--operator, .qtg__msg--ai, .qtg__msg--system, .qtg__msg--greeting { align-self: flex-start; }
.qtg__msg + .qtg__msg--operator:not(.qtg__msg--same) { margin-top: 8px; }
.qtg__name { font-size: 12px; color: var(--qtg-muted); margin: 0 0 2px 12px; }
.qtg__bubble {
	padding: 9px 12px;
	border-radius: var(--qtg-radius);
	background: var(--qtg-operator);
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}
.qtg__msg--visitor .qtg__bubble { background: var(--qtg-visitor); border-bottom-right-radius: 4px; }
.qtg__msg--operator .qtg__bubble, .qtg__msg--ai .qtg__bubble, .qtg__msg--greeting .qtg__bubble { border-bottom-left-radius: 4px; }
.qtg__msg--system .qtg__bubble { background: none; border: 1px dashed var(--qtg-line); color: var(--qtg-muted); font-size: 14px; }
.qtg__bubble a { color: var(--qtg-primary); text-decoration: underline; }
.qtg__files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.qtg__files img { display: block; max-width: 200px; max-height: 200px; border-radius: 10px; }
.qtg__file { display: inline-flex; gap: 6px; align-items: center; padding: 6px 10px; border-radius: 10px; background: var(--qtg-bg); color: var(--qtg-ink); text-decoration: none; font-size: 14px; }
.qtg__meta { font-size: 12px; color: var(--qtg-muted); margin: 2px 6px 0; }
.qtg__meta--failed { color: var(--qtg-danger); }
.qtg__retry { border: 0; background: none; padding: 0; color: var(--qtg-danger); text-decoration: underline; font-size: 12px; }

/* Плашка контактов, капча, уведомления */
.qtg__card {
	margin: 0 16px 12px;
	padding: 12px 14px;
	border-radius: 12px;
	background: var(--qtg-visitor);
	font-size: 14px;
}
.qtg__card p { margin: 0 0 8px; }
.qtg__card-row { display: flex; gap: 8px; margin-top: 8px; }
.qtg__field {
	width: 100%;
	margin-top: 6px;
	padding: 9px 11px;
	border: 1px solid var(--qtg-line);
	border-radius: 10px;
	background: var(--qtg-bg);
	color: var(--qtg-ink);
	font: inherit;
	font-size: 16px;
}
.qtg__btn {
	padding: 9px 14px;
	border: 0;
	border-radius: 10px;
	background: var(--qtg-primary);
	color: var(--qtg-on-primary);
	font-weight: 600;
}
.qtg__btn--ghost { background: none; color: var(--qtg-muted); }
.qtg__error { color: var(--qtg-danger); font-size: 13px; margin: 6px 0 0; }
.qtg__notice { margin: 0 16px 10px; font-size: 13px; color: var(--qtg-muted); }
.qtg__notice a { color: inherit; }

/* Поле ввода */
.qtg__composer {
	display: flex;
	align-items: flex-end;
	gap: 6px;
	padding: 10px 10px 12px;
	border-top: 1px solid var(--qtg-line);
}
.qtg__input {
	flex: 1;
	min-height: 42px;
	max-height: 140px;
	padding: 10px 12px;
	border: 1px solid var(--qtg-line);
	border-radius: 21px;
	resize: none;
	font: inherit;
	font-size: 16px;
	line-height: 1.35;
	color: var(--qtg-ink);
	background: var(--qtg-bg);
}
.qtg__input:focus { outline: none; border-color: var(--qtg-primary); }
.qtg__icon-btn {
	flex: none;
	width: 42px;
	height: 42px;
	border: 0;
	border-radius: 50%;
	background: none;
	color: var(--qtg-muted);
	display: grid;
	place-items: center;
}
.qtg__icon-btn:hover { background: var(--qtg-operator); }
.qtg__send { background: var(--qtg-primary); color: var(--qtg-on-primary); }
.qtg__send:hover { background: var(--qtg-primary); filter: brightness(1.08); }
.qtg__send:disabled { opacity: .45; cursor: default; }
.qtg__icon-btn svg { width: 20px; height: 20px; }
.qtg__chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px; }
.qtg__chips:empty { display: none; }
.qtg__chip { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 4px 6px 4px 10px; border-radius: 14px; background: var(--qtg-operator); font-size: 13px; }
.qtg__chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qtg__chip button { border: 0; background: none; color: var(--qtg-muted); font-size: 16px; line-height: 1; padding: 0 4px; }
.qtg__drop { outline: 2px dashed var(--qtg-primary); outline-offset: -8px; }
.qtg__consent { display: flex; gap: 8px; align-items: flex-start; margin: 0 16px 8px; font-size: 13px; color: var(--qtg-muted); }
.qtg__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 480px) {
	.qtg { bottom: var(--qtg-y-mobile); }
	.qtg__panel {
		position: fixed;
		inset: 0;
		width: 100%;
		height: 100%;
		max-height: none;
		border-radius: 0;
	}
	.qtg--open .qtg__launcher { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	.qtg__panel { animation: none; }
	.qtg__launcher { transition: none; }
}
