#chatDemoOverlay {
	display: none;
	position: fixed;
	inset: 0;
	background: rgba(15, 20, 40, .5);
	z-index: 9000;
	align-items: center;
	justify-content: center;
	padding: 16px;
}

#chatDemoOverlay.open {
	display: flex;
}

.chat-demo-modal {
	background: #fff;
	border-radius: 18px;
	width: 720px;
	max-width: calc(100vw - 32px);
	height: 560px;
	max-height: calc(100vh - 32px);
	display: flex;
	box-shadow: 0 24px 72px rgba(0, 0, 0, .22);
	overflow: hidden;
}

.chat-sidebar {
	width: 240px;
	flex-shrink: 0;
	display: flex;
	flex-direction: column;
	border-right: 1px solid #edf0f5;
	background: #fafbfd;
	transition: width .22s ease, min-width .22s ease;
}

.chat-sidebar-head {
	padding: 18px 16px 12px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}

.chat-sidebar-title {
	font-size: 15px;
	font-weight: 700;
	color: #1a1d29;
}

.chat-sidebar-head-actions {
	display: flex;
	align-items: center;
	gap: 4px;
}

.chat-sidebar-new {
	width: 28px;
	height: 28px;
	border-radius: 8px;
	background: #eff3ff;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #3b5bdb;
}

.chat-sidebar-new:hover {
	background: #e0e7ff;
}

.chat-demo-modal--sidebar-collapsed .chat-sidebar {
	width: 56px;
	min-width: 56px;
}

.chat-demo-modal--sidebar-collapsed .chat-sidebar-title,
.chat-demo-modal--sidebar-collapsed .chat-sidebar-search,
.chat-demo-modal--sidebar-collapsed .chat-room-list {
	display: none;
}

.chat-demo-modal--sidebar-collapsed .chat-sidebar-head {
	padding: 14px 10px;
	justify-content: center;
}

.chat-demo-modal--sidebar-collapsed .chat-sidebar-head-actions {
	width: 100%;
	justify-content: center;
}

.chat-demo-modal--sidebar-collapsed .chat-sidebar-new {
	transform: rotate(180deg);
}

.chat-sidebar-search {
	padding: 0 12px 10px;
	flex-shrink: 0;
}

.chat-sidebar-search input {
	width: 100%;
	border: 1px solid #e8ebf2;
	border-radius: 10px;
	padding: 7px 12px;
	font-size: 12px;
	font-family: inherit;
	color: #444;
	background: #fff;
	outline: none;
	box-sizing: border-box;
}

.chat-sidebar-search input::placeholder {
	color: #b0b8c8;
}

.chat-room-list {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	overflow-x: hidden;
	-webkit-overflow-scrolling: touch;
	scrollbar-gutter: stable;
	scrollbar-width: thin;
	scrollbar-color: #b8c3ff #eef2ff;
}

.chat-room-list::-webkit-scrollbar {
	width: 6px;
}

.chat-room-list::-webkit-scrollbar-track {
	background: #eef2ff;
	border-radius: 999px;
}

.chat-room-list::-webkit-scrollbar-thumb {
	background: #b8c3ff;
	border-radius: 999px;
}

.chat-room-list::-webkit-scrollbar-thumb:hover {
	background: #99a9ff;
}

.chat-room-item {
	display: grid;
	grid-template-columns: 38px minmax(0, 1fr) auto;
	align-items: start;
	gap: 10px;
	width: 100%;
	padding: 10px 14px;
	min-height: 62px;
	cursor: pointer;
	border-radius: 0;
	border: 0;
	background: transparent;
	text-align: left;
	float: none;
	transition: background .15s;
	position: relative;
	box-sizing: border-box;
}

.chat-room-item:hover {
	background: #f0f3fa;
}

.chat-room-item.active {
	background: #eff3ff;
}

.chat-room-avatar {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: #e8ebf5;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 15px;
	font-weight: 700;
	color: #3b5bdb;
	flex-shrink: 0;
	font-style: normal;
}

.chat-room-item.active .chat-room-avatar {
	background: #dde4ff;
}

.chat-room-info {
	min-width: 0;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	justify-content: center;
	min-height: 42px;
}

.chat-room-name {
	display: block;
	max-width: 100%;
	font-size: 13px;
	font-weight: 600;
	color: #1a1d29;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.chat-room-preview {
	display: block;
	max-width: 100%;
	font-size: 11px;
	color: #9098b0;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	margin-top: 2px;
}

.chat-room-meta {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	justify-content: flex-start;
	gap: 4px;
	flex-shrink: 0;
	padding-top: 1px;
	min-width: fit-content;
}

.chat-room-time {
	font-size: 10px;
	color: #b0b8c8;
	white-space: nowrap;
	display: block;
	margin-bottom: 2px;
}

.chat-room-unread {
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: #3b5bdb;
	color: #fff;
	font-size: 10px;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: center;
}

.chat-main {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-width: 0;
	min-height: 0;
	overflow: hidden;
}

.chat-main-header {
	padding: 14px 18px;
	border-bottom: 1px solid #edf0f5;
	display: flex;
	align-items: center;
	gap: 10px;
	flex-shrink: 0;
	background: #fff;
}

.chat-main-avatar {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: #dde4ff;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 14px;
	font-weight: 700;
	color: #3b5bdb;
	flex-shrink: 0;
}

.chat-main-info {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 0;
}

.chat-main-name {
	font-size: 14px;
	font-weight: 700;
	color: #1a1d29;
	line-height: 1.2;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.chat-main-status {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-size: 11px;
	font-weight: 500;
	line-height: 1.1;
	margin-top: 4px;
	color: #94a3b8;
}

.chat-main-status__dot {
	width: 9px;
	height: 9px;
	border-radius: 50%;
	background: currentColor;
	flex-shrink: 0;
}

.chat-main-status[data-room-status="active"] {
	color: #52c57a;
}

.chat-main-status[data-room-status="pending"],
.chat-main-status[data-room-status="unknown"],
.chat-main-status[data-room-status="error"] {
	color: #d39b1a;
}

.chat-main-status[data-room-status="blocked"],
.chat-main-status[data-room-status="closed"],
.chat-main-status[data-room-status="offline"] {
	color: #e25b5b;
}

.chat-main-status[data-room-status="waiting"] {
	color: #94a3b8;
}

.chat-sidebar-close {
	display: none;
}

.chat-back-btn {
	display: none;
	width: 32px;
	height: 32px;
	border-radius: 8px;
	background: none;
	border: none;
	color: #3b5bdb;
	cursor: pointer;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	margin-right: 2px;
}

.chat-back-btn:hover {
	background: #f0f3fa;
}

.chat-demo-close {
	width: 32px;
	height: 32px;
	border-radius: 8px;
	background: none;
	border: none;
	color: #9098b0;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
}

.chat-demo-close:hover {
	background: #f0f3fa;
	color: #444;
}

.chat-demo-messages {
	flex: 1;
	overflow-y: auto;
	overflow-anchor: none;
	padding: 20px 18px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	background: #f6f8fc;
}

.chat-msg {
	display: flex;
	flex-direction: column;
	max-width: 72%;
	min-width: 0;
	gap: 4px;
}

.chat-msg--in {
	align-self: flex-start;
}

.chat-msg--out {
	align-self: flex-end;
	align-items: flex-end;
}

.chat-msg-sender {
	font-size: 11px;
	color: #9098b0;
	font-weight: 600;
	margin-left: 2px;
}

.chat-msg-bubble {
	padding: 9px 14px;
	border-radius: 14px;
	font-size: 13px;
	line-height: 1.6;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.chat-msg-text {
	white-space: pre-wrap;
	word-break: break-word;
	overflow-wrap: anywhere;
}

/* theme/layout.css 의 #wrap * { word-break:keep-all; } 전역 규칙 우선순위 대응 */
#chatDemoOverlay .chat-msg-bubble,
#chatDemoOverlay .chat-msg-text,
#chatDemoOverlay .chat-msg-bubble * ,
#chatDemoOverlay .chat-msg-text * {
	white-space: pre-wrap !important;
	word-break: break-all !important;
	overflow-wrap: anywhere !important;
}

.chat-msg--in .chat-msg-bubble {
	background: #fff;
	color: #222;
	border: 1px solid #eaedf3;
	border-top-left-radius: 4px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
}

.chat-msg--out .chat-msg-bubble {
	background: #3b5bdb;
	color: #fff;
	border-bottom-right-radius: 4px;
}

.chat-msg-time {
	font-size: 10px;
	color: #b8bfcc;
}

.chat-msg-attachments {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.chat-attachment {
	display: flex;
	align-items: center;
	gap: 8px;
	max-width: 100%;
	padding: 7px 10px;
	border-radius: 10px;
	text-decoration: none;
	font-size: 12px;
	line-height: 1.4;
}

.chat-msg--in .chat-attachment {
	background: #f5f7fb;
	color: #2f3b5c;
	border: 1px solid #e5e9f2;
}

.chat-msg--out .chat-attachment {
	background: rgba(255, 255, 255, .2);
	color: #fff;
	border: 1px solid rgba(255, 255, 255, .28);
}

.chat-attachment__label {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 24px;
	height: 20px;
	border-radius: 6px;
	font-size: 10px;
	font-weight: 700;
	letter-spacing: .02em;
}

.chat-msg--in .chat-attachment__label {
	background: #dde4ff;
	color: #3b5bdb;
}

.chat-msg--out .chat-attachment__label {
	background: rgba(255, 255, 255, .24);
	color: #fff;
}

.chat-attachment__name {
	display: block;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.chat-attachment--image {
	padding: 0;
	overflow: hidden;
	border: none;
	background: transparent;
}

.chat-attachment--image img {
	display: block;
	max-width: min(220px, 100%);
	max-height: 200px;
	border-radius: 10px;
	object-fit: cover;
}

.chat-demo-badge {
	display: inline-block;
	background: #f0f4ff;
	color: #4c6ef5;
	font-size: 11px;
	font-weight: 600;
	padding: 4px 12px;
	border-radius: 20px;
	margin: 4px auto;
	text-align: center;
	align-self: center;
	border: 1px solid #dde4ff;
}

.chat-demo-input-row {
	padding: 12px 16px;
	border-top: 1px solid #edf0f5;
	display: flex;
	gap: 8px;
	align-items: center;
	flex-shrink: 0;
	background: #fff;
}

.chat-demo-input {
	flex: 1;
	border: 1px solid #e8ebf2;
	border-radius: 24px;
	padding: 9px 16px;
	font-size: 13px;
	font-family: inherit;
	outline: none;
	color: #333;
	background: #f6f8fc;
	transition: border-color .15s, background .15s;
}

.chat-demo-input:focus {
	border-color: #3b5bdb;
	background: #fff;
}

.chat-demo-send {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: #3b5bdb;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: background .15s;
}

.chat-demo-send:hover {
	background: #2f4abf;
}

.chat-demo-send svg {
	stroke: #fff;
}

.chat-demo-file-input {
	display: none;
}

.chat-demo-attach {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	border: 1px solid #dce3ff;
	background: #eff3ff;
	color: #3b5bdb;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: background .15s, border-color .15s, color .15s;
}

.chat-demo-attach:hover {
	background: #e3eaff;
	border-color: #cad6ff;
}

.chat-demo-attach:disabled,
.chat-demo-send:disabled {
	opacity: .6;
	cursor: not-allowed;
}

.trade-chat-empty-state {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px 20px;
	font-size: 12px;
	line-height: 1.6;
	color: #9098b0;
	text-align: center;
}

.trade-chat-empty-state--list {
	min-height: 120px;
}

.trade-chat-empty-state--messages {
	flex: 1;
	min-height: 180px;
}

.chat-demo-toast {
	position: fixed;
	left: 50%;
	bottom: 24px;
	transform: translateX(-50%) translateY(12px);
	opacity: 0;
	z-index: 9200;
	max-width: min(92vw, 420px);
	padding: 10px 14px;
	border-radius: 12px;
	font-size: 12px;
	font-weight: 600;
	line-height: 1.45;
	color: #fff;
	background: rgba(15, 23, 42, .92);
	box-shadow: 0 10px 24px rgba(15, 23, 42, .28);
	transition: opacity .18s ease, transform .18s ease;
	pointer-events: none;
}

.chat-demo-toast.is-show {
	opacity: 1;
	transform: translateX(-50%) translateY(0);
}

.chat-demo-toast--error {
	background: rgba(185, 28, 28, .95);
}

.chat-demo-toast--success {
	background: rgba(22, 101, 52, .95);
}

.trade-chat-state-card {
	max-width: 420px;
	margin: auto;
	padding: 18px 20px;
	border-radius: 18px;
	border: 1px solid #e5e7eb;
	background: #fff;
	text-align: center;
	box-shadow: 0 6px 18px rgba(15, 23, 42, .05);
}

.trade-chat-state-card__title {
	display: block;
	font-size: 14px;
	font-weight: 700;
	color: #111827;
	margin-bottom: 8px;
}

.trade-chat-state-card__body {
	margin: 0;
	font-size: 12px;
	line-height: 1.7;
	color: #6b7280;
}

.trade-chat-state-card.is-pending {
	background: #fffaf5;
	border-color: #fed7aa;
}

.trade-chat-state-card.is-blocked {
	background: #fef2f2;
	border-color: #fecaca;
}

.trade-chat-state-card.is-closed,
.trade-chat-state-card.is-unknown {
	background: #f9fafb;
	border-color: #e5e7eb;
}

.login-guard-modal {
	position: fixed;
	inset: 0;
	z-index: 9100;
	display: none;
}

.login-guard-modal.is-open {
	display: block;
}

.login-guard {
	min-height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
}

.login-guard__overlay {
	position: fixed;
	inset: 0;
	background: rgba(15, 23, 42, .18);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
}

.login-guard__modal {
	--login-guard-card: #fff;
	--login-guard-text: #1f2937;
	--login-guard-muted: #6b7280;
	--login-guard-primary: #2563eb;
	--login-guard-primary-dark: #1d4ed8;
	--login-guard-shadow: 0 24px 60px rgba(15, 23, 42, .16);
	position: relative;
	max-width:380px;
	width:90%;
	background: var(--login-guard-card);
	border-radius: 20px;
	padding: 40px 36px 32px;
	box-shadow: var(--login-guard-shadow);
	text-align: center;
	animation: loginGuardFade .18s ease-out;
	color: var(--login-guard-text);
}

.login-guard__close {
	position: absolute;
	top: 12px;
	right: 12px;
	width: 28px;
	height: 28px;
	border: none;
	border-radius: 50%;
	background: transparent;
	color: #9ca3af;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
}

.login-guard__close svg {
	width: 16px;
	height: 16px;
	stroke: currentColor;
	fill: none;
	stroke-width: 2.2;
	stroke-linecap: round;
}

@keyframes loginGuardFade {
	from {
		opacity: 0;
		transform: translateY(10px) scale(.98);
	}
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

.login-guard__icon {
	width: 56px;
	height: 56px;
	margin: 0 auto 18px;
	border-radius: 999px;
	background: #2f5fe3;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
}

.login-guard__icon svg {
	width: 26px;
	height: 26px;
	fill: #fff;
}

.login-guard__title {
	margin: 0 0 10px;
	font-size: 18px;
	font-weight: 700;
	letter-spacing: -.02em;
}

.login-guard__desc {
	margin: 0 0 26px;
	font-size: 14px;
	line-height: 1.5;
	color: var(--login-guard-muted);
}

.login-guard__actions {
	display: flex;
	gap: 10px;
}

.login-guard__btn {
	flex: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 48px;
	border-radius: 14px;
	border: 1px solid transparent;
	font-size: 15px;
	font-weight: 600;
	text-decoration: none;
	cursor: pointer;
	transition: .18s ease;
}

.login-guard__btn--ghost {
	background: #f3f4f6;
	color: #4b5563;
	border-color: #e5e7eb;
}

.login-guard__btn--ghost:hover {
	background: #e5e7eb;
}

.login-guard__btn--primary {
	background: var(--login-guard-primary);
	color: #fff;
}

.login-guard__btn--primary:hover {
	background: var(--login-guard-primary-dark);
}

@media (max-width: 600px) {
	#chatDemoOverlay {
		padding: 0;
	}

	.chat-demo-modal {
		width: 100%;
		height: 100vh;
		height: 100dvh;
		border-radius: 0;
		max-width: 100%;
		max-height: 100vh;
		max-height: 100dvh;
	}

	.chat-sidebar {
		display: flex;
		width: 100%;
	}

	.chat-main {
		display: none;
	}

	.chat-demo-modal--mobile-chat .chat-sidebar {
		display: none;
	}

	.chat-demo-modal--mobile-chat .chat-main {
		display: flex;
	}

	.chat-back-btn {
		display: flex !important;
	}

	.chat-sidebar-close {
		display: flex !important;
	}
}

.chat-demo-modal--locked .chat-sidebar,
.chat-demo-modal--locked .chat-main {
	filter: blur(1px);
	pointer-events: none;
	user-select: none;
}

@media (max-width: 480px) {
	.login-guard {
		padding: 18px;
	}

	.login-guard__modal {
		border-radius: 20px;
		padding: 30px 20px 22px;
	}

	.login-guard__title {
		font-size: 19px;
	}

	.login-guard__desc {
		font-size: 14px;
	}

	.login-guard__actions {
		flex-direction: row;
	}
}
