/* KMU Garage Chat */
#kgc-root {
	--kgc-c1: #2563eb;
	--kgc-c2: #06b6d4;
	--kgc-grad: linear-gradient(135deg, var(--kgc-c1), var(--kgc-c2));
	--kgc-ink: #0f172a;
	--kgc-muted: #64748b;
	--kgc-bg: #ffffff;
	--kgc-soft: #f1f5f9;
	--kgc-line: #e2e8f0;
	--kgc-off: var(--kgc-off-d, 24px);
	position: fixed;
	z-index: 2147483000;
	bottom: calc(var(--kgc-off) + env(safe-area-inset-bottom, 0px));
	right: 20px;
	font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif;
	color: var(--kgc-ink);
	-webkit-font-smoothing: antialiased;
}
#kgc-root.kgc-pos-left { right: auto; left: 20px; }
#kgc-root *, #kgc-root *::before, #kgc-root *::after { box-sizing: border-box; }
#kgc-root button, #kgc-root input, #kgc-root textarea { font: inherit; color: inherit; margin: 0; letter-spacing: normal; text-transform: none; }

/* ---------- Launcher ---------- */
.kgc-launcher {
	position: relative;
	width: 60px; height: 60px;
	border: 0; border-radius: 50%;
	background: var(--kgc-grad);
	color: #fff;
	cursor: pointer;
	display: grid; place-items: center;
	box-shadow: 0 10px 28px rgba(15, 23, 42, .35), 0 0 0 3px rgba(255, 255, 255, .9);
	transition: transform .2s ease, box-shadow .2s ease;
	padding: 0;
}
.kgc-launcher:hover { transform: translateY(-2px) scale(1.04); }
.kgc-launcher:focus-visible { outline: 3px solid var(--kgc-c2); outline-offset: 3px; }
.kgc-launcher svg { width: 28px; height: 28px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; grid-area: 1 / 1; transition: opacity .2s, transform .2s; }
.kgc-ico-chat { fill: #fff !important; stroke: none !important; }
.kgc-ico-close { opacity: 0; transform: rotate(-90deg); }
.kgc-open .kgc-ico-chat { opacity: 0; transform: rotate(90deg); }
.kgc-open .kgc-ico-close { opacity: 1; transform: none; }
.kgc-dot {
	position: absolute; top: 2px; right: 2px;
	width: 14px; height: 14px; border-radius: 50%;
	background: #ef4444; border: 2px solid #fff;
	transform: scale(0); transition: transform .25s;
}
.kgc-dot.kgc-show { transform: scale(1); }
.kgc-open .kgc-dot { transform: scale(0); }

/* ---------- Teaser ---------- */
.kgc-teaser {
	position: absolute; bottom: 72px; right: 0;
	width: max-content; max-width: min(280px, calc(100vw - 40px));
	background: var(--kgc-bg);
	border-radius: 14px 14px 4px 14px;
	padding: 12px 34px 12px 14px;
	box-shadow: 0 10px 30px rgba(15, 23, 42, .22);
	font-size: 14px; cursor: pointer;
	opacity: 0; transform: translateY(8px); pointer-events: none;
	transition: opacity .3s, transform .3s;
}
.kgc-pos-left .kgc-teaser { right: auto; left: 0; border-radius: 14px 14px 14px 4px; }
.kgc-teaser.kgc-show { opacity: 1; transform: none; pointer-events: auto; }
.kgc-teaser-x {
	position: absolute; top: 4px; right: 4px;
	width: 26px; height: 26px; border: 0; border-radius: 50%;
	background: transparent; color: var(--kgc-muted) !important; cursor: pointer; font-size: 18px; line-height: 1; padding: 0;
}

/* ---------- Panel ---------- */
.kgc-panel {
	position: absolute; bottom: 76px; right: 0;
	width: 380px; height: min(620px, calc(100vh - var(--kgc-off) - 110px));
	background: var(--kgc-bg);
	border-radius: 18px;
	box-shadow: 0 24px 60px rgba(15, 23, 42, .35);
	display: flex; flex-direction: column; overflow: hidden;
	opacity: 0; transform: translateY(12px) scale(.98); transform-origin: bottom right;
	transition: opacity .2s ease, transform .2s ease;
}
.kgc-pos-left .kgc-panel { right: auto; left: 0; transform-origin: bottom left; }
.kgc-open .kgc-panel { opacity: 1; transform: none; }
.kgc-panel[hidden] { display: none; }

.kgc-head {
	display: flex; align-items: center; gap: 10px;
	padding: 14px 12px 14px 16px;
	background: #0b0b0c; color: #fff;
	border-bottom: 3px solid transparent;
	border-image: var(--kgc-grad) 1;
}
.kgc-avatar {
	flex: 0 0 42px; width: 42px; height: 42px; border-radius: 50%;
	background: #fff; color: #000; font-weight: 800; font-size: 18px;
	display: grid; place-items: center; overflow: hidden; position: relative;
}
.kgc-avatar img { width: 100%; height: 100%; object-fit: cover; }
.kgc-head-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.kgc-head-text strong { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kgc-head-status { font-size: 12px; opacity: .8; display: flex; align-items: center; gap: 6px; }
.kgc-head-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; }
.kgc-is-open .kgc-head-status::before { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .25); }
.kgc-hbtn {
	width: 36px; height: 36px; border: 0; border-radius: 10px;
	background: transparent; cursor: pointer; display: grid; place-items: center; padding: 0;
}
.kgc-hbtn:hover { background: rgba(255, 255, 255, .12); }
.kgc-hbtn svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.kgc-body {
	flex: 1; overflow-y: auto; padding: 16px 14px 8px;
	background: var(--kgc-soft);
	display: flex; flex-direction: column; gap: 8px;
	overscroll-behavior: contain;
}
.kgc-msg {
	max-width: 86%; padding: 10px 13px; border-radius: 16px;
	white-space: pre-line; word-wrap: break-word;
	animation: kgc-in .22s ease both;
}
.kgc-bot { align-self: flex-start; background: #fff; border-bottom-left-radius: 4px; box-shadow: 0 1px 2px rgba(15, 23, 42, .08); }
.kgc-user { align-self: flex-end; background: var(--kgc-grad); color: #fff; border-bottom-right-radius: 4px; }
.kgc-typing { display: flex; gap: 4px; padding: 13px 14px; }
.kgc-typing i { width: 7px; height: 7px; border-radius: 50%; background: #94a3b8; animation: kgc-blink 1s infinite; }
.kgc-typing i:nth-child(2) { animation-delay: .15s; }
.kgc-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes kgc-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes kgc-blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

/* ---------- Antwort-Buttons ---------- */
.kgc-foot { background: var(--kgc-soft); padding: 4px 14px 12px; max-height: 58%; overflow-y: auto; overscroll-behavior: contain; }
.kgc-foot:empty { padding: 0; }
.kgc-options { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.kgc-opt {
	display: inline-flex; align-items: center;
	padding: 9px 14px; border-radius: 999px;
	background: #fff; border: 1.5px solid var(--kgc-c1);
	color: var(--kgc-c1) !important; font-weight: 600; font-size: 14px;
	text-decoration: none !important; cursor: pointer; line-height: 1.2;
	transition: background .15s, color .15s, transform .1s;
}
.kgc-opt:hover, .kgc-opt:focus-visible { background: var(--kgc-c1); color: #fff !important; outline: none; }
.kgc-opt:active { transform: scale(.97); }
.kgc-action { background: var(--kgc-grad); color: #fff !important; border-color: transparent; }
.kgc-back {
	border: 0; background: transparent; color: var(--kgc-muted) !important;
	font-size: 13px; padding: 9px 6px; cursor: pointer; text-decoration: underline;
}

/* ---------- Formular ---------- */
.kgc-form { background: #fff; border-radius: 14px; padding: 14px; box-shadow: 0 1px 3px rgba(15, 23, 42, .1); display: grid; gap: 10px; margin-bottom: 8px; }
.kgc-field { display: grid; gap: 4px; font-size: 13px; color: var(--kgc-muted); font-weight: 600; }
.kgc-field input, .kgc-field textarea {
	width: 100%; padding: 10px 12px;
	border: 1.5px solid var(--kgc-line); border-radius: 10px;
	background: #fff; color: var(--kgc-ink) !important;
	font-size: 16px; /* verhindert Zoom auf iOS */ font-weight: 400;
	box-shadow: none; min-height: 0; height: auto;
}
.kgc-field input:focus, .kgc-field textarea:focus { border-color: var(--kgc-c1); outline: none; box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
.kgc-field textarea { resize: vertical; min-height: 70px; }
.kgc-hint { margin: -4px 0 0; font-size: 12px; color: var(--kgc-muted); }
.kgc-photo-btn {
	display: flex; align-items: center; justify-content: center;
	padding: 12px; border: 1.5px dashed var(--kgc-c1); border-radius: 10px;
	color: var(--kgc-c1); font-weight: 600; font-size: 14px; cursor: pointer;
}
.kgc-photo-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.kgc-preview { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.kgc-preview img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }
.kgc-preview small { flex-basis: 100%; color: var(--kgc-muted); }
.kgc-consent { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; color: var(--kgc-muted); line-height: 1.4; }
.kgc-consent input { margin-top: 2px; width: 18px; height: 18px; flex: 0 0 18px; accent-color: var(--kgc-c1); }
.kgc-consent a { color: var(--kgc-c1); }
.kgc-err { margin: 0; color: #dc2626; font-size: 13px; }
.kgc-err:empty { display: none; }
.kgc-submit {
	width: 100%; padding: 13px; border: 0; border-radius: 12px;
	background: var(--kgc-grad); color: #fff !important; font-weight: 700; font-size: 15px; cursor: pointer;
}
.kgc-submit:disabled { opacity: .6; cursor: wait; }
.kgc-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }

.kgc-callbar {
	display: block; text-align: center; padding: 10px;
	font-size: 13px; font-weight: 600;
	background: #fff; color: var(--kgc-ink) !important; text-decoration: none !important;
	border-top: 1px solid var(--kgc-line);
}
.kgc-callbar:hover { color: var(--kgc-c1) !important; }

/* ---------- Mobile ---------- */
@media (max-width: 768px) {
	#kgc-root { --kgc-off: var(--kgc-off-m, 96px); right: 16px; }
	#kgc-root.kgc-pos-left { left: 16px; }
	.kgc-launcher { width: 56px; height: 56px; }
	.kgc-teaser { bottom: 66px; }

	.kgc-panel {
		position: fixed; inset: 0;
		width: 100%; height: 100%; height: 100dvh;
		border-radius: 0; transform: translateY(20px);
	}
	.kgc-head { padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
	.kgc-callbar { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
	.kgc-open .kgc-launcher, .kgc-open .kgc-teaser { display: none; }
	html.kgc-lock, html.kgc-lock body { overflow: hidden !important; }
}

@media (prefers-reduced-motion: reduce) {
	#kgc-root * { animation: none !important; transition: none !important; }
}

@media print { #kgc-root { display: none !important; } }

/* ---------- Avatare (v1.1) ---------- */
.kgc-avatar-wrap { flex: 0 0 44px; position: relative; }
.kgc-avatar { width: 44px; height: 44px; border: 2px solid #fff; }
.kgc-avatar-wrap::after {
	content: ""; position: absolute; right: -1px; bottom: -1px;
	width: 12px; height: 12px; border-radius: 50%;
	background: #94a3b8; border: 2px solid #0b0b0c;
}
.kgc-is-open .kgc-avatar-wrap::after { background: #22c55e; }
.kgc-avatar img, .kgc-mini img, .kgc-teaser-av img { width: 100%; height: 100%; object-fit: cover; object-position: center 20%; display: block; }

.kgc-row { display: flex; align-items: flex-end; gap: 8px; max-width: 92%; align-self: flex-start; }
.kgc-row .kgc-msg { max-width: 100%; }
.kgc-mini {
	flex: 0 0 28px; width: 28px; height: 28px; border-radius: 50%; overflow: hidden;
	background: #fff; color: #000; font-weight: 700; font-size: 12px;
	display: grid; place-items: center; box-shadow: 0 1px 2px rgba(15, 23, 42, .15);
	align-self: flex-start;
}
.kgc-mini-empty { background: transparent; box-shadow: none; }

.kgc-teaser-text { display: flex; gap: 10px; align-items: center; }
.kgc-teaser-text > span { display: flex; flex-direction: column; gap: 2px; }
.kgc-teaser-text strong { font-size: 13px; }
.kgc-teaser-av {
	flex: 0 0 44px; width: 44px; height: 44px; border-radius: 50%; overflow: hidden;
	background: #0b0b0c; color: #fff; display: grid; place-items: center; font-weight: 700;
}

/* ---------- Theme-Overrides (v1.2.1): feste Farben in allen Zuständen ---------- */
#kgc-root .kgc-opt,
#kgc-root .kgc-opt:focus,
#kgc-root .kgc-opt:active,
#kgc-root .kgc-opt:visited {
	background: #fff !important;
	background-image: none !important;
	color: var(--kgc-c1) !important;
	border: 1.5px solid var(--kgc-c1) !important;
	box-shadow: none !important;
	text-shadow: none !important;
	outline: none;
}
@media (hover: hover) {
	#kgc-root .kgc-opt:hover {
		background: var(--kgc-c1) !important;
		color: #fff !important;
	}
}
#kgc-root .kgc-opt:focus-visible {
	background: #fff !important;
	color: var(--kgc-c1) !important;
	outline: 3px solid var(--kgc-c2) !important;
	outline-offset: 2px;
}
#kgc-root .kgc-opt:active {
	background: var(--kgc-c1) !important;
	color: #fff !important;
}
/* Link-Buttons (Anrufen, Route) */
#kgc-root .kgc-action,
#kgc-root .kgc-action:hover,
#kgc-root .kgc-action:focus,
#kgc-root .kgc-action:active,
#kgc-root .kgc-action:visited {
	background: var(--kgc-grad) !important;
	color: #fff !important;
	border-color: transparent !important;
}
/* Senden-Button */
#kgc-root .kgc-submit,
#kgc-root .kgc-submit:hover,
#kgc-root .kgc-submit:focus,
#kgc-root .kgc-submit:active {
	background: var(--kgc-grad) !important;
	color: #fff !important;
	border: 0 !important;
	box-shadow: none !important;
}
/* Kopf-, Zurück- und Schliessen-Buttons */
#kgc-root .kgc-hbtn,
#kgc-root .kgc-hbtn:focus,
#kgc-root .kgc-hbtn:active {
	background: transparent !important;
	border: 0 !important;
	box-shadow: none !important;
}
#kgc-root .kgc-hbtn:hover { background: rgba(255, 255, 255, .12) !important; }
#kgc-root .kgc-back,
#kgc-root .kgc-back:hover,
#kgc-root .kgc-back:focus,
#kgc-root .kgc-back:active,
#kgc-root .kgc-teaser-x,
#kgc-root .kgc-teaser-x:hover,
#kgc-root .kgc-teaser-x:focus {
	background: transparent !important;
	color: var(--kgc-muted) !important;
	border: 0 !important;
	box-shadow: none !important;
}
#kgc-root .kgc-launcher,
#kgc-root .kgc-launcher:hover,
#kgc-root .kgc-launcher:focus,
#kgc-root .kgc-launcher:active {
	background: var(--kgc-grad) !important;
	border: 0 !important;
	color: #fff !important;
}
