:root {
	--app-height: 100vh;
	/*
	 * The viewport container already excludes its top chrome/status bar.
	 * Keeping this at zero prevents a duplicate inset inside native WebViews.
	 */
	--safe-area-top: 0px;
	--safe-area-right: env(safe-area-inset-right);
	--safe-area-bottom: env(safe-area-inset-bottom);
	--safe-area-left: env(safe-area-inset-left);
	--ink: #17213b;
	--muted: #77809a;
	--line: #e9ebf2;
	--soft: #f7f8fb;
	--primary: #5b21f4;
	--primary-dark: #4012c6;
	--primary-soft: #f0eaff;
	--white: #fff;
	--shadow: 0 18px 55px rgba(49, 35, 95, .12);
}

html.yadid-webview {
	--safe-area-top: 0px;
	--safe-area-right: 0px;
	--safe-area-bottom: 0px;
	--safe-area-left: 0px;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
	background:
		radial-gradient(circle at 12% 8%, rgba(91, 33, 244, .10), transparent 30rem),
		#f4f3f8;
	color: var(--ink);
	font-family: "DM Sans", sans-serif;
}

button, input, textarea { font: inherit; }
button { color: inherit; }

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.chat-app {
	display: grid;
	grid-template-columns: 330px minmax(430px, 1fr) 285px;
	width: min(1460px, calc(100vw - 36px));
	height: calc(100vh - 36px);
	min-height: 650px;
	margin: 18px auto;
	background: var(--white);
	border: 1px solid rgba(220, 220, 231, .8);
	border-radius: 22px;
	box-shadow: var(--shadow);
	overflow: hidden;
}

.conversation-panel, .details-panel {
	display: flex;
	flex-direction: column;
	min-width: 0;
	background: var(--white);
}

.conversation-panel { border-right: 1px solid var(--line); }
.details-panel { border-left: 1px solid var(--line); padding: 20px 24px; overflow-y: auto; }

.brand-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 24px 24px 12px;
}

.brand {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	color: var(--ink);
	font-family: "Manrope", sans-serif;
	font-size: 23px;
	font-weight: 800;
	letter-spacing: -.8px;
	text-decoration: none;
}

.brand-mark {
	display: grid;
	place-items: center;
	width: 37px;
	height: 37px;
	color: var(--white);
	background: linear-gradient(145deg, #7c3cff, #4a13db);
	border-radius: 12px 12px 12px 5px;
	font-size: 20px;
	box-shadow: 0 7px 17px rgba(91, 33, 244, .28);
}

.icon-button, .composer-action {
	display: grid;
	place-items: center;
	width: 38px;
	height: 38px;
	padding: 0;
	border: 1px solid var(--line);
	border-radius: 11px;
	background: var(--white);
	cursor: pointer;
	transition: .2s ease;
}

.icon-button:hover, .composer-action:hover { border-color: #cfc4f5; background: var(--primary-soft); color: var(--primary); }
.new-chat { border: 0; background: var(--primary); color: var(--white); font-size: 22px; }
.new-chat:hover { background: var(--primary-dark); color: var(--white); }

.inbox-heading {
	display: flex;
	align-items: end;
	justify-content: space-between;
	padding: 14px 24px 17px;
}

.eyebrow {
	margin: 0 0 3px;
	color: var(--primary);
	font-size: 11px;
	font-weight: 700;
	letter-spacing: .1em;
	text-transform: uppercase;
}

h1, h2 { font-family: "Manrope", sans-serif; }
h1 { margin: 0; font-size: 25px; letter-spacing: -.6px; }

.unread-total {
	display: grid;
	place-items: center;
	width: 24px;
	height: 24px;
	margin-bottom: 3px;
	color: var(--primary);
	background: var(--primary-soft);
	border-radius: 8px;
	font-size: 12px;
	font-weight: 700;
}

.search-box {
	display: flex;
	align-items: center;
	gap: 9px;
	height: 43px;
	margin: 0 24px 15px;
	padding: 0 12px;
	background: var(--soft);
	border: 1px solid transparent;
	border-radius: 12px;
	color: #9aa1b5;
	transition: .2s ease;
}

.search-box:focus-within { border-color: #c9b8ff; background: var(--white); box-shadow: 0 0 0 3px rgba(91, 33, 244, .08); }
.search-box input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 13px; }
.search-box input::placeholder { color: #9aa1b5; }
.search-box kbd { padding: 3px 6px; border: 1px solid #dedfe7; border-radius: 5px; background: var(--white); color: #9aa1b5; font: 10px "DM Sans", sans-serif; }

.filter-tabs {
	display: flex;
	gap: 5px;
	padding: 0 24px 14px;
	border-bottom: 1px solid var(--line);
}

.filter-tab {
	padding: 7px 12px;
	border: 0;
	border-radius: 9px;
	background: transparent;
	color: var(--muted);
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
}

.filter-tab.active { color: var(--primary); background: var(--primary-soft); }
.conversation-list { flex: 1; overflow-y: auto; padding: 9px; }

.conversation {
	display: flex;
	align-items: center;
	gap: 12px;
	width: 100%;
	padding: 12px 14px;
	border: 0;
	border-radius: 13px;
	background: transparent;
	text-align: left;
	cursor: pointer;
	transition: .16s ease;
}

.conversation:hover { background: #f8f7fc; }
.conversation.active { background: var(--primary-soft); }
.conversation[hidden] { display: none; }

.avatar {
	position: relative;
	display: grid;
	flex: 0 0 auto;
	place-items: center;
	width: 45px;
	height: 45px;
	border-radius: 14px;
	color: var(--white);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: .03em;
}

.avatar-coral { background: linear-gradient(145deg, #ff987e, #e85d7a); }
.avatar-violet { background: linear-gradient(145deg, #8a68f8, #5432d9); }
.avatar-gold { background: linear-gradient(145deg, #f5bd58, #e78738); }
.avatar-blue { background: linear-gradient(145deg, #5db5f1, #3276d6); }
.avatar-green { background: linear-gradient(145deg, #66cda7, #239977); }
.avatar-dark { background: linear-gradient(145deg, #394666, #17213b); }

.presence {
	position: absolute;
	right: -1px;
	bottom: -1px;
	width: 12px;
	height: 12px;
	background: #32c38c;
	border: 2px solid var(--white);
	border-radius: 50%;
}

.conversation.active .presence { border-color: var(--primary-soft); }
.conversation-copy { min-width: 0; flex: 1; }
.conversation-top, .conversation-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.conversation-top strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.conversation-top time { flex: 0 0 auto; color: #9aa1b5; font-size: 10px; }
.conversation-bottom { margin-top: 5px; color: var(--muted); font-size: 11px; }
.conversation-bottom > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-bottom b { display: grid; flex: 0 0 auto; place-items: center; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 8px; background: var(--primary); color: var(--white); font-size: 9px; }

.profile-chip {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 10px 16px 16px;
	padding: 12px;
	border: 1px solid var(--line);
	border-radius: 14px;
}

.profile-chip .avatar { width: 38px; height: 38px; border-radius: 11px; }
.profile-chip > span:nth-child(2) { display: flex; min-width: 0; flex: 1; flex-direction: column; font-size: 12px; }
.profile-chip small { margin-top: 2px; color: var(--muted); }
.profile-chip .icon-button { width: 30px; height: 30px; border: 0; }

.message-panel { display: flex; min-width: 0; flex-direction: column; background: #fbfbfd; }

.message-header {
	display: flex;
	align-items: center;
	gap: 12px;
	min-height: 78px;
	padding: 15px 22px;
	background: rgba(255, 255, 255, .92);
	border-bottom: 1px solid var(--line);
}

.message-header .avatar { width: 44px; height: 44px; }
.contact-heading { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.contact-heading strong { font-size: 14px; }
.contact-heading span { display: flex; align-items: center; gap: 5px; margin-top: 4px; color: var(--muted); font-size: 11px; }
.contact-heading i { width: 6px; height: 6px; border-radius: 50%; background: #32c38c; }
.header-actions { display: flex; gap: 8px; }
.mobile-back { display: none; }

.messages {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 8px;
	overflow-y: auto;
	padding: 28px clamp(24px, 6vw, 72px);
	background-image: radial-gradient(#e2deef 0.7px, transparent 0.7px);
	background-size: 15px 15px;
}

.date-divider { display: flex; align-items: center; gap: 12px; margin: 0 0 13px; color: #9ca2b3; font-size: 10px; font-weight: 600; }
.date-divider::before, .date-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.date-divider span { padding: 5px 10px; background: var(--white); border: 1px solid var(--line); border-radius: 10px; }

.message {
	max-width: min(72%, 520px);
	padding: 11px 14px 7px;
	border: 1px solid var(--line);
	border-radius: 15px 15px 15px 4px;
	background: var(--white);
	box-shadow: 0 5px 16px rgba(36, 39, 58, .04);
	animation: message-in .22s ease both;
}

@keyframes message-in {
	from { opacity: 0; transform: translateY(5px); }
	to { opacity: 1; transform: translateY(0); }
}

.message.sent {
	align-self: flex-end;
	border-color: transparent;
	border-radius: 15px 15px 4px 15px;
	background: linear-gradient(145deg, #6630f6, #501bd9);
	color: var(--white);
	box-shadow: 0 7px 20px rgba(91, 33, 244, .16);
}

.message p { margin: 0; font-size: 13px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.message time { display: block; margin-top: 4px; color: #a1a7b6; font-size: 9px; text-align: right; }
.message.sent time { color: rgba(255, 255, 255, .68); }
.message.sent time span { margin-left: 3px; color: #adf0dd; }
.message:has(.message-media) { padding: 6px; }
.message-media { display: block; width: 230px; max-width: 100%; padding: 0; overflow: hidden; border: 0; border-radius: 11px; background: #fff; text-align: left; cursor: pointer; }
.message-media-preview {
	display: block;
	aspect-ratio: 16 / 10;
	background:
		linear-gradient(160deg, transparent 0 58%, rgba(26, 48, 58, .72) 59%),
		radial-gradient(circle at 72% 28%, #ffe9ad 0 8%, transparent 9%),
		linear-gradient(#79b8d7 0 56%, #d6b17a 57% 66%, #386a75 67%);
}
.message-media-copy { display: block; padding: 9px 10px; color: var(--ink); font-size: 10px; font-weight: 700; }

.typing {
	align-self: flex-start;
	padding: 11px 15px;
	background: var(--white);
	border: 1px solid var(--line);
	border-radius: 14px 14px 14px 4px;
}

.typing span { display: inline-block; width: 5px; height: 5px; margin: 0 1px; background: #9ca2b3; border-radius: 50%; animation: bounce .9s infinite alternate; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { to { transform: translateY(-3px); opacity: .45; } }

.composer {
	display: flex;
	align-items: flex-end;
	gap: 9px;
	padding: 15px 20px 18px;
	background: var(--white);
	border-top: 1px solid var(--line);
}

.composer-action { flex: 0 0 auto; color: var(--muted); font-size: 20px; }
.message-input { min-width: 0; flex: 1; }
.message-input textarea {
	display: block;
	width: 100%;
	max-height: 110px;
	padding: 10px 13px;
	resize: none;
	border: 1px solid var(--line);
	border-radius: 12px;
	outline: 0;
	color: var(--ink);
	line-height: 1.35;
}
.message-input textarea:focus { border-color: #bba7fb; box-shadow: 0 0 0 3px rgba(91, 33, 244, .08); }
.message-input textarea::placeholder { color: #a5aaba; }

.send-button {
	height: 40px;
	padding: 0 11px 0 15px;
	border: 0;
	border-radius: 11px;
	background: var(--primary);
	color: var(--white);
	font-size: 12px;
	font-weight: 700;
	cursor: pointer;
	box-shadow: 0 6px 15px rgba(91, 33, 244, .22);
}
.send-button:hover { background: var(--primary-dark); }
.send-button span { display: inline-grid; place-items: center; width: 21px; height: 21px; margin-left: 5px; background: rgba(255, 255, 255, .17); border-radius: 7px; }

.details-actions { display: flex; justify-content: flex-end; }
.details-actions .icon-button { width: 32px; height: 32px; border: 0; font-size: 21px; }
.profile-avatar { width: 76px; height: 76px; margin: 8px auto 11px; border-radius: 22px; font-size: 18px; box-shadow: 0 9px 25px rgba(232, 93, 122, .25); }
.profile-avatar .presence { width: 16px; height: 16px; border-width: 3px; }
.details-panel h2 { margin: 0; text-align: center; font-size: 17px; }
.details-panel > p { margin: 4px 0 0; color: var(--muted); text-align: center; font-size: 11px; }

.quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 20px 0; }
.quick-actions button {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-direction: column;
	padding: 9px 4px;
	border: 0;
	border-radius: 11px;
	background: var(--soft);
	color: var(--muted);
	font-size: 10px;
	cursor: pointer;
}
.quick-actions button:hover { background: var(--primary-soft); color: var(--primary); }
.quick-actions span { color: var(--ink); font-size: 16px; }

.detail-section { padding: 16px 0; border-top: 1px solid var(--line); }
.detail-heading, .detail-row { display: flex; align-items: center; width: 100%; padding: 0; border: 0; background: transparent; cursor: pointer; }
.detail-heading { justify-content: space-between; margin-bottom: 12px; font-size: 11px; }
.detail-heading span { color: var(--primary); font-size: 10px; font-weight: 600; }
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.media-tile { aspect-ratio: 1; border-radius: 9px; background-size: cover; }
.tile-one { background: linear-gradient(145deg, rgba(54, 133, 212, .2), rgba(70, 44, 137, .15)), linear-gradient(25deg, #40667b 0 35%, #d6ae79 36% 55%, #83b9ce 56%); }
.tile-two { background: radial-gradient(circle at 50% 50%, #f6e4b6 0 27%, #c96f45 28% 35%, #555a45 36% 41%, #d5a35d 42%); }
.tile-three { background: linear-gradient(155deg, transparent 0 45%, #344b67 46%), linear-gradient(25deg, #d5a99e, #7da4bc); }
.detail-row { gap: 9px; padding: 8px 1px; font-size: 11px; text-align: left; }
.detail-row > span { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 8px; background: var(--soft); }
.detail-row strong { flex: 1; font-weight: 600; }
.detail-row b { color: #9ca2b3; font-size: 11px; }
.danger-zone .detail-row { color: #d84e68; }
.privacy-note { margin-top: auto !important; padding-top: 18px; font-size: 9px !important; }

.media-viewer {
	position: fixed;
	z-index: 100;
	inset: 0;
	display: grid;
	place-items: center;
	padding: 22px;
	background: rgba(8, 13, 27, .88);
	backdrop-filter: blur(14px);
}
.media-viewer[hidden] { display: none; }
.media-viewer-panel { width: min(880px, 100%); overflow: hidden; border: 1px solid rgba(255,255,255,.15); border-radius: 20px; background: #10182a; color: #fff; box-shadow: 0 28px 80px rgba(0,0,0,.45); }
.media-viewer-panel header, .media-viewer-panel footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 15px 18px; }
.media-viewer-panel header > div { display: flex; min-width: 0; flex-direction: column; }
.media-viewer-panel header strong { font-size: 13px; }
.media-viewer-panel header span, .media-viewer-panel footer { color: #aeb8ce; font-size: 10px; }
.media-viewer-panel .icon-button { border-color: rgba(255,255,255,.13); background: rgba(255,255,255,.08); color: #fff; }
.protected-photo {
	width: 100%;
	aspect-ratio: 16 / 9;
	background:
		linear-gradient(160deg, transparent 0 58%, rgba(22, 45, 54, .8) 59%),
		radial-gradient(circle at 72% 27%, #ffe6a1 0 7%, transparent 7.5%),
		linear-gradient(#72b7d7 0 56%, #d9af72 57% 66%, #326a75 67%);
}
body.media-open { overflow: hidden; }

@media (max-width: 1080px) {
	.chat-app { grid-template-columns: 310px minmax(420px, 1fr); }
	.details-panel { display: none; }
}

@media (max-width: 760px), (orientation: landscape) and (max-height: 520px) and (max-width: 920px) {
	body { background: var(--white); }
	.chat-app { display: block; width: 100%; height: 100dvh; min-height: 0; margin: 0; border: 0; border-radius: 0; box-shadow: none; }
	.conversation-panel, .message-panel { height: 100%; }
	.conversation-panel { border: 0; }
	.message-panel { display: none; }
	.chat-app.chat-open .conversation-panel { display: none; }
	.chat-app.chat-open .message-panel { display: flex; }
	.mobile-back { display: grid; border: 0; }
	.message-header { min-height: 70px; padding: 11px 13px; }
	.header-actions .icon-button:nth-child(2) { display: none; }
	.messages { padding: 22px 16px; }
	.message { max-width: 84%; }
	.composer { padding: 11px 12px max(11px, var(--safe-area-bottom)); }
	.composer-action { width: 36px; height: 36px; }
	.emoji-button { display: none; }
	.send-button { width: 43px; padding: 0; font-size: 0; }
	.send-button span { margin: 0; background: transparent; font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Mobile production sizing and safe-area behavior. */
html {
	min-width: 280px;
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}

body {
	height: var(--app-height);
	min-height: 100svh;
	min-height: 100dvh;
	min-height: var(--app-height);
	font-size: 16px;
	line-height: 1.5;
	overflow: hidden;
	-webkit-font-smoothing: antialiased;
}

a.icon-button {
	color: inherit;
	text-decoration: none;
}

.icon-button,
.composer-action { width: 44px; height: 44px; }
.conversation { min-height: 72px; }
.conversation-top strong,
.message-header .contact-heading strong { font-size: 14px; }
.conversation-bottom,
.message-header .contact-heading span,
.profile-chip > span:nth-child(2),
.filter-tab { font-size: 13px; }
.conversation-top time,
.date-divider,
.message time,
.message-media-copy,
.details-panel > p,
.privacy-note { font-size: 12px !important; }
.message p { font-size: 16px; line-height: 1.5; }
.message-input textarea { min-height: 44px; font-size: 16px; }
.send-button { min-width: 44px; height: 44px; font-size: 14px; }

@media (max-width: 760px), (orientation: landscape) and (max-height: 520px) and (max-width: 920px) {
	.chat-app {
		width: 100dvw;
		height: 100svh;
		height: 100dvh;
		height: var(--app-height);
	}
	.brand-row {
		padding:
			max(14px, var(--safe-area-top))
			max(16px, var(--safe-area-right))
			12px
			max(16px, var(--safe-area-left));
	}
	.inbox-heading,
	.filter-tabs,
	.conversation-list,
	.profile-chip {
		padding-left: max(16px, var(--safe-area-left));
		padding-right: max(16px, var(--safe-area-right));
	}
	.search-box {
		margin-left: max(16px, var(--safe-area-left));
		margin-right: max(16px, var(--safe-area-right));
	}
	.profile-chip { margin-bottom: var(--safe-area-bottom); }
	.message-header {
		min-height: calc(68px + var(--safe-area-top));
		padding:
			max(10px, var(--safe-area-top))
			max(12px, var(--safe-area-right))
			10px
			max(12px, var(--safe-area-left));
	}
	.header-actions .icon-button:not([href]) { display: none; }
	.messages {
		padding:
			22px
			max(14px, var(--safe-area-right))
			22px
			max(14px, var(--safe-area-left));
	}
	.message { max-width: min(88%, 520px); }
	.composer {
		padding:
			11px
			max(12px, var(--safe-area-right))
			max(11px, var(--safe-area-bottom))
			max(12px, var(--safe-area-left));
	}
	.composer-action { width: 44px; height: 44px; }
	.send-button { width: 46px; }
	.media-viewer {
		padding:
			max(12px, var(--safe-area-top))
			max(12px, var(--safe-area-right))
			max(12px, var(--safe-area-bottom))
			max(12px, var(--safe-area-left));
	}
}

@media (max-width: 360px) {
	.message-header { gap: 8px; }
	.message-header .avatar { width: 40px; height: 40px; }
	.contact-heading strong { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
	.messages { padding-inline: 10px; }
	.composer { gap: 7px; padding-inline: 9px; }
}

.brand {
	width: 108px;
	height: 44px;
}
.brand img {
	display: block;
	width: 100%;
	height: auto;
	max-height: 42px;
	object-fit: contain;
}
