#twc-widget {
	--twc-accent: #2AABEE;
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Many themes apply global rules like "svg { width:100%; height:auto; }" or
   "button { padding: ...; }" that fight with this widget's own sizing, making
   icons look stretched, clipped, or off-center. Lock these down explicitly. */
#twc-widget, #twc-widget *, #twc-widget *::before, #twc-widget *::after {
	box-sizing: border-box;
}

#twc-widget svg {
	display: block;
	max-width: none;
	flex-shrink: 0;
}

#twc-launcher svg,
#twc-send svg {
	width: 100%;
	height: 100%;
}

#twc-launcher, #twc-send, #twc-input {
	-webkit-appearance: none;
	appearance: none;
	line-height: normal;
}

#twc-launcher {
	width: 64px;
	height: 64px;
	min-width: 64px;
	min-height: 64px;
	padding: 13px;
	border-radius: 50%;
	border: none;
	background: #ffffff;
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#twc-icon-chat, #twc-icon-close {
	width: 100%;
	height: 100%;
}

#twc-icon-close {
	background: var(--twc-accent);
	border-radius: 50%;
	padding: 7px;
}

#twc-launcher:hover {
	transform: translateY(-2px);
	box-shadow: 0 10px 22px rgba(0, 0, 0, 0.28);
}

#twc-launcher:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 3px;
}

#twc-panel {
	position: absolute;
	right: 0;
	bottom: 72px;
	width: 330px;
	max-width: calc(100vw - 32px);
	height: 460px;
	max-height: calc(100vh - 120px);
	background: #fff;
	border-radius: 14px;
	box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transform-origin: bottom right;
	animation: twc-pop-in 0.16s ease-out;
}

#twc-panel.twc-hidden {
	display: none;
}

@keyframes twc-pop-in {
	from { opacity: 0; transform: scale(0.92) translateY(8px); }
	to   { opacity: 1; transform: scale(1) translateY(0); }
}

#twc-header {
	background: var(--twc-accent);
	color: #fff;
	padding: 14px 16px;
	font-size: 15px;
	font-weight: 600;
	flex-shrink: 0;
}

#twc-messages {
	flex: 1;
	overflow-y: auto;
	padding: 14px;
	background: #f4f6f8;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.twc-msg {
	display: flex;
	flex-direction: column;
	max-width: 80%;
}

.twc-msg-visitor {
	align-self: flex-end;
	align-items: flex-end;
}

.twc-msg-admin {
	align-self: flex-start;
	align-items: flex-start;
}

.twc-bubble {
	padding: 9px 13px;
	border-radius: 14px;
	font-size: 14px;
	line-height: 1.4;
	word-wrap: break-word;
}

.twc-msg-visitor .twc-bubble {
	background: var(--twc-accent);
	color: #fff;
	border-bottom-right-radius: 4px;
}

.twc-msg-admin .twc-bubble {
	background: #fff;
	color: #1a1a1a;
	border: 1px solid #e3e6ea;
	border-bottom-left-radius: 4px;
}

.twc-meta {
	display: flex;
	align-items: center;
	gap: 4px;
	margin-top: 3px;
	padding: 0 4px;
}

.twc-time {
	font-size: 11px;
	color: #9aa3ab;
}

.twc-status {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 13px;
	height: 13px;
	color: #9aa3ab;
}

.twc-status-sent {
	color: var(--twc-accent);
}

.twc-status-failed {
	color: #e0453f;
}

.twc-status-sending {
	gap: 2px;
	width: auto;
}

.twc-dot {
	width: 4px;
	height: 4px;
	border-radius: 50%;
	background: #b6bcc2;
	display: inline-block;
	animation: twc-blink 1.1s infinite ease-in-out;
}

.twc-dot:nth-child(2) { animation-delay: 0.15s; }
.twc-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes twc-blink {
	0%, 80%, 100% { opacity: 0.3; }
	40% { opacity: 1; }
}

#twc-form {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px;
	border-top: 1px solid #e8eaed;
	background: #fff;
	flex-shrink: 0;
}

#twc-input {
	flex: 1;
	border: 1px solid #dde1e5;
	border-radius: 20px;
	padding: 9px 14px;
	font-size: 14px;
	outline: none;
	min-width: 0;
}

#twc-input:focus {
	border-color: var(--twc-accent);
}

#twc-send {
	width: 36px;
	height: 36px;
	min-width: 36px;
	min-height: 36px;
	padding: 9px;
	border-radius: 50%;
	border: none;
	background: var(--twc-accent);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	flex-shrink: 0;
}

#twc-send:disabled {
	opacity: 0.6;
	cursor: default;
}

@media (max-width: 420px) {
	#twc-panel {
		width: calc(100vw - 24px);
		right: -8px;
	}
}
