.km-contact-seller {
	display: grid;
	gap: 0.8rem;
	margin-top: 1rem;
	padding-top: 1rem;
	border-top: 1px solid var(--km-neutral-100);
}

.km-contact-seller label {
	display: grid;
	gap: 0.45rem;
	margin: 0;
}

.km-contact-seller textarea {
	min-height: 7rem;
}

.km-contact-seller__actions,
.km-message-reply-form__actions {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	flex-wrap: wrap;
}

.km-messages-shell {
	display: grid;
	gap: 1rem;
}

.km-conversation-list,
.km-message-thread {
	min-width: 0;
	border: 1px solid var(--km-neutral-100);
	border-radius: var(--km-radius-lg);
	background: var(--km-neutral-0);
	box-shadow: var(--km-shadow-sm);
	overflow: hidden;
}

.km-conversation-list {
	display: grid;
	align-content: start;
}

.km-conversation-card {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr) auto;
	gap: 0.75rem;
	padding: 0.9rem;
	border-bottom: 1px solid var(--km-neutral-100);
	color: var(--km-neutral-900);
	text-decoration: none;
	transition: background 140ms ease;
}

.km-conversation-card:hover,
.km-conversation-card.is-active {
	background: rgba(241, 87, 34, 0.06);
}

.km-conversation-card__avatar {
	display: inline-grid;
	place-items: center;
	width: 2.5rem;
	height: 2.5rem;
	border-radius: var(--km-radius-pill);
	background: var(--km-primary);
	color: var(--km-neutral-0);
	font-weight: 800;
}

.km-conversation-card__body {
	display: grid;
	min-width: 0;
	gap: 0.15rem;
}

.km-conversation-card__body strong,
.km-conversation-card__body small,
.km-conversation-card__body em {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.km-conversation-card__body small,
.km-conversation-card__body em,
.km-conversation-card__meta {
	color: var(--km-neutral-500);
	font-size: 0.86rem;
	font-style: normal;
}

.km-conversation-card__meta {
	display: grid;
	gap: 0.25rem;
	justify-items: end;
}

.km-unread-dot {
	display: inline-flex;
	padding: 0.18rem 0.5rem;
	border-radius: var(--km-radius-pill);
	background: var(--km-primary);
	color: var(--km-neutral-0);
	font-size: 0.72rem;
	font-weight: 800;
}

.km-message-thread {
	display: grid;
	grid-template-rows: auto minmax(18rem, 1fr) auto;
}

.km-message-thread__header {
	padding: 1rem;
	border-bottom: 1px solid var(--km-neutral-100);
	background: var(--km-neutral-50);
}

.km-message-thread__header div {
	display: grid;
	gap: 0.15rem;
}

.km-message-thread__header a {
	color: var(--km-primary);
	font-weight: 800;
	text-decoration: none;
}

.km-message-thread__body {
	display: grid;
	align-content: start;
	gap: 0.8rem;
	max-height: 34rem;
	padding: 1rem;
	overflow: auto;
	background: var(--km-neutral-50);
}

.km-message-bubble {
	display: grid;
	gap: 0.35rem;
	max-width: min(100%, 34rem);
	padding: 0.85rem 1rem;
	border: 1px solid var(--km-neutral-100);
	border-radius: var(--km-radius-xl);
	background: var(--km-neutral-0);
}

.km-message-bubble.is-mine {
	justify-self: end;
	background: rgba(241, 87, 34, 0.1);
	border-color: rgba(241, 87, 34, 0.18);
}

.km-message-bubble__meta {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	color: var(--km-neutral-500);
	font-size: 0.82rem;
}

.km-message-bubble p {
	margin: 0;
	color: var(--km-neutral-900);
	line-height: 1.6;
}

.km-message-attachments {
	display: grid;
	gap: 0.45rem;
	margin-top: 0.25rem;
}

.km-message-attachment {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr);
	gap: 0.55rem;
	align-items: center;
	max-width: 100%;
	padding: 0.45rem;
	border: 1px solid rgba(100, 116, 139, 0.18);
	border-radius: var(--km-radius);
	background: rgba(255, 255, 255, 0.72);
	color: var(--km-neutral-900);
	text-decoration: none;
}

.km-message-attachment img {
	display: block;
	width: 3.4rem;
	height: 3.4rem;
	border-radius: var(--km-radius-sm);
	object-fit: cover;
}

.km-message-attachment > i {
	display: grid;
	width: 2.4rem;
	height: 2.4rem;
	place-items: center;
	border-radius: var(--km-radius-sm);
	background: var(--km-neutral-50);
	color: var(--km-primary);
	font-size: 1.35rem;
}

.km-message-attachment span {
	display: grid;
	min-width: 0;
	gap: 0.1rem;
}

.km-message-attachment strong,
.km-message-attachment em {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.km-message-attachment em {
	color: var(--km-neutral-500);
	font-size: 0.78rem;
	font-style: normal;
}

.km-message-attachment-picker {
	display: grid;
	gap: 0.5rem;
}

.km-message-attachment-picker input[type="file"] {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
	pointer-events: none;
}

.km-message-attach-button {
	display: inline-flex;
	width: fit-content;
	align-items: center;
	gap: 0.4rem;
	min-height: 2.35rem;
	padding: 0.4rem 0.7rem;
	border: 1px solid var(--km-neutral-100);
	border-radius: var(--km-radius-pill);
	background: var(--km-neutral-50);
	color: var(--km-neutral-900);
	font-size: 0.86rem;
	font-weight: 800;
	cursor: pointer;
	transition: border-color 140ms ease, color 140ms ease;
}

.km-message-attach-button:focus-within,
.km-message-attach-button:hover {
	border-color: rgba(241, 87, 34, 0.35);
	color: var(--km-primary);
}

.km-message-attachment-preview {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
}

.km-message-attachment-chip {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	max-width: 100%;
	padding: 0.35rem 0.45rem;
	border: 1px solid var(--km-neutral-100);
	border-radius: var(--km-radius-pill);
	background: var(--km-neutral-0);
	color: var(--km-neutral-900);
	font-size: 0.82rem;
}

.km-message-attachment-chip strong {
	max-width: 11rem;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.km-message-attachment-chip button {
	display: inline-grid;
	width: 1.35rem;
	height: 1.35rem;
	place-items: center;
	border: 0;
	border-radius: 50%;
	background: rgba(220, 38, 38, 0.1);
	color: var(--km-danger);
	cursor: pointer;
}

.km-message-reply-form {
	display: grid;
	gap: 0.8rem;
	padding: 1rem;
	border-top: 1px solid var(--km-neutral-100);
	background: var(--km-neutral-0);
}

.km-message-reply-form label {
	display: grid;
	gap: 0.45rem;
	margin: 0;
}

.km-message-reply-form textarea {
	min-height: 6rem;
}

.km-chatbox {
	position: fixed;
	right: 1rem;
	bottom: 1rem;
	z-index: 9999;
	width: min(23rem, calc(100vw - 2rem));
	pointer-events: none;
}

.km-chatbox__bubble,
.km-chatbox__panel {
	pointer-events: auto;
}

.km-chatbox__bubble {
	display: none;
	align-items: center;
	gap: 0.5rem;
	min-height: 3rem;
	padding: 0.75rem 1rem;
	border: 0;
	border-radius: var(--km-radius-pill);
	background: var(--km-primary);
	color: var(--km-neutral-0);
	box-shadow: 0 18px 45px rgba(15, 23, 42, 0.25);
	font-weight: 800;
	cursor: pointer;
	transition: background 140ms ease, box-shadow 140ms ease;
}

.km-chatbox__bubble:hover {
	background: var(--km-primary-hover);
	box-shadow: 0 22px 50px rgba(15, 23, 42, 0.32);
}

.km-chatbox__bubble:focus-visible,
.km-chatbox__header button:focus-visible,
.km-chatbox__form textarea:focus-visible {
	outline: 2px solid var(--km-primary);
	outline-offset: 3px;
}

.km-chatbox__badge {
	display: inline-grid;
	place-items: center;
	min-width: 1.35rem;
	height: 1.35rem;
	padding: 0 0.35rem;
	border-radius: var(--km-radius-pill);
	background: var(--km-neutral-0);
	color: var(--km-primary);
	font-size: 0.75rem;
}

.km-chatbox__panel {
	display: grid;
	grid-template-rows: auto minmax(14rem, 1fr) auto;
	height: min(34rem, calc(100vh - 6rem));
	margin-top: 0.75rem;
	border: 1px solid var(--km-neutral-100);
	border-radius: var(--km-radius-xl);
	background: var(--km-neutral-0);
	box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
	overflow: hidden;
}

.km-chatbox[data-state="open"] .km-chatbox__bubble {
	display: none;
}

.km-chatbox__header {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr) auto;
	align-items: center;
	gap: 0.75rem;
	padding: 0.85rem;
	border-bottom: 1px solid var(--km-neutral-100);
	background: var(--km-neutral-50);
}

.km-chatbox__header strong,
.km-chatbox__header small {
	display: block;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.km-chatbox__header small {
	color: var(--km-neutral-500);
	font-size: 0.78rem;
}

.km-chatbox__header button {
	display: inline-grid;
	place-items: center;
	width: 2.25rem;
	height: 2.25rem;
	border: 1px solid var(--km-neutral-100);
	border-radius: var(--km-radius-pill);
	background: var(--km-neutral-0);
	color: var(--km-neutral-900);
	cursor: pointer;
}

.km-chatbox__avatar {
	display: inline-grid;
	place-items: center;
	width: 2.4rem;
	height: 2.4rem;
	border-radius: var(--km-radius-pill);
	background: var(--km-primary);
	background-position: center;
	background-size: cover;
	color: var(--km-neutral-0);
	font-weight: 800;
}

.km-chatbox__avatar.has-image {
	color: transparent;
}

.km-chatbox__messages {
	display: grid;
	align-content: start;
	gap: 0.7rem;
	padding: 0.85rem;
	overflow: auto;
	background: var(--km-neutral-50);
}

.km-chatbox__empty {
	padding: 1.25rem 1rem;
	border: 1px dashed rgba(241, 87, 34, 0.2);
	border-radius: var(--km-radius-xl);
	background: rgba(241, 87, 34, 0.04);
	color: var(--km-neutral-500);
	font-size: 0.9rem;
	line-height: 1.5;
	text-align: center;
}

.km-chatbox__form {
	display: grid;
	gap: 0.65rem;
	padding: 0.85rem;
	border-top: 1px solid var(--km-neutral-100);
	background: var(--km-neutral-0);
}

.km-chatbox__form textarea {
	min-height: 4.25rem;
	max-height: 8rem;
	resize: vertical;
}

.km-chatbox__actions {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
}

.km-chatbox__actions .km-action-notice {
	flex: 1;
	min-width: 0;
	font-size: 0.82rem;
}

.km-chatbox__actions .km-button {
	min-height: 2.35rem;
	padding: 0.5rem 0.9rem;
}

.km-message-thread__back {
	display: none;
	align-items: center;
	justify-content: center;
	width: 2.25rem;
	height: 2.25rem;
	flex-shrink: 0;
	border: 0;
	border-radius: 50%;
	background: var(--km-neutral-100);
	color: var(--km-neutral-700);
	font-size: 1.1rem;
	cursor: pointer;
	transition: background var(--km-transition);
}

.km-message-thread__back:hover {
	background: var(--km-neutral-200);
}

@media (max-width: 55.999rem) {
	.km-message-thread {
		position: fixed;
		inset: 0;
		z-index: 400;
		display: flex;
		flex-direction: column;
		border: 0;
		border-radius: 0;
		box-shadow: none;
		transform: translateY(100%);
		transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
		/* ensure it's above bottom nav */
		padding-bottom: env(safe-area-inset-bottom, 0px);
	}

	.km-message-thread.is-open {
		transform: translateY(0);
	}

	.km-message-thread__header {
		display: flex;
		align-items: center;
		gap: 0.75rem;
		flex-shrink: 0;
	}

	.km-message-thread__back {
		display: flex;
	}

	.km-message-thread__body {
		flex: 1;
		max-height: none;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
	}

	.km-message-reply-form {
		flex-shrink: 0;
		border-top: 1px solid var(--km-neutral-100);
		padding: 0.75rem 1rem;
		background: var(--km-neutral-0);
	}
}

@media (min-width: 56rem) {
	.km-messages-shell {
		grid-template-columns: minmax(16rem, 0.85fr) minmax(0, 1.6fr);
		align-items: stretch;
	}
}

@media (max-width: 42rem) {
	.km-chatbox {
		right: 0.75rem;
		left: 0.75rem;
		bottom: 0.75rem;
		width: auto;
	}

	.km-chatbox__panel {
		height: min(38rem, calc(100vh - 2rem));
	}
}
