/* ===========================================================
 * Floating Chat Widget
 * Used on /community/ (花知意) and /discovery/ (小语)
 * =========================================================== */

.fw-chat-root {
	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: 9999;
	font-family: Inter, system-ui, sans-serif;
}

@media (max-width: 500px) {
	.fw-chat-root {
		right: 16px;
		bottom: 16px;
	}
}

/* ── Launcher bubble ────────────────────────────────────── */
.fw-chat-launcher {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 14px 22px 14px 18px;
	border-radius: var(--radius-pill, 999px);
	border: 1px solid var(--text, #151515);
	background: var(--text, #151515);
	color: #fff;
	box-shadow: 0 18px 44px rgba(0, 0, 0, 0.22);
	cursor: pointer;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
	font-weight: 600;
	font-size: 0.95rem;
	letter-spacing: 0.02em;
}

.fw-chat-launcher:hover {
	transform: translateY(-2px);
	box-shadow: 0 22px 50px rgba(0, 0, 0, 0.28);
}

.fw-chat-launcher-icon {
	width: 28px;
	height: 28px;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.18);
	display: grid;
	place-items: center;
	font-size: 16px;
}

.fw-chat-launcher-subtitle {
	display: block;
	font-size: 0.72rem;
	font-weight: 400;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	opacity: 0.7;
}

.fw-chat-launcher-title {
	display: block;
	font-family: "Noto Serif", serif;
	font-weight: 600;
	line-height: 1.2;
}

.fw-chat-root.is-open .fw-chat-launcher {
	display: none;
}

/* ── Panel ──────────────────────────────────────────────── */
.fw-chat-panel {
	display: none;
	flex-direction: column;
	width: 380px;
	height: 560px;
	max-height: calc(100vh - 40px);
	background: var(--surface, #fffdf8);
	border-radius: 22px;
	border: 1px solid var(--line, rgba(21, 21, 21, 0.09));
	box-shadow: 0 28px 60px rgba(0, 0, 0, 0.22);
	overflow: hidden;
	animation: fwChatOpen 0.22s ease;
}

.fw-chat-root.is-open .fw-chat-panel {
	display: flex;
}

@keyframes fwChatOpen {
	from {
		opacity: 0;
		transform: translateY(12px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@media (max-width: 500px) {
	.fw-chat-panel {
		width: calc(100vw - 32px);
		height: calc(100vh - 80px);
	}
}

/* ── Header ─────────────────────────────────────────────── */
.fw-chat-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 18px 20px;
	background: var(--text, #151515);
	color: #fff;
}

.fw-chat-avatar {
	width: 40px;
	height: 40px;
	border-radius: 999px;
	display: grid;
	place-items: center;
	background: rgba(255, 255, 255, 0.18);
	font-family: "Noto Serif", serif;
	font-size: 1.15rem;
}

.fw-chat-heading {
	flex: 1;
	min-width: 0;
}

.fw-chat-heading .fw-chat-name {
	display: block;
	font-family: "Noto Serif", serif;
	font-size: 1.05rem;
	font-weight: 600;
}

.fw-chat-heading .fw-chat-tag {
	display: block;
	font-size: 0.75rem;
	letter-spacing: 0.15em;
	text-transform: uppercase;
	opacity: 0.75;
}

.fw-chat-close {
	width: 32px;
	height: 32px;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.12);
	border: 0;
	color: #fff;
	cursor: pointer;
	display: grid;
	place-items: center;
	transition: background 0.15s ease;
}

.fw-chat-close:hover {
	background: rgba(255, 255, 255, 0.22);
}

/* ── Messages ───────────────────────────────────────────── */
.fw-chat-body {
	flex: 1;
	overflow-y: auto;
	padding: 18px 18px 4px;
	background: var(--surface, #fffdf8);
	scroll-behavior: smooth;
}

.fw-chat-msg {
	margin-bottom: 14px;
	max-width: 82%;
	padding: 12px 14px;
	border-radius: 16px;
	font-size: 0.94rem;
	line-height: 1.56;
	white-space: pre-wrap;
	word-wrap: break-word;
}

.fw-chat-msg.is-bot {
	background: var(--surface-soft, #f4efe7);
	color: var(--text, #151515);
	border-top-left-radius: 6px;
	margin-right: auto;
}

.fw-chat-msg.is-user {
	background: var(--text, #151515);
	color: #fff;
	border-top-right-radius: 6px;
	margin-left: auto;
}

.fw-chat-msg.is-error {
	background: rgba(194, 87, 67, 0.12);
	color: #a63e26;
	font-style: italic;
}

.fw-chat-typing {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 12px 14px;
	border-radius: 16px;
	border-top-left-radius: 6px;
	background: var(--surface-soft, #f4efe7);
	margin-bottom: 14px;
	margin-right: auto;
	max-width: 82%;
}

.fw-chat-typing-dot {
	width: 6px;
	height: 6px;
	border-radius: 999px;
	background: var(--muted, #a38f7a);
	animation: fwTypingDot 1.2s infinite ease-in-out;
}

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

@keyframes fwTypingDot {
	0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); }
	40% { opacity: 1; transform: scale(1); }
}

/* ── Input ──────────────────────────────────────────────── */
.fw-chat-input-row {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 12px 14px 14px;
	border-top: 1px solid var(--line, rgba(21, 21, 21, 0.09));
	background: var(--surface, #fffdf8);
}

.fw-chat-input {
	flex: 1;
	min-height: 42px;
	max-height: 120px;
	padding: 10px 14px;
	border: 1px solid var(--line-strong, rgba(21, 21, 21, 0.16));
	border-radius: 20px;
	background: #fff;
	color: var(--text, #151515);
	font-family: inherit;
	font-size: 0.95rem;
	line-height: 1.4;
	resize: none;
	outline: none;
}

.fw-chat-input:focus {
	border-color: var(--text, #151515);
}

.fw-chat-send {
	width: 42px;
	height: 42px;
	border-radius: 999px;
	background: var(--text, #151515);
	color: #fff;
	border: 0;
	display: grid;
	place-items: center;
	cursor: pointer;
	flex-shrink: 0;
	transition: background 0.15s ease;
}

.fw-chat-send:hover { background: #000; }

.fw-chat-send:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

.fw-chat-disclaimer {
	padding: 0 18px 12px;
	background: var(--surface, #fffdf8);
	font-size: 0.72rem;
	color: var(--muted, #a38f7a);
	text-align: center;
	letter-spacing: 0.04em;
}
