/* サイトの配色（濃い茶・金・生成り）に合わせたチャットウィジェット */
.hac-root {
	--hac-brown: #3b2a1d;
	--hac-gold: #a8822f;
	--hac-gold-dark: #8a6a24;
	--hac-cream: #f6f0e3;
	--hac-paper: #fffdf8;
	--hac-text: #2b2118;
	--hac-muted: #7a6a58;
	position: fixed;
	bottom: 96px; /* 右下の reCAPTCHA バッジと重ならない高さ */
	z-index: 99990;
	font-family: inherit;
	font-size: 15px;
	line-height: 1.6;
	color: var(--hac-text);
}
.hac-root.hac-pos-right { right: 20px; }
.hac-root.hac-pos-left { left: 20px; bottom: 20px; }
.hac-root *, .hac-root *::before, .hac-root *::after { box-sizing: border-box; }

.hac-launcher {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-left: auto;
	padding: 12px 18px 12px 14px;
	border: 2px solid var(--hac-gold);
	border-radius: 999px;
	background: var(--hac-brown);
	color: #f3e2b5;
	font: inherit;
	font-weight: 700;
	cursor: pointer;
	box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
	transition: transform .15s ease, background .15s ease;
}
.hac-pos-left .hac-launcher { margin-left: 0; }
.hac-launcher:hover { transform: translateY(-2px); background: #4a3626; }
.hac-launcher:focus-visible { outline: 3px solid var(--hac-gold); outline-offset: 3px; }
.hac-open .hac-launcher-label { display: none; }
.hac-open .hac-launcher { padding: 12px; }

.hac-panel {
	display: flex;
	flex-direction: column;
	width: 370px;
	height: min(560px, calc(100vh - 200px));
	margin-bottom: 12px;
	overflow: hidden;
	border: 1px solid #d9ccb2;
	border-radius: 14px;
	background: var(--hac-cream);
	box-shadow: 0 12px 36px rgba(0, 0, 0, .28);
}
.hac-panel[hidden] { display: none; }

.hac-header {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 12px 10px 12px 16px;
	background: var(--hac-brown);
	border-bottom: 3px solid var(--hac-gold);
	color: #f3e2b5;
}
.hac-title { flex: 1; font-weight: 700; letter-spacing: .03em; }
.hac-icon-btn {
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: 6px;
	background: transparent;
	color: inherit;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
}
.hac-icon-btn:hover { background: rgba(255, 255, 255, .12); }

.hac-log {
	flex: 1;
	overflow-y: auto;
	padding: 16px 14px;
	display: flex;
	flex-direction: column;
	gap: 10px;
}
.hac-msg {
	max-width: 88%;
	padding: 10px 13px;
	border-radius: 12px;
	word-break: break-word;
	white-space: normal;
}
.hac-assistant {
	align-self: flex-start;
	background: var(--hac-paper);
	border: 1px solid #e3d7bf;
	border-top-left-radius: 4px;
}
.hac-user {
	align-self: flex-end;
	background: var(--hac-gold);
	color: #fff;
	border-top-right-radius: 4px;
}
.hac-error {
	align-self: flex-start;
	background: #fbeaea;
	border: 1px solid #e7b9b9;
	color: #8a2a2a;
}
.hac-msg a { color: var(--hac-gold-dark); text-decoration: underline; font-weight: 600; }
.hac-user a { color: #fff; }

.hac-typing { display: flex; gap: 5px; padding: 14px 16px; }
.hac-typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--hac-gold);
	animation: hac-bounce 1.2s infinite ease-in-out;
}
.hac-typing span:nth-child(2) { animation-delay: .15s; }
.hac-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes hac-bounce {
	0%, 80%, 100% { opacity: .3; transform: translateY(0); }
	40% { opacity: 1; transform: translateY(-4px); }
}

.hac-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; }
.hac-chips[hidden] { display: none; }
.hac-chip {
	padding: 6px 11px;
	border: 1px solid var(--hac-gold);
	border-radius: 999px;
	background: var(--hac-paper);
	color: var(--hac-gold-dark);
	font: inherit;
	font-size: 13px;
	cursor: pointer;
}
.hac-chip:hover { background: #f1e5c8; }

.hac-form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid #e3d7bf;
	background: var(--hac-paper);
}
.hac-input {
	flex: 1;
	min-height: 40px;
	max-height: 120px;
	padding: 9px 11px;
	border: 1px solid #d3c4a6;
	border-radius: 10px;
	background: #fff;
	color: var(--hac-text);
	font: inherit;
	font-size: 16px; /* iOS でのズームを防ぐ */
	resize: none;
}
.hac-input:focus { outline: 2px solid var(--hac-gold); outline-offset: 0; border-color: var(--hac-gold); }
.hac-send {
	height: 40px;
	padding: 0 16px;
	border: 0;
	border-radius: 10px;
	background: var(--hac-brown);
	color: #f3e2b5;
	font: inherit;
	font-weight: 700;
	cursor: pointer;
}
.hac-send:disabled { opacity: .5; cursor: wait; }
.hac-note { padding: 0 12px 8px; background: var(--hac-paper); color: var(--hac-muted); font-size: 11px; text-align: center; }

@media (max-width: 600px) {
	.hac-root.hac-pos-right { right: 12px; bottom: 84px; }
	.hac-root.hac-pos-left { left: 12px; bottom: 16px; }
	.hac-open.hac-root { left: 8px; right: 8px; bottom: 8px; }
	.hac-open .hac-panel { width: 100%; height: calc(100vh - 90px); height: calc(100dvh - 90px); }
	.hac-launcher-label { display: none; }
	.hac-launcher { padding: 12px; }
}

@media (prefers-reduced-motion: reduce) {
	.hac-launcher, .hac-typing span { transition: none; animation: none; }
}

/* ---- キャラ画像 ---- */
.hac-launcher-avatar {
	width: 44px;
	height: 44px;
	margin: -4px 0 -4px -6px;
	border-radius: 50%;
	background: #fff;
	object-fit: cover;
}
.hac-open .hac-launcher-avatar { margin: -4px; }
.hac-header-avatar {
	width: 34px;
	height: 34px;
	margin-right: 8px;
	border: 2px solid var(--hac-gold);
	border-radius: 50%;
	background: #fff;
	object-fit: cover;
}
.hac-has-avatar .hac-assistant,
.hac-has-avatar .hac-error {
	position: relative;
	margin-left: 42px;
	max-width: calc(88% - 42px);
}
.hac-has-avatar .hac-assistant::before {
	content: "";
	position: absolute;
	left: -42px;
	top: 0;
	width: 34px;
	height: 34px;
	border: 1px solid #e3d7bf;
	border-radius: 50%;
	background: var(--hac-avatar) center / cover no-repeat, #fff;
}
@media (max-width: 600px) {
	.hac-has-avatar.hac-open .hac-launcher-avatar { margin: -4px; }
	.hac-has-avatar .hac-launcher-avatar { margin: -4px; }
}
