/* Koto Site Chat — виджет на сайте. Мир «Тёплая берлога» (DESIGN.md): лён, кора, старый мёд.
   Сигнатура — линейная кошка на «полке» (кнопка-планка) и на верхнем крае окна чата.
   Анимации — через WAAPI в widget.js (тема гасит CSS transition под reduced-motion). */

.koto-sc {
	--ksc-cream: #f5f0e8;
	--ksc-warm: #ede8dc;
	--ksc-bark: #2e1f0e;
	--ksc-pine: #4a3728;
	--ksc-gold: #ba8756;
	--ksc-gold-lt: #d4a070;
	--ksc-gold-ink: #8a5f36;
	--ksc-sage-lt: #8fa37e;
	--ksc-muted: #736759;
	--ksc-rule: #c9bfae;
	--ksc-sans: 'Jost', system-ui, sans-serif;
	--ksc-serif: 'Cormorant Garamond', Georgia, serif;
	--ksc-shadow: 0 8px 24px rgba(46, 31, 14, .25);
	--ksc-right: 24px;
	--ksc-bottom: 24px;
	position: fixed;
	right: var(--ksc-right);
	bottom: var(--ksc-bottom);
	z-index: 99990;
	font-family: var(--ksc-sans);
	color: var(--ksc-bark);
	-webkit-font-smoothing: antialiased;
	line-height: 1.5;
}
.koto-sc *, .koto-sc *::before, .koto-sc *::after { box-sizing: border-box; }
.koto-sc button { font-family: inherit; }
.koto-sc [hidden] { display: none !important; }
.koto-sc ::selection { background: var(--ksc-gold-lt); color: var(--ksc-bark); }

/* ---------- Кнопка-полка ---------- */
.ksc-launch.ksc-launch {
	position: relative;
	display: flex;
	align-items: center;
	gap: 12px;
	min-height: 54px;
	padding: 8px 22px 8px 20px;
	border: 0;
	border-radius: 5px;
	background: var(--ksc-bark);
	color: var(--ksc-cream);
	cursor: pointer;
	box-shadow: inset 0 -4px 0 #4a3728, var(--ksc-shadow);
	text-align: left;
	text-transform: none;
	letter-spacing: 0;
}
.ksc-launch.ksc-launch:hover { background: var(--ksc-pine); color: var(--ksc-cream); }
.ksc-launch.ksc-launch:focus-visible { outline: 2px solid var(--ksc-gold-lt); outline-offset: 3px; }
.ksc-launch-ic { flex: none; width: 22px; height: 22px; color: var(--ksc-gold-lt); }
.ksc-launch-txt { display: flex; flex-direction: column; }
.ksc-launch-txt b { font-weight: 500; font-size: 15.5px; letter-spacing: .01em; line-height: 1.25; }
.ksc-launch-txt small { display: flex; align-items: center; gap: 6px; font-size: 12px; line-height: 1.35; color: rgba(245, 240, 232, .7); }
.ksc-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ksc-sage-lt); flex: none; }
.ksc-dot.is-off { background: var(--ksc-muted); }
.ksc-badge {
	position: absolute; top: -9px; right: -9px;
	min-width: 22px; height: 22px; padding: 0 6px;
	border-radius: 11px; background: var(--ksc-gold); color: #fff;
	font: 600 12px/22px var(--ksc-sans); text-align: center;
	box-shadow: 0 0 0 2px var(--ksc-cream);
}

/* Кошка, сидящая на верхнем крае */
.ksc-cat { position: absolute; left: 12px; bottom: calc(100% - 7px); width: 68px; height: 48px; pointer-events: none; overflow: visible; }
.ksc-cat svg { display: block; width: 100%; height: 100%; overflow: visible; }
.ksc-cat .c-fill { fill: var(--ksc-cream); }
.ksc-cat .c-line { fill: none; stroke: var(--ksc-bark); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ksc-cat .c-eye { fill: var(--ksc-bark); transform-box: fill-box; transform-origin: center; }
.ksc-cat .c-nose { fill: var(--ksc-gold); }
.ksc-cat .c-head { transform-box: fill-box; transform-origin: 50% 100%; }

/* ---------- Тизер: сообщение оператора при свёрнутом чате ---------- */
.ksc-teaser {
	position: absolute; right: 0; bottom: calc(100% + 58px);
	width: 300px; padding: 14px 40px 14px 16px;
	background: #fff; border-radius: 10px; box-shadow: var(--ksc-shadow);
	text-align: left;
}
.ksc-teaser .ksc-cat { display: none; }
.ksc-teaser-open { display: block; width: 100%; padding: 0; margin: 0; border: 0; background: none; text-align: left; cursor: pointer; color: inherit; text-transform: none; letter-spacing: 0; }
.ksc-teaser-open:hover { background: none; }
.ksc-teaser-open:focus-visible { outline: 2px solid var(--ksc-gold); outline-offset: 4px; border-radius: 4px; }
.ksc-teaser-who { display: block; font: 600 11px/1.3 var(--ksc-sans); letter-spacing: .14em; text-transform: uppercase; color: var(--ksc-muted); margin-bottom: 4px; }
.ksc-teaser-txt { font-size: 14.5px; line-height: 1.5; color: var(--ksc-bark); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.ksc-teaser-x { position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; border: 0; border-radius: 5px; background: transparent; color: var(--ksc-muted); cursor: pointer; display: grid; place-items: center; }
.ksc-teaser-x:hover { color: var(--ksc-bark); background: var(--ksc-warm); }
.ksc-teaser-x svg { width: 14px; height: 14px; }

/* ---------- Окно чата ---------- */
.ksc-panel {
	position: absolute; right: 0; bottom: 0;
	width: 384px; height: min(640px, calc(100vh - 72px));
	display: flex; flex-direction: column;
	background: var(--ksc-cream);
	border-radius: 10px;
	box-shadow: var(--ksc-shadow);
	transform-origin: 100% 100%;
}
.ksc-panel .ksc-cat { left: auto; right: 74px; }

.ksc-head {
	position: relative; flex: none;
	display: flex; align-items: center; gap: 14px;
	padding: 18px 12px 16px 22px;
	background: var(--ksc-bark); color: var(--ksc-cream);
	border-radius: 10px 10px 0 0;
}
.ksc-head-txt { flex: 1; min-width: 0; }
.ksc-head h2 {
	margin: 0; padding: 0;
	font: 700 25px/1.05 var(--ksc-serif); letter-spacing: -.01em;
	color: var(--ksc-cream); text-transform: none;
}
.ksc-head p { margin: 5px 0 0; display: flex; align-items: center; gap: 7px; font-size: 13px; line-height: 1.35; color: rgba(245, 240, 232, .72); }
.ksc-icon-btn {
	flex: none; width: 40px; height: 40px; border: 0; border-radius: 5px;
	background: transparent; color: rgba(245, 240, 232, .8); cursor: pointer;
	display: grid; place-items: center; padding: 0;
}
.ksc-icon-btn:hover { background: rgba(245, 240, 232, .1); color: var(--ksc-cream); }
.ksc-icon-btn:focus-visible { outline: 2px solid var(--ksc-gold-lt); outline-offset: 1px; }
.ksc-icon-btn svg { width: 20px; height: 20px; }

/* Лента */
.ksc-feed {
	flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
	padding: 18px 18px 10px;
	display: flex; flex-direction: column; gap: 4px;
}
.ksc-feed::-webkit-scrollbar { width: 8px; }
.ksc-feed::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
.ksc-feed::-webkit-scrollbar-track { background: transparent; }
.ksc-feed::-webkit-scrollbar-thumb { background: var(--ksc-rule); border-radius: 6px; border: 2px solid var(--ksc-cream); }
.ksc-feed::-webkit-scrollbar-thumb:hover { background: var(--ksc-gold-lt); }

.ksc-day { align-self: center; margin: 10px 0 6px; font: 600 10.5px/1 var(--ksc-sans); letter-spacing: .14em; text-transform: uppercase; color: var(--ksc-muted); }

.ksc-row { display: flex; flex-direction: column; max-width: 84%; }
.ksc-row.is-in { align-self: flex-start; }
.ksc-row.is-out { align-self: flex-end; align-items: flex-end; }
.ksc-row + .ksc-row.is-in:not(.is-cont), .ksc-row + .ksc-row.is-out:not(.is-cont) { margin-top: 8px; }
.ksc-who { font: 600 10.5px/1.3 var(--ksc-sans); letter-spacing: .14em; text-transform: uppercase; color: var(--ksc-muted); margin: 0 0 4px 2px; }
.ksc-bub {
	padding: 9px 13px 10px;
	font-size: 14.5px; line-height: 1.5;
	border-radius: 10px;
	white-space: pre-wrap; overflow-wrap: anywhere;
}
.is-in .ksc-bub { background: #fff; color: var(--ksc-bark); border: 1px solid #e4dccd; border-bottom-left-radius: 3px; }
.is-in.is-auto .ksc-bub { background: var(--ksc-warm); border-color: transparent; }
.is-out .ksc-bub { background: var(--ksc-gold); color: #fff; border-bottom-right-radius: 3px; }
.is-in.is-cont .ksc-bub { border-top-left-radius: 3px; }
.is-out.is-cont .ksc-bub { border-top-right-radius: 3px; }
.ksc-bub a { color: inherit; text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
.is-in .ksc-bub a { color: var(--ksc-gold-ink); }
.ksc-bub.is-photo { padding: 4px; background: transparent; border: 0; }
.ksc-bub.is-photo + .ksc-bub { margin-top: 4px; }
.ksc-img { display: block; max-width: 240px; max-height: 260px; border-radius: 8px; cursor: zoom-in; background: var(--ksc-warm); }
.ksc-meta { font-size: 11px; line-height: 1.3; color: var(--ksc-muted); margin: 3px 4px 0; font-variant-numeric: tabular-nums; }
.ksc-row.is-pending .ksc-bub { opacity: .7; }
.ksc-row.is-failed .ksc-meta { color: #a3402c; }

.ksc-sys { align-self: center; max-width: 90%; margin: 10px 0; display: flex; align-items: center; gap: 6px; font-size: 12.5px; line-height: 1.4; color: var(--ksc-muted); text-align: center; }
.ksc-sys svg { width: 14px; height: 14px; flex: none; color: var(--ksc-sage-lt); }

.ksc-typing { align-self: flex-start; display: flex; gap: 4px; padding: 12px 14px; background: #fff; border: 1px solid #e4dccd; border-radius: 10px 10px 10px 3px; margin-top: 8px; }
.ksc-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--ksc-rule); }

/* Приветствие и темы */
.ksc-hello { display: flex; flex-direction: column; gap: 14px; }
.ksc-hello .ksc-row { max-width: 92%; }
.ksc-topics { display: flex; flex-direction: column; border-top: 1px solid var(--ksc-rule); }
.ksc-topic {
	display: grid; grid-template-columns: 36px 1fr; gap: 2px 12px; align-items: center;
	width: 100%; padding: 12px 8px; text-align: left;
	background: transparent; border: 0; border-bottom: 1px solid var(--ksc-rule); border-radius: 5px;
	color: var(--ksc-bark); cursor: pointer;
	text-transform: none; letter-spacing: 0;
}
.ksc-topic:hover { background: var(--ksc-warm); color: var(--ksc-bark); }
.ksc-topic:focus-visible { outline: 2px solid var(--ksc-gold); outline-offset: 2px; }
.ksc-topic-ic { grid-row: span 2; width: 36px; height: 36px; color: var(--ksc-gold-ink); display: grid; place-items: center; }
.ksc-topic-ic svg { width: 22px; height: 22px; }
.ksc-topic b { font-weight: 500; font-size: 14.5px; line-height: 1.3; }
.ksc-topic small { font-size: 12.5px; line-height: 1.35; color: var(--ksc-muted); }

.ksc-chans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 6px; padding: 2px 0 6px; font-size: 12.5px; color: var(--ksc-muted); }
.ksc-chans > span { grid-column: 1 / -1; }
.ksc-chans a {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px;
	padding: 5px 8px; border: 1px solid var(--ksc-rule); border-radius: 5px;
	color: var(--ksc-pine); text-decoration: none; font-size: 12.5px; line-height: 1.3;
}
.ksc-chans a:hover { border-color: var(--ksc-gold); color: var(--ksc-gold-ink); }
.ksc-chans a svg { width: 16px; height: 16px; flex: none; color: var(--ksc-gold-ink); }

/* Карточка «куда ответить» */
.ksc-contact { align-self: stretch; margin: 12px 0 4px; padding: 14px 14px 12px; background: var(--ksc-warm); border: 0; border-radius: 10px; }
.ksc-contact h3 { margin: 0 0 10px; font: 700 19px/1.15 var(--ksc-serif); color: var(--ksc-bark); text-transform: none; letter-spacing: 0; }
.ksc-contact .ksc-fields { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; }
.ksc-contact input {
	width: 100%; height: 42px; padding: 0 12px; margin: 0;
	background: transparent; border: 1px solid var(--ksc-rule); border-radius: 5px;
	font: 400 14px var(--ksc-sans); color: var(--ksc-bark); box-shadow: none;
}
.ksc-contact input::placeholder { color: var(--ksc-muted); opacity: 1; }
.ksc-contact input:focus { outline: none; border-color: var(--ksc-gold); }
.ksc-contact-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.ksc-contact small { font-size: 11.5px; line-height: 1.4; color: var(--ksc-muted); }
.ksc-contact small a { color: var(--ksc-gold-ink); }
.ksc-err { color: #a3402c; font-size: 12.5px; margin-top: 6px; }
.ksc-btn.ksc-btn {
	flex: none; height: 40px; padding: 0 18px; border: 0; border-radius: 5px;
	background: var(--ksc-gold); color: #fff; cursor: pointer;
	font: 600 11px/40px var(--ksc-sans); letter-spacing: .16em; text-transform: uppercase;
}
.ksc-btn.ksc-btn:hover { background: var(--ksc-gold-lt); color: #fff; }
.ksc-btn.ksc-btn:disabled { opacity: .6; cursor: default; }
.ksc-link.ksc-link { border: 0; background: none; padding: 4px 2px; color: var(--ksc-muted); font-size: 12.5px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-transform: none; letter-spacing: 0; }
.ksc-link.ksc-link:hover { color: var(--ksc-bark); background: none; }

/* Поле ввода */
.ksc-compose {
	flex: none; display: flex; align-items: flex-end; gap: 6px;
	padding: 10px 10px 10px 8px;
	border-top: 1px solid var(--ksc-rule);
	background: var(--ksc-cream);
	border-radius: 0 0 10px 10px;
}
.ksc-compose textarea {
	flex: 1; min-height: 42px; max-height: 132px; resize: none; margin: 0;
	padding: 10px 6px; border: 0; background: transparent; box-shadow: none;
	font: 400 15px/1.45 var(--ksc-sans); color: var(--ksc-bark); caret-color: var(--ksc-gold);
	outline: none;
}
.ksc-compose:focus-within { border-top-color: var(--ksc-gold); }
.ksc-compose textarea::placeholder { color: var(--ksc-muted); opacity: 1; }
.ksc-compose textarea:focus { outline: none; box-shadow: none; border: 0; }
.ksc-att.ksc-att, .ksc-send.ksc-send {
	flex: none; width: 42px; height: 42px; border: 0; border-radius: 5px;
	display: grid; place-items: center; cursor: pointer; padding: 0;
}
.ksc-att.ksc-att { background: transparent; color: var(--ksc-muted); }
.ksc-att.ksc-att:hover, .ksc-att.ksc-att.is-hint { color: var(--ksc-gold-ink); background: var(--ksc-warm); }
.ksc-send.ksc-send { background: var(--ksc-gold); color: #fff; }
.ksc-send.ksc-send:hover { background: var(--ksc-gold-lt); color: #fff; }
.ksc-send.ksc-send:disabled { background: var(--ksc-warm); color: var(--ksc-rule); cursor: default; }
.ksc-att svg, .ksc-send svg { width: 21px; height: 21px; }
.ksc-att:focus-visible, .ksc-send:focus-visible { outline: 2px solid var(--ksc-gold); outline-offset: 2px; }
.ksc-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }

/* ---------- Планшет: над нижней навигацией, кнопка «Наверх» выше ---------- */
@media (min-width: 768px) and (max-width: 1024px) {
	.koto-sc { --ksc-right: 14px; --ksc-bottom: 72px; }
	.ksc-panel { height: min(600px, calc(100vh - 96px)); }
}

/* ---------- Телефон: кнопку заменяет иконка чата в шапке, окно — на весь экран ---------- */
@media (max-width: 767px) {
	.koto-sc { --ksc-right: 12px; --ksc-bottom: calc(64px + env(safe-area-inset-bottom, 0px) + 14px); }
	.ksc-launch.ksc-launch { display: none; }
	.ksc-teaser { position: fixed; right: 12px; left: 12px; bottom: var(--ksc-bottom); width: auto; }
	.ksc-teaser .ksc-cat { display: block; }
	.koto-sc.is-open { inset: 0; right: 0; bottom: 0; }
	.ksc-panel {
		position: fixed; inset: 0; width: 100%; height: 100%; height: 100dvh;
		border-radius: 0; box-shadow: none;
	}
	.ksc-panel .ksc-cat { display: none; }
	.ksc-head { border-radius: 0; padding: calc(12px + env(safe-area-inset-top, 0px)) 8px 12px 18px; }
	.ksc-head h2 { font-size: 23px; }
	.ksc-compose { border-radius: 0; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
	.ksc-compose textarea { font-size: 16px; } /* iOS не зумит поле от 16px */
	.ksc-contact input { font-size: 16px; }
	.ksc-row { max-width: 88%; }
	.ksc-contact .ksc-fields { grid-template-columns: 1fr; }
}
html.ksc-lock, html.ksc-lock body { overflow: hidden !important; }

/* Просмотр фото */
.ksc-lb { position: fixed; inset: 0; z-index: 2147483000; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top, 0px)) 16px max(16px, env(safe-area-inset-bottom, 0px)); background: rgba(20, 13, 6, .92); cursor: zoom-out; }
.ksc-lb img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; cursor: default; }
.ksc-lb-x { position: fixed; top: max(12px, env(safe-area-inset-top, 0px)); right: 12px; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: rgba(245, 240, 232, .16); color: #f5f0e8; display: grid; place-items: center; cursor: pointer; }
.ksc-lb-x:hover { background: rgba(245, 240, 232, .28); }
.ksc-lb-x:focus-visible { outline: 2px solid #d4a070; outline-offset: 2px; }
.ksc-lb-x svg { width: 22px; height: 22px; }

/* ---------- 15.11.2026 по просьбе владельца ----------
   Темы — как карточки «Требует внимания» на рабочем столе CRM: светлый фон, тонкая рамка,
   тёмный заголовок, приглушённая подпись, стрелка справа. Повторы класса — тема (Elementor kit)
   красит все <button> своим фоном с большей специфичностью. */
.koto-sc .ksc-topics.ksc-topics { gap: 8px; border-top: 0; }
.koto-sc .ksc-topic.ksc-topic.ksc-topic {
	display: flex; align-items: center; gap: 12px;
	padding: 11px 14px; background: #fffdf9; color: var(--ksc-pine);
	border: 1px solid #ddd3c2; border-radius: 8px; box-shadow: none;
}
.koto-sc .ksc-topic.ksc-topic.ksc-topic:hover { background: var(--ksc-warm); border-color: var(--ksc-pine); color: var(--ksc-pine); }
.koto-sc .ksc-topic.ksc-topic.ksc-topic:focus-visible { outline: 2px solid var(--ksc-gold); outline-offset: 1px; }
.koto-sc .ksc-topic .ksc-topic-ic { flex: none; width: 22px; height: 22px; color: var(--ksc-gold-ink); }
.koto-sc .ksc-topic .ksc-topic-ic svg { width: 22px; height: 22px; }
.koto-sc .ksc-topic .ksc-topic-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.koto-sc .ksc-topic.ksc-topic b { font-size: 14px; font-weight: 600; line-height: 1.3; color: var(--ksc-bark); }
.koto-sc .ksc-topic.ksc-topic small { font-size: 12px; line-height: 1.4; color: var(--ksc-muted); }
.koto-sc .ksc-topic .ksc-topic-go { flex: none; font-size: 16px; line-height: 1; color: var(--ksc-muted); }
.koto-sc .ksc-topic.ksc-topic:hover .ksc-topic-go { color: var(--ksc-bark); }

/* Мессенджеры — прежние контурные кнопки, значки в фирменных цветах */
.koto-sc .ksc-chans.ksc-chans a svg { width: 18px; height: 18px; }

/* Кнопка «свернуть» в шапке — явно, без фона темы */
.koto-sc .ksc-icon-btn.ksc-icon-btn { background: transparent; color: rgba(245, 240, 232, .8); box-shadow: none; border: 0; }
.koto-sc .ksc-icon-btn.ksc-icon-btn:hover { background: rgba(245, 240, 232, .12); color: #f5f0e8; }
