/* 채팅 라이브 스타일 (YouTube Live Chat style) */
/* 일반 텍스트: 아이콘+이름+메시지+시간 한 줄 */
/* 이미지/GIF/뉴스/링크프리뷰: 기존 버블 스타일 유지 */

section#chat_section ul { padding: 0 16px 16px 16px; margin: 0; }
section#chat_section ul .wrapper { display: flex; flex-direction: column-reverse; }

/* 블록 이름 숨김 (라이브 모드에서는 인라인 이름 사용) */
section#chat_section ul .chat_name { display: none; }

/* === 인라인 이름 표시 === */
.chat_name_inline {
	display: inline;
	font-weight: 600;
	font-size: 13px;
	margin-right: 6px;
	flex-shrink: 0;
	white-space: nowrap;
}
.chat_name_inline a {
	color: var(--color-text-secondary);
	text-decoration: none;
	font-weight: 600;
}
.chat_name_inline img { image-rendering: pixelated; vertical-align: middle; margin-top: -2px; margin-right: 0; }
.chat_name_inline.news_name { font-weight: 600; color: var(--color-text-secondary); }

/* === li 기본 (인라인 플로우) === */
section#chat_section ul li {
	font-size: 15px;
	line-height: 1.5;
	display: block;
	padding: 3px 0;
	position: relative;
}

/* === 버블 평면화 (일반 텍스트) === */
section#chat_section ul li .bubble_wrap {
	display: contents;
}
section#chat_section ul li .chat_bubble {
	display: inline;
	background: none;
	border-radius: 0;
	overflow: visible;
}
section#chat_section ul li .chat_msg {
	color: var(--color-text);
	padding: 0;
	word-break: keep-all;
	overflow-wrap: anywhere;
	display: inline;
}
section#chat_section ul li .chat_msg a { color: var(--color-link); font-weight: 500; }
img.twemoji { height: 1.2em; width: 1.2em; vertical-align: -0.2em; display: inline; margin: 0 1px; }
section#chat_section ul li .chat_msg a.link_domain_inline {
	color: var(--color-link);
	font-weight: normal;
}

/* === 시간 === */
section#chat_section ul li .time {
	font-size: 10px;
	font-weight: 500;
	color: var(--color-text-muted);
	display: inline;
	margin-left: 4px;
}
section#chat_section ul li .time.deletable { cursor: pointer; }
section#chat_section ul li .time.deletable:hover { text-decoration: underline; }

/* === 이미지 메시지 — 버블 스타일 복원 === */
section#chat_section ul li.image_msg,
section#chat_section ul li.gif_msg {
	flex-direction: column;
	align-items: flex-start;
	gap: 4px;
}
section#chat_section ul li.image_msg .bubble_wrap,
section#chat_section ul li.gif_msg .bubble_wrap {
	display: flex;
	align-items: flex-end;
	gap: 6px;
	position: relative;
	cursor: pointer;
}
section#chat_section ul li.image_msg .chat_bubble,
section#chat_section ul li.gif_msg .chat_bubble {
	display: block;
	background: var(--color-bg-card);
	border-radius: 10px;
	overflow: hidden;
}
section#chat_section ul li .chat_bubble .chat_image {
	display: block;
	max-width: 300px;
	border-radius: 12px;
}
section#chat_section ul li .chat_bubble.has_image {
	background: var(--color-bg-card);
	padding: 0;
	margin-top: 5px;
}
section#chat_section ul li .chat_bubble.has_image .chat_image {
	border-radius: 18px 18px 0 0;
}
section#chat_section ul li .chat_bubble.has_image .chat_msg {
	padding: 8px 14px;
	display: block;
}

/* 이미지/GIF 시간 위치 복원 */
section#chat_section ul li.image_msg .time,
section#chat_section ul li.gif_msg .time {
	margin-left: 0;
	margin-bottom: 4px;
}

/* === 뉴스 메시지 — 일반 메시지와 동일 (인라인) === */
section#chat_section ul li.news_msg .news_bubble {
	display: inline;
	text-decoration: none;
	background: none;
	border: none;
	padding: 0;
	border-radius: 0;
	overflow: visible;
}
section#chat_section ul li.news_msg .chat_msg {
	display: inline;
	padding: 0;
}

/* === 리액션 피커 팝업 === */
.reaction_picker {
	position: absolute;
	top: calc(100% + 4px);
	left: 0;
	display: flex;
	gap: 4px;
	background: var(--color-bg-elevated);
	border: 1px solid var(--color-border-strong);
	border-radius: 20px;
	padding: 4px 6px;
	box-shadow: 0 2px 12px rgba(0,0,0,.15);
	z-index: 100;
	white-space: nowrap;
}
.reaction_picker span {
	cursor: pointer;
	padding: 0;
	border-radius: 8px;
	display: inline-block;
	width: 24px;
	height: 24px;
}
.reaction_picker span img {
	width: 24px;
	height: 24px;
	display: block;
}
.reaction_picker span:active {
	transform: scale(1.3);
}

/* === 리액션 표시 영역 === */
.chat_reactions {
	display: flex;
	flex-wrap: nowrap;
	gap: 3px;
	padding-left: 0;
	margin-top: 2px;
	position: relative;
	z-index: 1;
}
.chat_reactions .reaction_btn {
	display: inline-flex;
	align-items: center;
	gap: 2px;
	font-size: 11px;
	padding: 3px 5px 3px 4px;
	border-radius: 100px;
	background: var(--color-bg-elevated);
	border: none;
	cursor: pointer;
	color: var(--color-text-secondary);
	font-weight: 500;
}
.chat_reactions .reaction_btn img {
	width: 13px !important;
	height: 13px !important;
	vertical-align: middle;
}
.chat_reactions .reaction_btn.reacted {
	background: var(--color-bg-match);
}

/* === 링크 미리보기 — 버블 스타일 유지 === */
section#chat_section ul li .link_preview {
	display: block;
	text-decoration: none;
	background: var(--color-bg-card);
	border-radius: 10px;
	margin-top: 5px;
	overflow: hidden;
	width: 100%;
	max-width: 280px;
	clear: both;
}
section#chat_section ul li:has(.link_preview) {
	flex-direction: column;
	align-items: flex-start;
}
section#chat_section ul li .link_preview img {
	width: 100%;
	aspect-ratio: 1.91 / 1;
	object-fit: cover;
	object-position: top center;
	display: block;
}
section#chat_section ul li .link_preview .link_info {
	padding: 12px;
	display: flex;
	flex-direction: column;
	min-width: 0;
}
section#chat_section ul li .link_preview .link_domain {
	font-size: 10px;
	color: var(--color-text-muted);
	text-transform: uppercase;
	font-weight: 600;
}
section#chat_section ul li .link_preview .link_title {
	font-size: 14px;
	font-weight: 500;
	color: var(--color-text);
	line-height: 1.35;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	margin-top: 2px;
}
section#chat_section ul li .link_preview .link_desc {
	font-size: 13px;
	color: var(--color-text-secondary);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* === 더 보기 스피너 === */
section#chat_section .chat_spinner {
	text-align: center;
	padding: 16px 0;
}
section#chat_section .chat_spinner .spinner {
	width: 20px;
	height: 20px;
	border: 2px solid var(--color-border-strong);
	border-top-color: var(--color-text-muted);
	border-radius: 50%;
	margin: 0 auto;
	animation: spin 0.6s linear infinite;
}

/* === 새 메시지 등장 애니메이션 === */
@keyframes chatFadeIn {
	from { opacity: 0; transform: translateY(-10px); }
	to { opacity: 1; transform: translateY(0); }
}
section#chat_section ul li.chat_new {
	animation: chatFadeIn 0.3s ease-out;
}

/* === 채팅 GIF 이미지 === */
section#chat_section .chat_gif {
	display: block;
	max-width: 200px;
	border-radius: 18px;
}
