.multplat-tg-page,
.mp-tg-modal { --tg: #229ed9; --tg-dark: #1b8ec6; }

.multplat-tg-page {
	display: flex;
	flex-direction: column;
	height: calc(100vh - var(--nex-navbar-h, 71px));
	min-height: 520px;
	background: #e7eef3;
}

.mp-tg-inst-actions {
	display: flex;
	align-items: center;
	gap: 0.55rem;
	margin-left: auto;
	flex-shrink: 0;
}
.mp-tg-inst-actions .mp-inst-add { margin-left: 0; }
.mp-tg-add, .mp-tg-info { color: var(--tg); box-shadow: 0 4px 14px rgba(34, 158, 217, 0.22); }
.mp-tg-add:hover, .mp-tg-info:hover { background: #e8f6fc; color: var(--tg-dark); }

.multplat-tg-page.is-empty .mp-inst-hint,
.multplat-tg-page:not(.has-app) .mp-inst-hint { display: block; }

.multplat-tg-app {
	flex: 1;
	min-height: 0;
	display: flex;
	background: #fff;
	overflow: hidden;
	position: relative;
}
.multplat-tg-app.is-idle { display: none; }
.mp-avatar.tg { background: #e8f6fc; color: var(--tg); }

.mp-tg-web {
	display: none;
	flex: 1;
	flex-direction: column;
	background: #e7eef3;
	min-height: 0;
}
.multplat-tg-app.is-offline .mp-tg-web { display: flex; }
.multplat-tg-app.is-offline .mp-tg-workspace { display: none; }
.multplat-tg-app.is-online .mp-tg-web { display: none; }
.multplat-tg-app.is-online .mp-tg-workspace { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.mp-tg-web-bar { height: 140px; background: linear-gradient(135deg, #229ed9, #2aabee); flex-shrink: 0; }
.mp-tg-web-card {
	margin: -88px auto 2rem;
	width: min(920px, calc(100% - 2rem));
	background: #fff;
	border-radius: 12px;
	box-shadow: 0 6px 18px rgba(11, 20, 26, 0.12);
	display: flex;
	flex-wrap: wrap;
	gap: 2rem;
	padding: 2rem;
}
.mp-tg-web-copy { flex: 1 1 280px; }
.mp-tg-web-copy h2 { margin: 0 0 1rem; color: #1c2733; }
.mp-tg-web-copy ol { margin: 0; padding-left: 1.2rem; color: #4a5a6a; line-height: 1.55; }
.mp-tg-web-hint { color: #6b7c8d; font-size: 0.9rem; }
.mp-tg-web-qr {
	flex: 0 0 240px;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.75rem;
}
.mp-qr-frame {
	width: 220px;
	height: 220px;
	border: 1px solid #dfe6ec;
	border-radius: 12px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #fff;
	overflow: hidden;
}
.mp-qr-frame img { width: 100%; height: 100%; object-fit: contain; }
.mp-qr-wait { color: #6b7c8d; text-align: center; padding: 1rem; font-size: 0.9rem; }
.mp-qr-spin {
	display: block;
	width: 28px;
	height: 28px;
	margin: 0 auto 0.6rem;
	border: 3px solid #d7e8f3;
	border-top-color: var(--tg);
	border-radius: 50%;
	animation: mp-tg-spin 0.8s linear infinite;
}
@keyframes mp-tg-spin { to { transform: rotate(360deg); } }
.mp-tg-web-refresh {
	border: 0;
	background: none;
	color: var(--tg);
	font-weight: 600;
	cursor: pointer;
}
.mp-tg-web-refresh:hover { text-decoration: underline; }
.mp-tg-pass { margin-top: 1rem; }
.mp-tg-pass label { display: block; font-size: 0.85rem; color: #4a5a6a; }
.mp-tg-pass input {
	display: block;
	width: 100%;
	margin: 0.35rem 0 0.6rem;
	padding: 0.55rem 0.7rem;
	border: 1px solid #d5dee6;
	border-radius: 8px;
}
.mp-tg-login {
	border: 0;
	border-radius: 10px;
	background: var(--tg);
	color: #fff;
	padding: 0.65rem 1.1rem;
	font-weight: 600;
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
}
.mp-tg-login:hover { background: var(--tg-dark); }

.mp-tg-chat { flex: 1; min-height: 0; display: flex; background: #fff; }
.mp-tg-inbox {
	width: min(340px, 38%);
	border-right: 1px solid #e4eaf0;
	overflow: auto;
	background: #fff;
}
.mp-tg-thread {
	width: 100%;
	border: 0;
	background: transparent;
	display: flex;
	align-items: center;
	gap: 0.7rem;
	padding: 0.75rem 0.9rem;
	text-align: left;
	cursor: pointer;
}
.mp-tg-thread:hover, .mp-tg-thread.is-active { background: #f4f8fb; }
.mp-tg-thread-ava, .mp-tg-thread-ava.is-fallback {
	width: 44px; height: 44px; border-radius: 50%; object-fit: cover;
	background: #e8f6fc; color: var(--tg);
	display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.mp-tg-thread-main { min-width: 0; flex: 1; }
.mp-tg-thread-top { display: flex; justify-content: space-between; gap: 0.4rem; }
.mp-tg-thread-top strong { color: #1c2733; font-size: 0.92rem; }
.mp-tg-thread-top time { color: #8aa0b3; font-size: 0.72rem; }
.mp-tg-thread-main p {
	margin: 0.15rem 0 0; color: #8aa0b3; font-size: 0.82rem;
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mp-tg-unread {
	min-width: 18px;
	height: 18px;
	padding: 0 5px;
	border-radius: 999px;
	background: #229ed9;
	color: #fff;
	font-size: 0.68rem;
	font-weight: 700;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.mp-tg-thread-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; background: #e7eef3; }
.mp-tg-thread-empty, .mp-tg-empty {
	flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
	text-align: center; color: #8aa0b3; padding: 2rem; gap: 0.4rem;
}
.mp-tg-empty i, .mp-tg-thread-empty i { font-size: 2.6rem; color: var(--tg); }
.mp-tg-empty h4, .mp-tg-thread-empty h4 { margin: 0; color: #1c2733; }
.mp-tg-thread-box { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.mp-tg-thread-box .mp-attach-menu { left: 12px; bottom: 64px; }
.mp-tg-chat.is-open .mp-tg-thread-empty { display: none; }
.mp-tg-thread-head {
	display: flex; align-items: center; gap: 0.65rem;
	padding: 0.7rem 1rem; background: #fff; border-bottom: 1px solid #e4eaf0;
}
.mp-tg-thread-back { border: 0; background: transparent; color: #1c2733; font-size: 1.3rem; display: none; }
.mp-tg-thread-who strong { display: block; color: #1c2733; }
.mp-tg-thread-who span { color: #8aa0b3; font-size: 0.75rem; }
.mp-tg-thread-msgs {
	flex: 1; min-height: 0; overflow: auto; padding: 1rem;
	display: flex; flex-direction: column; gap: 0.45rem;
}
.mp-tg-bubble {
	max-width: 78%; padding: 0.55rem 0.75rem; border-radius: 14px;
	font-size: 0.92rem; line-height: 1.4;
}
.mp-tg-bubble.in { align-self: flex-start; background: #fff; color: #1c2733; }
.mp-tg-bubble.out { align-self: flex-end; background: #effdde; color: #1c2733; }
.mp-tg-bubble time { display: block; font-size: 0.68rem; opacity: 0.7; margin-top: 0.25rem; }
.mp-tg-bubble img { max-width: 220px; border-radius: 10px; display: block; }
.mp-tg-emoji {
	display: flex;
	flex-wrap: wrap;
	gap: 0.2rem;
	padding: 0.55rem 0.7rem;
	background: #fff;
	border-top: 1px solid #e4eaf0;
	max-height: 160px;
	overflow: auto;
	flex-shrink: 0;
}
.mp-tg-emoji[hidden] { display: none !important; }
.mp-tg-emoji button {
	border: 0;
	background: transparent;
	width: 34px;
	height: 34px;
	font-size: 1.25rem;
	border-radius: 8px;
}
.mp-tg-emoji button:hover { background: #f0f2f5; }

.mp-tg-thread-send {
	display: flex; align-items: center; gap: 0.5rem;
	padding: 0.7rem 0.85rem; background: #fff; border-top: 1px solid #e4eaf0;
}
.mp-tg-send-field {
	flex: 1;
	display: flex;
	align-items: center;
	border: 1px solid #d5dee6;
	border-radius: 22px;
	padding: 0 0.2rem 0 0.9rem;
	background: #fff;
	min-width: 0;
}
.mp-tg-send-field:focus-within { border-color: var(--tg); }
.mp-tg-thread-send input {
	flex: 1; border: 0; padding: 0.55rem 0.35rem 0.55rem 0; min-width: 0; background: transparent;
}
.mp-tg-thread-send input:focus { outline: 0; }
.mp-tg-thread-send .mp-icon-btn {
	width: 40px; height: 40px; border: 0; border-radius: 50%;
	background: transparent; color: #54656f; font-size: 1.25rem;
	flex-shrink: 0;
}
.mp-tg-thread-send .mp-icon-btn:hover { background: #f0f2f5; color: #1c2733; }
.mp-tg-thread-send button[type="submit"] {
	width: 40px; height: 40px; border: 0; border-radius: 50%;
	background: var(--tg); color: #fff; font-size: 1.15rem; flex-shrink: 0;
}
.mp-tg-thread-send button.is-busy, .mp-tg-thread-send button:disabled { opacity: 0.7; pointer-events: none; }

.mp-tg-modal {
	position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-start; justify-content: center;
	padding: calc(var(--nex-navbar-h, 71px) + 1.2rem) 1rem 1rem;
}
.mp-tg-modal[hidden] { display: none; }
.mp-tg-modal-back { position: absolute; inset: 0; background: rgba(16, 24, 32, 0.45); }
.mp-tg-modal-card {
	position: relative; width: min(440px, 100%); background: #fff; border-radius: 16px;
	padding: 1.4rem; box-shadow: 0 16px 40px rgba(16, 24, 32, 0.2);
}
.mp-tg-help-card { width: min(560px, 100%); max-height: calc(100vh - 8rem); overflow: auto; }
.mp-tg-modal-icon {
	width: 48px; height: 48px; border-radius: 14px; background: #e8f6fc; color: var(--tg);
	display: flex; align-items: center; justify-content: center; font-size: 1.6rem; margin-bottom: 0.7rem;
}
.mp-tg-modal-card h3 { margin: 0 0 0.4rem; }
.mp-tg-modal-text { color: #5b6b7a; margin: 0 0 1rem; }
.mp-tg-modal-card label { display: block; font-size: 0.82rem; color: #5b6b7a; margin-bottom: 0.75rem; }
.mp-tg-modal-card input {
	display: block; width: 100%; margin-top: 0.3rem; border: 1px solid #d5dee6;
	border-radius: 10px; padding: 0.55rem 0.7rem;
}
.mp-tg-modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }
.mp-tg-btn {
	border: 0; border-radius: 10px; background: #229ed9; color: #fff;
	padding: 0.55rem 1rem; font-weight: 600;
}
.mp-tg-btn.ghost { background: #eef3f7; color: #1c2733; }
.mp-tg-help-steps { margin: 0; padding-left: 1.1rem; color: #4a5a6a; }
.mp-tg-help-steps li { margin-bottom: 0.8rem; }
.mp-tg-help-steps strong { display: block; color: #1c2733; margin-bottom: 0.2rem; }

@media (max-width: 800px) {
	.mp-tg-inbox { width: 100%; }
	.mp-tg-chat.is-open .mp-tg-inbox { display: none; }
	.mp-tg-thread-pane { display: none; }
	.mp-tg-chat.is-open .mp-tg-thread-pane { display: flex; }
	.mp-tg-thread-back { display: inline-flex; }
}
