/* AGI Chatbot — 色はここ(CSS変数)を変えるだけでサイトに合わせられます */
.agi-chatbot {
	--agi-accent: #1f5c7a;        /* 見出し帯・送信ボタン */
	--agi-accent-ink: #ffffff;
	--agi-bg: #f6f8f9;            /* 会話欄の背景 */
	--agi-surface: #ffffff;
	--agi-ink: #1d2b33;
	--agi-muted: #5b6b74;
	--agi-line: #d7dfe3;
	--agi-user: #e3eef3;          /* 利用者の吹き出し */
	box-sizing: border-box;
	max-width: 760px;
	margin: 1.5em auto;
	border: 1px solid var(--agi-line);
	border-radius: 10px;
	background: var(--agi-surface);
	color: var(--agi-ink);
	font-size: 16px;
	line-height: 1.7;
	overflow: hidden;
}
.agi-chatbot *, .agi-chatbot *::before, .agi-chatbot *::after { box-sizing: border-box; }
.agi-chatbot__head { background: var(--agi-accent); color: var(--agi-accent-ink); padding: 14px 18px; display: flex; align-items: center; gap: 14px; }
.agi-chatbot__logo { flex: 0 0 auto; width: 52px; height: 52px; border-radius: 10px; background: #fff; display: flex; align-items: center; justify-content: center; }
.agi-chatbot__logo img { display: block; width: 44px; height: 44px; object-fit: contain; border-radius: 6px; }
.agi-chatbot__headtext { min-width: 0; }
.agi-chatbot__title { margin: 0; font-size: 1.1em; font-weight: 700; color: inherit; line-height: 1.4; }
.agi-chatbot__intro { margin: 4px 0 0; font-size: .875em; opacity: .92; color: inherit; }
.agi-chatbot__log { background: var(--agi-bg); padding: 16px; overflow-y: auto; max-height: 70vh; overscroll-behavior: contain; }
.agi-chatbot__msg { display: flex; flex-direction: column; align-items: flex-start; margin: 0 0 12px; }
.agi-chatbot__msg--user { align-items: flex-end; }
.agi-chatbot__bubble {
	max-width: 88%;
	padding: 10px 14px;
	border-radius: 12px;
	background: var(--agi-surface);
	border: 1px solid var(--agi-line);
	white-space: pre-wrap;
	overflow-wrap: anywhere;
	word-break: break-word;
}
.agi-chatbot__bubble--rich { white-space: normal; max-width: 94%; line-height: 1.8; }
.agi-chatbot__bubble--rich .agi-chatbot__p { margin: 0 0 .7em; white-space: pre-line; }
.agi-chatbot__bubble--rich .agi-chatbot__list { margin: 0 0 .8em; padding: 0 0 0 1.2em; list-style: disc; }
.agi-chatbot__bubble--rich .agi-chatbot__list li { margin: 0 0 .45em; padding: 0; }
.agi-chatbot__bubble--rich .agi-chatbot__list strong { font-weight: 700; }
.agi-chatbot__bubble--rich .agi-chatbot__cite { margin: .4em 0 .5em; padding-top: .5em; border-top: 1px solid var(--agi-line); font-size: .8125em; color: var(--agi-muted); }
.agi-chatbot__bubble--rich > :last-child { margin-bottom: 0; }
.agi-chatbot__msg--user .agi-chatbot__bubble { background: var(--agi-user); border-color: transparent; }
.agi-chatbot__msg--system .agi-chatbot__bubble { background: transparent; border-style: dashed; color: var(--agi-muted); font-size: .9em; max-width: 100%; }
.agi-chatbot__msg.is-waiting .agi-chatbot__bubble { color: var(--agi-muted); }
.agi-chatbot__bubble a, .agi-chatbot__sources a, .agi-chatbot__note a { color: var(--agi-accent); text-decoration: underline; }
.agi-chatbot__review { margin: 6px 0 0; font-size: .8125em; color: #8a5a00; }
.agi-chatbot__sources { margin: 6px 0 0; font-size: .8125em; color: var(--agi-muted); max-width: 88%; }
.agi-chatbot__sources summary { cursor: pointer; }
.agi-chatbot__sources ul { margin: 6px 0 0; padding-left: 1.2em; }
.agi-chatbot__sources li { margin: 2px 0; overflow-wrap: anywhere; }
.agi-chatbot__examples { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px 0; }
.agi-chatbot__examples[hidden] { display: none; }
.agi-chatbot__example {
	appearance: none; border: 1px solid var(--agi-line); background: var(--agi-surface); color: var(--agi-ink);
	border-radius: 999px; padding: 6px 12px; font-size: .8125em; line-height: 1.4; cursor: pointer; text-align: left;
}
.agi-chatbot__example:hover, .agi-chatbot__example:focus-visible { border-color: var(--agi-accent); color: var(--agi-accent); }
.agi-chatbot__form { display: flex; gap: 8px; padding: 12px 16px; align-items: flex-end; }
.agi-chatbot__input {
	flex: 1 1 auto; min-width: 0; resize: vertical; min-height: 48px; max-height: 160px;
	padding: 10px 12px; border: 1px solid var(--agi-line); border-radius: 8px;
	font: inherit; font-size: 16px; /* 16px未満だとiPhoneで画面が拡大されるため */
	color: var(--agi-ink); background: var(--agi-surface);
}
.agi-chatbot__input:focus-visible, .agi-chatbot__send:focus-visible, .agi-chatbot__example:focus-visible { outline: 2px solid var(--agi-accent); outline-offset: 2px; }
.agi-chatbot__send {
	flex: 0 0 auto; appearance: none; border: 0; border-radius: 8px; min-height: 48px; padding: 0 20px;
	background: var(--agi-accent); color: var(--agi-accent-ink); font: inherit; font-weight: 700; cursor: pointer;
}
.agi-chatbot__send:disabled, .agi-chatbot__input:disabled { opacity: .6; cursor: not-allowed; }
.agi-chatbot__note { margin: 0; padding: 0 16px 14px; font-size: .75em; color: var(--agi-muted); line-height: 1.6; }
.agi-chatbot .screen-reader-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.agi-chatbot-off { padding: 12px 16px; border: 1px dashed #d7dfe3; border-radius: 8px; }
@media (max-width: 480px) {
	.agi-chatbot { margin: 1em 0; border-radius: 8px; font-size: 15px; }
	.agi-chatbot__log { padding: 12px; height: 420px !important; max-height: 420px; }
	.agi-chatbot__bubble, .agi-chatbot__sources { max-width: 96%; }
	.agi-chatbot__form { padding: 10px 12px; }
	.agi-chatbot__send { padding: 0 14px; }
	.agi-chatbot__examples { padding: 10px 12px 0; }
	.agi-chatbot__note { padding: 0 12px 12px; }
}
@media (prefers-reduced-motion: no-preference) {
	.agi-chatbot__log { scroll-behavior: smooth; }
}

/* ---- 別ウィンドウで開くボタン ---- */
.agi-chatbot-launch-wrap { text-align: center; margin: 1.5em 0; }
.agi-chatbot-launch {
	display: inline-flex; align-items: center; gap: 14px; padding: 12px 22px 12px 12px;
	background: #1f5c7a; color: #fff !important; text-decoration: none !important;
	border-radius: 14px; font-weight: 700; font-size: 17px; line-height: 1.4;
	box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
}
.agi-chatbot-launch:hover, .agi-chatbot-launch:focus-visible { background: #17485f; }
.agi-chatbot-launch:focus-visible { outline: 2px solid #1f5c7a; outline-offset: 3px; }
.agi-chatbot-launch__logo { flex: 0 0 auto; width: 52px; height: 52px; border-radius: 10px; background: #fff; display: flex; align-items: center; justify-content: center; }
.agi-chatbot-launch__logo img { display: block; width: 44px; height: 44px; object-fit: contain; }
.agi-chatbot-launch__text { text-align: left; }

/* ---- 別ウィンドウの中のチャット(画面いっぱいに表示) ---- */
html:has(body.agi-chatbot-window), body.agi-chatbot-window { height: 100%; margin: 0; background: #f6f8f9; font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, sans-serif; }
body.agi-chatbot-window .agi-chatbot { max-width: none; margin: 0; border: 0; border-radius: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; contain: none; }
body.agi-chatbot-window .agi-chatbot__log { flex: 1 1 auto; height: auto !important; max-height: none; min-height: 0; }
body.agi-chatbot-window .agi-chatbot__head, body.agi-chatbot-window .agi-chatbot__examples, body.agi-chatbot-window .agi-chatbot__form, body.agi-chatbot-window .agi-chatbot__note { flex: 0 0 auto; }
body.agi-chatbot-window .agi-chatbot-off { margin: 24px; }
