/* =========================================================
   echat v3.0 — iOS 17 Pro Max-inspired Chat Widget
   Frosted glass, pill button, Dynamic Island vibes
   ========================================================= */

.echat-root {
	--ec-bg: var(--bg-lighter, #1c1c1e);
	--ec-surface: var(--bg, #000000);
	--ec-elevated: var(--bg-lighter-2, #2c2c2e);
	--ec-header: rgba(44,44,46,.72);
	--ec-border: var(--bdc-lighter, rgba(255,255,255,.08));
	--ec-text: var(--tt, #f2f2f2);
	--ec-muted: var(--tt-darker, #8e8e93);
	--ec-accent: var(--accent, #ffa332);
	--ec-accent2: var(--accent-darker, #f39b2e);
	--ec-own-bg: rgba(255,163,50,.12);
	--ec-own-border: rgba(255,163,50,.30);
	--ec-danger: #ff453a;
	--ec-radius: 20px;
	--ec-radius-sm: 12px;
	--ec-speed: .25s;
	--ec-blur: 24px;

	position: fixed;
	right: 16px;
	bottom: 0;
	width: 380px;
	max-width: calc(100vw - 32px);
	font: 14px/1.45 -apple-system, 'SF Pro Text', 'Helvetica Neue', 'nunito', sans-serif;
	color: var(--ec-text);
	z-index: 1004;
}
.echat-root * { box-sizing: border-box; }

/* =========== LIGHT-THEME OVERRIDES =========== */
.lt-is-active .echat-root {
	--ec-header: rgba(242,242,247,.72);
	--ec-own-bg: rgba(227,76,0,.07);
	--ec-own-border: rgba(227,76,0,.22);
	--ec-danger: #d32f2f;
}

/* Reset global "button { color: #fff !important }" for echat on light theme */
.lt-is-active .echat-root .echat button {
	color: var(--ec-muted) !important;
	background-color: transparent;
	border-color: transparent;
}
.lt-is-active .echat-root .echat button:hover {
	background-color: rgba(0,0,0,.06);
	color: var(--ec-text) !important;
	border-color: transparent;
}
.lt-is-active .echat-root .echat__btn-send {
	color: var(--ec-accent) !important;
	background-color: transparent;
}
.lt-is-active .echat-root .echat__btn-send.visible:hover {
	background-color: var(--ec-accent);
	color: #fff !important;
}
.lt-is-active .echat-root .echat__offline-btn,
.lt-is-active .echat-root .echat__edit-save {
	color: #fff !important;
	background-color: var(--ec-accent);
}
.lt-is-active .echat-root .echat__offline-btn:hover,
.lt-is-active .echat-root .echat__edit-save:hover {
	background-color: var(--ec-accent2);
	color: #fff !important;
}
.lt-is-active .echat-root .echat__room.active,
.lt-is-active .echat-root .echat__picker-tab.active {
	color: var(--ec-accent) !important;
	background-color: var(--ec-elevated);
}
.lt-is-active .echat-root .echat .ec-lb-btn,
.lt-is-active .echat-root .echat .ec-lb-btn:hover,
.lt-is-active .echat-root .echat .ec-lb-x,
.lt-is-active .echat-root .echat .ec-lb-x:hover {
	color: inherit !important;
	background-color: transparent;
	border-color: transparent;
}

/* Scrollbars */
.lt-is-active .echat__body::-webkit-scrollbar-thumb,
.lt-is-active .echat__picker-body::-webkit-scrollbar-thumb {
	background: rgba(0,0,0,.15);
}
.lt-is-active .echat__textarea::-webkit-scrollbar-thumb {
	background: rgba(0,0,0,.12);
}

/* Hover states: white-alpha → black-alpha */
.lt-is-active .ec-emoji:hover,
.lt-is-active .ec-sticker-item:hover {
	background: rgba(0,0,0,.06);
}
.lt-is-active .echat__picker-tab:hover {
	background: rgba(0,0,0,.06);
}
.lt-is-active .echat__room:hover {
	background: rgba(0,0,0,.04);
}

/* Shell & panel shadows — softer for light */
.lt-is-active .echat {
	box-shadow: 0 -2px 24px rgba(0,0,0,.08);
}
.lt-is-active .minified .echat {
	box-shadow: 0 2px 16px rgba(0,0,0,.10), 0 0 0 .5px rgba(0,0,0,.08);
}
.lt-is-active .echat__msg-act {
	box-shadow: 0 2px 10px rgba(0,0,0,.08);
}
.lt-is-active .echat__attach-menu {
	box-shadow: 0 4px 20px rgba(0,0,0,.10);
}
.lt-is-active .echat__picker {
	box-shadow: 0 -4px 20px rgba(0,0,0,.08);
}
.lt-is-active .echat__shortcode-hint {
	box-shadow: 0 2px 12px rgba(0,0,0,.08);
}

/* Bubble hover: darken slightly instead of brightening */
.lt-is-active .echat__msg-bubble:hover {
	filter: brightness(.97);
}

/* Offline overlay — frosted white instead of frosted black */
.lt-is-active .echat__offline {
	background: rgba(255,255,255,.88);
	color: #444;
}

/* Inline code in messages */
.lt-is-active .echat__msg-text code {
	background: rgba(0,0,0,.06);
	color: var(--ec-accent);
}

/* Input focus ring with light accent */
.lt-is-active .echat__input-row:focus-within {
	box-shadow: 0 0 0 2px rgba(227,76,0,.12);
}

/* Reply chain hover */
.lt-is-active .echat__reply-chain:hover {
	background: rgba(227,76,0,.12);
}

/* Upload progress text readable on light bg */
.lt-is-active .echat__upload-progress {
	color: #333;
	text-shadow: 0 1px 3px rgba(255,255,255,.6);
}

/* =========== MINIMIZED — compact pill =========== */
.echat-root.minified {
	width: auto;
	width: -moz-fit-content;
	width: fit-content;
	right: 16px;
	bottom: 16px;
}
.minified .echat {
	display: inline-flex;
	border-radius: 22px;
	box-shadow:
		0 2px 16px rgba(0,0,0,.22),
		0 0 0 .5px rgba(255,255,255,.06);
	background: #2c2c2e;
	background: var(--ec-header);
	-webkit-backdrop-filter: blur(var(--ec-blur));
	backdrop-filter: blur(var(--ec-blur));
}
.minified .echat__header {
	display: inline-flex;
	align-items: center;
	height: 40px;
	padding: 0 14px;
	border-radius: 22px;
	border-bottom: none;
	background: transparent;
	cursor: pointer;
	gap: 7px;
	justify-content: flex-start;
	touch-action: manipulation;
}
.minified .echat__header:hover {
	background: rgba(255,255,255,.06);
}
.lt-is-active .minified .echat__header:hover {
	background: rgba(0,0,0,.04);
}
.minified .echat__header-icon {
	font-size: 15px;
	color: var(--ec-accent);
}
.minified .echat__header-title {
	font-size: 13px;
	font-weight: 600;
	letter-spacing: .02em;
}
.minified .echat__pulse {
	width: 6px; height: 6px;
}
.minified .echat__header-info {
	gap: 6px;
	align-items: center;
}

/* Mention badge on pill */
.echat__mention-badge {
	display: none;
	min-width: 16px; height: 16px;
	padding: 0 4px;
	background: var(--ec-danger);
	color: #fff;
	font-size: 10px; font-weight: 700;
	border-radius: 8px;
	text-align: center; line-height: 16px;
	animation: ec-pulse 1.5s infinite;
}
.minified .echat__container { display: none; }
.minified .echat__header-actions { display: none; }

/* =========== EXPANDED — normal state =========== */
.echat-root:not(.minified):not(.fullsize) {
	bottom: 0;
}

/* =========== FULLSCREEN =========== */
.echat-root.fullsize {
	right: 0; top: 0; width: 480px; max-width: 100%;
}
@media (max-width: 600px) {
	.echat-root:not(.minified) {
		right: 0; left: 0; bottom: 0;
		width: 100%; max-width: 100%;
	}
	.echat-root.fullsize { width: 100%; }
	.echat-root.minified { right: 12px; bottom: 12px; }
	/* Увеличиваем tap-target до минимума 44px (Fitts' Law) */
	.echat__hbtn {
		width: 44px; height: 44px;
	}
}

/* =========== SHELL =========== */
.echat {
	overflow: hidden;
	border-radius: var(--ec-radius) var(--ec-radius) 0 0;
	box-shadow: 0 -2px 40px rgba(0,0,0,.22);
	background: var(--ec-bg);
	transition: border-radius var(--ec-speed) cubic-bezier(.4,0,.2,1),
	            box-shadow var(--ec-speed) cubic-bezier(.4,0,.2,1),
	            background var(--ec-speed) cubic-bezier(.4,0,.2,1);
}
.fullsize .echat {
	height: 100%; display: flex;
	flex-direction: column; border-radius: 0;
}

/* =========== HEADER =========== */
.echat__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 10px 0 16px;
	height: 48px;
	background: #2c2c2e;
	background: var(--ec-header);
	-webkit-backdrop-filter: blur(var(--ec-blur));
	backdrop-filter: blur(var(--ec-blur));
	user-select: none;
	border-bottom: .5px solid var(--ec-border);
	transition: all var(--ec-speed);
}

.echat__header-info {
	display: flex; align-items: center;
	gap: 8px; pointer-events: none;
}
.echat__header-icon {
	display: none;
	font-size: 17px;
	color: var(--ec-accent);
}
.minified .echat__header-icon { display: inline-block; }
.minified .echat__header-info { pointer-events: auto; }

.echat__header-title {
	font-weight: 700;
	font-size: 16px;
	letter-spacing: -.01em;
}
.echat__pulse {
	width: 8px; height: 8px; border-radius: 50%;
	background: #30d158;
	animation: ec-pulse 2s ease-in-out infinite;
}

.echat__header-actions { display: flex; gap: 2px; }

.echat__hbtn {
	display: inline-flex; align-items: center; justify-content: center;
	width: 34px; height: 34px; border-radius: 50%;
	color: var(--ec-muted); font-size: 15px;
	cursor: pointer; transition: color var(--ec-speed), background var(--ec-speed);
	background: transparent; border: none; padding: 0;
	touch-action: manipulation;
}
.echat__hbtn:hover {
	color: var(--ec-text);
	background: rgba(255,255,255,.08);
}
.lt-is-active .echat__hbtn:hover {
	background: rgba(0,0,0,.06);
}

/* =========== CONTAINER =========== */
.echat__container { position: relative; overflow: hidden; }
.fullsize .echat__container {
	flex: 1; display: flex; flex-direction: column;
}

/* =========== MESSAGE BODY =========== */
.echat__body {
	background: var(--ec-surface);
	padding: 12px 12px 12px 8px;
	overflow-x: hidden;
	overflow-y: auto;
	height: min(480px, 60vh);
	scroll-behavior: smooth;
	overscroll-behavior: contain;
}
.fullsize .echat__body { flex: 1; height: auto; }

.echat__body::-webkit-scrollbar { width: 4px; }
.echat__body::-webkit-scrollbar-track { background: transparent; }
.echat__body::-webkit-scrollbar-thumb {
	background: rgba(255,255,255,.1); border-radius: 4px;
}

/* =========== MESSAGE BUBBLE =========== */
.echat__msg {
	padding: 0 14px 0 42px;
	position: relative;
	animation: ec-fadeUp .2s ease-out both;
}
.echat__msg + .echat__msg { margin-top: 8px; }

.echat__msg-ava {
	width: 32px; height: 32px; border-radius: 50%;
	position: absolute; left: 4px; bottom: 0;
	object-fit: cover; background: var(--ec-elevated);
	border: 1px solid var(--ec-border);
}

.echat__msg-bubble {
	padding: 8px 12px;
	background: var(--ec-elevated);
	border-radius: 18px 18px 18px 6px;
	position: relative;
	transition: background var(--ec-speed);
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
}
.echat__msg-bubble:hover { filter: brightness(1.04); }

/* Role accents */
.echat--boss { border-left: 3px solid var(--ec-danger); }
.echat--admin { border-left: 3px solid #0a84ff; }
.echat--rel { border-left: 3px solid #30d158; }

/* AI Bot */
.echat--bot .echat__msg-bubble {
	background: rgba(99,102,241,.10);
	border-left: 3px solid #818cf8;
}
.echat--bot .echat__msg-name { color: #818cf8; }
.echat--bot .echat__msg-name::after {
	content: 'AI';
	display: inline-flex; align-items: center; justify-content: center;
	margin-left: 5px; padding: 0 5px;
	height: 15px; border-radius: 4px;
	background: #818cf8; color: #fff;
	font-size: 8px; font-weight: 800;
	letter-spacing: .5px; line-height: 1;
	vertical-align: middle;
}
.lt-is-active .echat--bot .echat__msg-bubble {
	background: rgba(99,102,241,.07);
}

/* Bot typing indicator */
.echat__bot-typing {
	display: flex; align-items: center; gap: 4px;
	padding: 12px 16px; margin: 8px 14px 0 42px;
	background: rgba(99,102,241,.10);
	border-left: 3px solid #818cf8;
	border-radius: 18px 18px 18px 6px;
	width: fit-content;
}
.echat__bot-typing span {
	width: 7px; height: 7px; border-radius: 50%;
	background: #818cf8; opacity: .4;
	animation: ec-typing 1.4s infinite ease-in-out;
}
.echat__bot-typing span:nth-child(2) { animation-delay: .2s; }
.echat__bot-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes ec-typing {
	0%, 60%, 100% { transform: translateY(0); opacity: .4; }
	30% { transform: translateY(-6px); opacity: 1; }
}

/* Own messages */
.echat__msg.myself { padding: 0 4px 0 54px; }
.echat__msg.myself .echat__msg-ava { display: none; }
.echat__msg.myself .echat__msg-bubble {
	background: var(--ec-own-bg);
	border: 1px solid var(--ec-own-border);
	border-left: none;
	border-radius: 18px 18px 6px 18px;
}

/* Quoted / mentioned messages */
.echat__msg.quoted .echat__msg-bubble {
	background: rgba(255,163,50,.15);
	border-left: 3px solid var(--ec-accent);
	box-shadow: inset 0 0 0 .5px rgba(255,163,50,.25);
}
.lt-is-active .echat__msg.quoted .echat__msg-bubble {
	background: rgba(227,76,0,.10);
	box-shadow: inset 0 0 0 .5px rgba(227,76,0,.18);
}

/* Message header */
.echat__msg-top {
	display: flex; align-items: center;
	gap: 6px; margin-bottom: 2px; flex-wrap: wrap;
}
.echat__msg-name {
	font-size: 12px; font-weight: 600;
	color: var(--ec-accent);
	text-decoration: none;
	overflow: hidden; white-space: nowrap;
	text-overflow: ellipsis; max-width: 180px;
}
.echat__msg-name:hover { color: var(--ec-accent2); }
.echat__msg.myself .echat__msg-top { display: none; }

.echat__msg-time {
	font-size: 12px; color: var(--ec-text);
	margin-left: auto; white-space: nowrap;
	opacity: .5;
}

/* Badges */
.echat__badge {
	font-size: 9px; font-weight: 700; text-transform: uppercase;
	letter-spacing: .4px; padding: 1px 5px; border-radius: 4px;
	line-height: 1.4;
}
.echat__badge--boss { background: var(--ec-danger); color: #fff; }
.echat__badge--adm { background: #0a84ff; color: #fff; }
.echat__badge--rel { background: #30d158; color: #000; }

/* Message text */
.echat__msg-text {
	word-break: break-word;
	line-height: 1.45;
}
.echat__msg-text code {
	font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
	font-size: .88em; color: var(--ec-accent);
	background: rgba(0,0,0,.15); padding: 1px 5px; border-radius: 4px;
}
.echat__msg-text a {
	color: var(--ec-accent); text-decoration: none;
}
.echat__msg-text a:hover {
	text-decoration: underline; text-underline-offset: 2px;
}

/* Emoji-only → sticker-size */
.echat__msg-text.ec-sticker {
	font-size: 48px; line-height: 1.15; padding: 4px 0;
}

/* =========== MESSAGE ACTIONS — floating pill toolbar =========== */
.echat__msg-act {
	display: none; gap: 2px;
	position: absolute; right: 8px; top: -14px;
	background: var(--ec-elevated);
	border: .5px solid var(--ec-border);
	border-radius: 10px; padding: 2px 3px;
	box-shadow: 0 2px 12px rgba(0,0,0,.2);
	z-index: 2;
}
.echat__msg-bubble:hover .echat__msg-act { display: flex; }
.echat__msg-act button {
	background: none; border: none; padding: 4px 5px;
	font-size: 12px; color: var(--ec-muted); cursor: pointer;
	border-radius: 6px; line-height: 1;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
}
.echat__msg-act button:hover {
	color: var(--ec-text);
	background: rgba(255,255,255,.08);
}
.lt-is-active .echat__msg-act button:hover {
	background: rgba(0,0,0,.06);
}
.echat__msg-act button:hover .fa-ban,
.echat__msg-act button:hover .fa-trash-alt,
.echat__msg-act button:hover .fa-times { color: var(--ec-danger); }

/* =========== MEDIA IN MESSAGES =========== */
.ec-media { margin: 6px 0 2px; max-width: 280px; }
.ec-media__img {
	max-width: 100%; max-height: 260px;
	border-radius: var(--ec-radius-sm);
	cursor: pointer; display: block;
}
.ec-media__video {
	max-width: 100%; max-height: 260px;
	border-radius: var(--ec-radius-sm);
	display: block; background: #000;
}
.ec-media__audio {
	width: 100%; max-width: 260px; height: 40px;
	border-radius: 20px; margin-top: 4px;
}
.ec-embed {
	margin: 6px 0 2px; position: relative;
	padding-bottom: 56.25%; height: 0; max-width: 280px;
	border-radius: var(--ec-radius-sm); overflow: hidden;
}
.ec-embed iframe {
	position: absolute; top: 0; left: 0;
	width: 100%; height: 100%; border: none;
}

/* =========== EDITOR =========== */
.echat__editor {
	background: var(--ec-bg);
	border-top: .5px solid var(--ec-border);
	padding: 6px 8px 8px;
	position: relative;
}

.echat__guest {
	text-align: center; padding: 10px;
	font-size: 13px; color: var(--ec-muted);
}
.echat__guest a { color: var(--ec-accent); font-weight: 600; }

/* Reply bar (editor) */
.echat__reply-bar {
	display: flex; align-items: center; gap: 6px;
	padding: 6px 10px; margin-bottom: 4px;
	background: var(--ec-own-bg);
	border-left: 3px solid var(--ec-accent);
	border-radius: 4px; font-size: 12px;
}
.echat__reply-info {
	flex: 1; min-width: 0;
	display: flex; flex-direction: column; gap: 1px;
}
.echat__reply-name { color: var(--ec-accent); font-weight: 700; }
.echat__reply-preview {
	color: var(--ec-muted); font-size: 11px;
	overflow: hidden; white-space: nowrap;
	text-overflow: ellipsis;
}
.echat__reply-x {
	margin-left: auto; background: none; border: none;
	color: var(--ec-muted); cursor: pointer;
	font-size: 12px; padding: 2px;
	flex-shrink: 0;
}

/* Input row — iOS-style capsule */
.echat__input-row {
	display: flex; align-items: flex-end; gap: 4px;
	background: var(--ec-elevated);
	border-radius: 22px; padding: 4px 6px;
	border: .5px solid var(--ec-border);
	transition: box-shadow var(--ec-speed), border-color var(--ec-speed);
}
.echat__input-row:focus-within {
	border-color: var(--ec-accent);
	box-shadow: 0 0 0 2px rgba(255,163,50,.15);
}

.echat__textarea {
	flex: 1; border: none; background: transparent;
	color: var(--ec-text); font: inherit; font-size: 14px;
	padding: 6px 4px; resize: none; outline: none;
	max-height: 120px; min-height: 32px; line-height: 1.4;
	scrollbar-width: thin;
}
.echat__textarea::placeholder { color: var(--ec-muted); }
.echat__textarea::-webkit-scrollbar { width: 3px; }
.echat__textarea::-webkit-scrollbar-thumb {
	background: var(--ec-border); border-radius: 2px;
}

/* Icon buttons in input */
.echat__ibtn {
	display: inline-flex; align-items: center; justify-content: center;
	width: 30px; height: 30px; border-radius: 50%;
	font-size: 16px; color: var(--ec-muted);
	background: transparent; border: none; cursor: pointer;
	flex-shrink: 0; transition: all .15s; padding: 0;
}
.echat__ibtn:hover {
	color: var(--ec-accent);
	background: rgba(255,255,255,.08);
}
.lt-is-active .echat__ibtn:hover {
	background: rgba(0,0,0,.06);
}
.echat__btn-send {
	color: var(--ec-accent);
	opacity: 0; pointer-events: none;
	width: 0; padding: 0; overflow: hidden;
	transition: opacity .15s, width .15s;
}
.echat__btn-send.visible {
	opacity: 1; pointer-events: auto;
	width: 30px;
}
.echat__btn-send:hover {
	background: var(--ec-accent); color: #000;
}

/* =========== ATTACH MENU =========== */
.echat__attach-menu {
	position: absolute; left: 8px; bottom: 100%;
	margin-bottom: 6px;
	background: var(--ec-elevated);
	border-radius: var(--ec-radius-sm);
	border: .5px solid var(--ec-border);
	box-shadow: 0 4px 20px rgba(0,0,0,.25);
	overflow: hidden; min-width: 140px; z-index: 10;
	-webkit-backdrop-filter: blur(20px);
	backdrop-filter: blur(20px);
}
.echat__attach-item {
	display: flex; align-items: center; gap: 8px;
	width: 100%; padding: 10px 14px; border: none;
	background: transparent; color: var(--ec-text);
	font: inherit; font-size: 13px; cursor: pointer;
	text-align: left;
}
.echat__attach-item:hover {
	background: rgba(255,255,255,.06);
}
.lt-is-active .echat__attach-item:hover {
	background: rgba(0,0,0,.04);
}
.echat__attach-item i {
	font-size: 16px; color: var(--ec-accent);
	width: 20px; text-align: center;
}

/* =========== EMOJI / STICKER PICKER =========== */
.echat__picker {
	position: absolute; left: 0; right: 0;
	bottom: 100%; margin-bottom: 2px;
	background: var(--ec-bg);
	border: .5px solid var(--ec-border);
	border-radius: var(--ec-radius-sm) var(--ec-radius-sm) 0 0;
	box-shadow: 0 -4px 24px rgba(0,0,0,.2);
	z-index: 10; overflow: hidden;
}
.echat__picker-head {
	display: flex; align-items: center; gap: 8px;
	padding: 6px 10px;
	border-bottom: .5px solid var(--ec-border);
}
.echat__picker-tabs { display: flex; gap: 2px; }
.echat__picker-tab {
	width: 34px; height: 30px; border: none;
	background: transparent; color: var(--ec-muted);
	font-size: 16px; border-radius: 8px; cursor: pointer;
	display: inline-flex; align-items: center; justify-content: center;
	transition: all .15s; padding: 0;
}
.echat__picker-tab:hover {
	color: var(--ec-text);
	background: rgba(255,255,255,.06);
}
.echat__picker-tab.active {
	color: var(--ec-accent);
	background: var(--ec-elevated);
}

.echat__picker-search {
	flex: 1; height: 28px; border: none; border-radius: 8px;
	background: var(--ec-elevated); color: var(--ec-text);
	padding: 0 10px; font: inherit; font-size: 12px;
	outline: none;
}
.echat__picker-search::placeholder { color: var(--ec-muted); }

.echat__picker-body {
	height: 220px; overflow-y: auto; padding: 6px;
	overscroll-behavior: contain;
}
.echat__picker-body::-webkit-scrollbar { width: 4px; }
.echat__picker-body::-webkit-scrollbar-thumb {
	background: rgba(255,255,255,.1); border-radius: 2px;
}

/* Emoji category */
.ec-cat-title {
	font-size: 11px; font-weight: 600; color: var(--ec-muted);
	text-transform: uppercase; letter-spacing: .4px;
	padding: 6px 4px 4px; position: sticky; top: 0;
	background: var(--ec-bg); z-index: 1;
}
.ec-cat-grid { display: flex; flex-wrap: wrap; }
.ec-emoji {
	display: inline-flex; align-items: center; justify-content: center;
	width: 38px; height: 36px; font-size: 22px;
	cursor: pointer; border-radius: 8px; transition: all .1s;
}
.ec-emoji:hover {
	background: rgba(255,255,255,.08);
	transform: scale(1.15);
}

/* Sticker grid */
.ec-sticker-grid { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; }
.ec-sticker-item {
	display: flex; align-items: center; justify-content: center;
	width: 72px; height: 72px; font-size: 42px;
	cursor: pointer; border-radius: var(--ec-radius-sm);
	transition: all .15s; background: var(--ec-elevated);
}
.ec-sticker-item:hover {
	transform: scale(1.08);
	background: rgba(255,255,255,.08);
}

/* =========== ROOMS =========== */
.echat__rooms {
	display: flex;
	border-top: .5px solid var(--ec-border);
	background: var(--ec-bg);
}
.echat__room {
	flex: 1; height: 36px; border: none;
	font: inherit; font-size: 11px; font-weight: 600;
	text-transform: uppercase; letter-spacing: .4px;
	color: var(--ec-muted); background: transparent;
	cursor: pointer; transition: all .15s;
}
.echat__room:hover {
	color: var(--ec-text);
	background: rgba(255,255,255,.04);
}
.echat__room.active {
	color: var(--ec-accent);
	background: var(--ec-elevated);
	pointer-events: none;
}

/* =========== OFFLINE OVERLAY =========== */
.echat__offline {
	display: none; position: absolute;
	top: 0; left: 0; right: 0; bottom: 0;
	background: rgba(0,0,0,.8);
	-webkit-backdrop-filter: blur(12px);
	backdrop-filter: blur(12px);
	flex-direction: column; align-items: center;
	justify-content: center; text-align: center;
	padding: 20px; gap: 10px; color: #ccc; font-size: 14px;
}
.echat__offline-icon { font-size: 32px; color: var(--ec-accent); }
.echat__offline-btn {
	height: 36px; padding: 0 24px; border: none;
	background: var(--ec-accent); color: #000;
	font: inherit; font-size: 12px; font-weight: 700;
	border-radius: 18px; cursor: pointer;
	text-transform: uppercase; letter-spacing: .4px;
	transition: all .15s;
}
.echat__offline-btn:hover {
	background: var(--ec-accent2); transform: scale(1.03);
}

/* =========== LOADING =========== */
.echat__loading {
	display: none; position: absolute;
	top: 50%; left: 50%; transform: translate(-50%, -50%);
	width: 36px; height: 36px; z-index: 5;
}
.echat__loading::after {
	content: ''; display: block; width: 100%; height: 100%;
	border: 2.5px solid var(--ec-border);
	border-top-color: var(--ec-accent);
	border-radius: 50%;
	animation: ec-spin .7s linear infinite;
}

/* =========== ANIMATIONS =========== */
@keyframes ec-pulse {
	0%, 100% { opacity: 1; }
	50% { opacity: .35; }
}
@keyframes ec-spin {
	to { transform: rotate(360deg); }
}
@keyframes ec-fadeUp {
	from { opacity: 0; transform: translateY(6px); }
	to { opacity: 1; transform: translateY(0); }
}

/* =========== REPLY CHAIN (Telegram-style) =========== */
.echat__reply-chain {
	display: flex; flex-direction: column;
	padding: 4px 10px; margin-bottom: 4px;
	background: var(--ec-own-bg);
	border-left: 2px solid var(--ec-accent);
	border-radius: 0 8px 8px 0;
	cursor: pointer;
	transition: background .15s;
	max-width: 100%;
}
.echat__reply-chain:hover { background: var(--ec-own-border); }
.echat__reply-chain-head {
	font-size: 11px; font-weight: 700;
	color: var(--ec-accent);
}
.echat__reply-chain-head i {
	transform: scaleX(-1); font-size: 10px;
	margin-right: 2px;
}
.echat__reply-chain-text {
	font-size: 11px; color: var(--ec-muted);
	overflow: hidden; white-space: nowrap;
	text-overflow: ellipsis;
	max-width: 260px;
}

/* Highlight target message on scroll */
.echat__msg.ec-highlight .echat__msg-bubble {
	animation: ec-glow .8s ease-out;
}
@keyframes ec-glow {
	0% { box-shadow: 0 0 0 3px var(--ec-accent); }
	100% { box-shadow: 0 0 0 0 transparent; }
}

/* =========== INLINE EDIT =========== */
.echat__edit-area {
	width: 100%; border: none; border-radius: 8px;
	background: var(--ec-surface); color: var(--ec-text);
	font: inherit; font-size: 13px; padding: 6px 8px;
	resize: none; outline: none; min-height: 36px;
	max-height: 120px; line-height: 1.4;
	box-shadow: inset 0 0 0 1px var(--ec-accent);
}
.echat__edit-area:focus {
	box-shadow: inset 0 0 0 2px var(--ec-accent);
}
.echat__edit-btns {
	display: flex; gap: 6px; margin-top: 4px;
	justify-content: flex-end;
}
.echat__edit-btns button {
	border: none; border-radius: 8px; padding: 4px 12px;
	font: inherit; font-size: 11px; font-weight: 700;
	cursor: pointer; text-transform: uppercase;
	letter-spacing: .3px; transition: all .15s;
}
.echat__edit-save {
	background: var(--ec-accent); color: #000;
}
.echat__edit-save:hover { background: var(--ec-accent2); }
.echat__edit-cancel {
	background: var(--ec-elevated); color: var(--ec-muted);
}
.echat__edit-cancel:hover {
	color: var(--ec-text);
	background: var(--ec-border);
}

/* =========== REPORT BUTTON =========== */
.echat__btn-report { margin-left: auto; }
.echat__btn-report i { color: var(--ec-muted); }
.echat__btn-report:hover i { color: var(--ec-danger); }
.echat__rnum {
	font-size: 10px; font-weight: 700; color: var(--ec-danger);
	margin-left: 2px;
}
.echat__msg.myself .echat__btn-report { display: none; }

/* =========== CENSORED MESSAGE =========== */
.echat--hidden .echat__msg-bubble { opacity: .55; }
.echat__censored {
	display: flex; align-items: center; gap: 6px;
	padding: 4px 0; font-size: 12px;
	color: var(--ec-muted); cursor: pointer;
	font-style: italic;
}
.echat__censored:hover { color: var(--ec-text); }
.echat__censored i { font-size: 14px; }
.echat__censored-body { display: none; }
.echat__censored-body.revealed { display: block; }

/* =========== SHORTCODE HINT =========== */
.echat__shortcode-hint {
	display: none;
	position: absolute; left: 8px; right: 8px;
	bottom: 100%; margin-bottom: 4px;
	background: var(--ec-elevated);
	border: .5px solid var(--ec-border);
	border-radius: 10px;
	padding: 5px 8px;
	box-shadow: 0 2px 12px rgba(0,0,0,.2);
	z-index: 10;
	align-items: center; gap: 6px;
	-webkit-backdrop-filter: blur(20px);
	backdrop-filter: blur(20px);
}
.echat__shortcode-hint[style*="block"],
.echat__shortcode-hint:not([style*="none"]):not(:empty) {
	display: flex;
}
.echat__sh-label {
	font-size: 12px; font-weight: 600;
	color: var(--ec-muted);
	padding-right: 4px;
	border-right: .5px solid var(--ec-border);
	white-space: nowrap;
}
.echat__sh-item {
	display: inline-flex; align-items: center; justify-content: center;
	width: 34px; height: 32px;
	font-size: 20px; cursor: pointer;
	border-radius: 8px;
	transition: all .1s;
}
.echat__sh-item:hover {
	background: rgba(255,255,255,.08);
	transform: scale(1.15);
}
.lt-is-active .echat__sh-item:hover {
	background: rgba(0,0,0,.06);
}

/* =========== UPLOAD PROGRESS =========== */
.echat__upload-preview {
	margin: 6px 0; position: relative; display: inline-block;
}
.echat__upload-preview img {
	max-width: 160px; max-height: 120px;
	border-radius: var(--ec-radius-sm); opacity: .6;
}
.echat__upload-progress {
	position: absolute; top: 50%; left: 50%;
	transform: translate(-50%, -50%);
	font-size: 12px; font-weight: 700;
	color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.5);
}

/* =========== TOUCH: tap-to-show actions (all touch-capable devices) =========== */
.echat__msg-act.ec-touch-visible { display: flex !important; }

@media (hover: none) and (pointer: coarse) {
	.echat__msg-bubble:hover .echat__msg-act { display: none; }
}

/* =========== SAFE AREA (iPhone notch) =========== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
	.echat__editor {
		padding-bottom: calc(8px + env(safe-area-inset-bottom));
	}
	.echat-root.minified {
		bottom: calc(16px + env(safe-area-inset-bottom));
	}
	.echat__rooms {
		padding-bottom: env(safe-area-inset-bottom);
	}
}

/* =========== IMAGE LIGHTBOX (HTML5 Popover, no JS) =========== */
.ec-lb-btn,
.ec-lb-btn:hover,
.ec-lb-x,
.ec-lb-x:hover {
	background: none;
	background-color: transparent;
	border: none;
	border-color: transparent;
	color: inherit;
}
.ec-lb-btn {
	display: inline-block;
	padding: 0;
	margin: 0;
	cursor: pointer;
	line-height: 0;
	height: auto;
	border-radius: 0;
	-webkit-appearance: none;
	appearance: none;
}

/* Fallback: hide popover for browsers without Popover API */
.ec-lb-pop {
	display: none;
}
/* Popover API supported — show when open */
.ec-lb-pop:popover-open {
	display: block;
}

[popover].ec-lb-pop {
	border: none;
	background: rgba(0,0,0,.92);
	-webkit-backdrop-filter: blur(16px);
	backdrop-filter: blur(16px);
	position: fixed;
	top: 0; left: 0; right: 0; bottom: 0;
	margin: 0;
	padding: 0;
	width: 100vw;
	height: 100vh;
	max-width: none;
	max-height: none;
	box-sizing: border-box;
	overflow: hidden;
	animation: ec-lbIn .2s ease-out;
}
.ec-lb-pop::backdrop { background: rgba(0,0,0,.92); }
.ec-lb-x {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	background: none;
	border: none;
	padding: 24px;
	cursor: zoom-out;
	-webkit-appearance: none;
	appearance: none;
}
.ec-lb-x img {
	max-width: 90vw;
	max-height: 90vh;
	border-radius: 12px;
	box-shadow: 0 8px 40px rgba(0,0,0,.5);
	object-fit: contain;
	user-select: none;
	-webkit-user-drag: none;
}
@keyframes ec-lbIn {
	from { opacity: 0; }
	to { opacity: 1; }
}

/* =========== REACTIONS =========== */
.echat__reactions {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	margin-top: 6px;
	position: relative;
}
.echat__reactions:empty { display: none; }
.echat__react {
	display: inline-flex;
	align-items: center;
	gap: 3px;
	background: rgba(255,255,255,.06);
	border: 1px solid rgba(255,255,255,.08);
	border-radius: 12px;
	padding: 2px 8px;
	font-size: 13px;
	line-height: 1.4;
	cursor: pointer;
	color: rgba(255,255,255,.7);
	transition: background .15s, border-color .15s;
	-webkit-appearance: none;
	appearance: none;
	font-family: inherit;
}
.echat__react:hover {
	background: rgba(255,255,255,.1);
	border-color: rgba(255,255,255,.15);
}
.echat__react.active {
	border-color: rgba(99,142,255,.5);
	background: rgba(99,142,255,.1);
	color: rgba(99,142,255,.9);
}
.echat__react-add {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	background: none;
	border: none;
	color: rgba(255,255,255,.2);
	font-size: 12px;
	line-height: 1;
	cursor: pointer;
	padding: 0;
	transition: color .15s;
	-webkit-appearance: none;
	appearance: none;
	font-family: inherit;
}
.echat__react-add:hover {
	color: rgba(255,255,255,.45);
}
.echat__react-picker {
	position: absolute;
	bottom: calc(100% + 4px);
	right: 0;
	display: flex;
	gap: 2px;
	background: rgba(30,30,40,.95);
	border: 1px solid rgba(255,255,255,.12);
	border-radius: 20px;
	padding: 4px 6px;
	backdrop-filter: blur(16px);
	-webkit-backdrop-filter: blur(16px);
	z-index: 100;
	box-shadow: 0 4px 20px rgba(0,0,0,.4);
	animation: ecReactIn .12s ease-out;
}
.echat__react-pick {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	font-size: 20px;
	border-radius: 50%;
	cursor: pointer;
	transition: transform .1s, background .1s;
}
.echat__react-pick:hover {
	transform: scale(1.25);
	background: rgba(255,255,255,.1);
}
@keyframes ecReactIn {
	from { opacity: 0; transform: scale(.9) translateY(4px); }
	to { opacity: 1; transform: scale(1) translateY(0); }
}

/* =========== HELP MODAL =========== */
.echat__help-overlay {
	position: absolute;
	top: 0; left: 0; right: 0; bottom: 0;
	background: var(--ec-bg);
	z-index: 20;
	display: flex;
	flex-direction: column;
	animation: ec-fadeIn .15s ease-out;
	border-radius: var(--ec-radius) var(--ec-radius) 0 0;
	overflow: hidden;
}
.echat__help-modal {
	width: 100%;
	height: 100%;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}
.echat__help-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 16px;
	border-bottom: .5px solid var(--ec-border);
	flex-shrink: 0;
}
.echat__help-title {
	font-size: 15px;
	font-weight: 700;
	letter-spacing: -.01em;
}
.echat__help-close {
	width: 30px; height: 30px;
	display: flex; align-items: center; justify-content: center;
	border-radius: 50%;
	background: var(--ec-elevated);
	border: none;
	color: var(--ec-muted);
	font-size: 14px;
	cursor: pointer;
	transition: all .15s;
	padding: 0;
}
.echat__help-close:hover {
	color: var(--ec-text);
	background: var(--ec-border);
}
.echat__help-body {
	overflow-y: auto;
	padding: 8px 12px 20px;
	overscroll-behavior: contain;
}
.echat__help-body::-webkit-scrollbar { width: 4px; }
.echat__help-body::-webkit-scrollbar-thumb {
	background: rgba(255,255,255,.1); border-radius: 4px;
}

.echat__help-section {
	display: flex;
	gap: 12px;
	padding: 14px 0;
	border-bottom: .5px solid var(--ec-border);
}
.echat__help-section:last-child { border-bottom: none; }

.echat__help-icon {
	font-size: 24px;
	width: 40px; height: 40px;
	display: flex; align-items: center; justify-content: center;
	background: var(--ec-elevated);
	border-radius: 12px;
	flex-shrink: 0;
}
.echat__help-content {
	flex: 1; min-width: 0;
}
.echat__help-content h4 {
	font-size: 13px;
	font-weight: 700;
	margin: 0 0 4px;
	color: var(--ec-text);
}
.echat__help-content p {
	font-size: 12px;
	color: var(--ec-muted);
	margin: 0 0 6px;
	line-height: 1.5;
}
.echat__help-content p:last-child { margin-bottom: 0; }
.echat__help-content b {
	color: var(--ec-accent);
	font-weight: 600;
}
.echat__help-content code {
	font-family: 'SF Mono', 'Cascadia Code', monospace;
	font-size: .88em;
	background: rgba(255,255,255,.06);
	padding: 1px 5px;
	border-radius: 4px;
	color: var(--ec-accent);
}
.echat__help-example {
	font-size: 12px;
	padding: 6px 10px;
	margin: 6px 0;
	background: var(--ec-elevated);
	border-left: 2px solid #818cf8;
	border-radius: 0 8px 8px 0;
	color: var(--ec-text);
	font-family: inherit;
}
.echat__help-fmt {
	display: flex;
	flex-direction: column;
	gap: 3px;
	font-size: 12px;
	color: var(--ec-muted);
}
.echat__help-fmt span {
	display: flex;
	align-items: center;
	gap: 6px;
}

/* =========== TOAST =========== */
.echat__toast {
	position: absolute;
	bottom: 70px;
	left: 50%;
	transform: translateX(-50%) translateY(8px);
	max-width: 90%;
	padding: 8px 16px;
	background: rgba(30, 30, 40, .92);
	border: 1px solid rgba(255,255,255,.1);
	border-radius: 12px;
	backdrop-filter: blur(12px);
	-webkit-backdrop-filter: blur(12px);
	color: rgba(255,255,255,.85);
	font-size: 13px;
	line-height: 1.4;
	text-align: center;
	z-index: 200;
	opacity: 0;
	transition: opacity .25s, transform .25s;
	pointer-events: none;
	box-shadow: 0 4px 16px rgba(0,0,0,.35);
}
.echat__toast.visible {
	opacity: 1;
	transform: translateX(-50%) translateY(0);
}

@keyframes ec-fadeIn {
	from { opacity: 0; }
	to { opacity: 1; }
}
