/* Sincerite AI Chat — テーマのスタイルと干渉しないよう .sac-root 配下に限定 */

.sac-root {
	--sac-accent: #8c7a5b;
	--sac-ink: #2f2a25;
	--sac-muted: #7a7168;
	--sac-line: #e7e1d8;
	--sac-bg: #ffffff;
	--sac-bot: #f6f3ee;
	--sac-radius: 14px;
	font-size: 15px;
	line-height: 1.7;
	color: var(--sac-ink);
	letter-spacing: 0.02em;
}

.sac-root *,
.sac-root *::before,
.sac-root *::after {
	box-sizing: border-box;
}

.sac-root button {
	font: inherit;
	margin: 0;
	text-transform: none;
	letter-spacing: inherit;
	box-shadow: none;
	cursor: pointer;
}

.sac-root [hidden] {
	display: none !important;
}

/* ---------- 起動ボタン（右下） ---------- */

.sac-root--floating {
	position: fixed;
	right: max(20px, env(safe-area-inset-right));
	bottom: max(20px, env(safe-area-inset-bottom));
	z-index: 99990;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 12px;
}

.sac-launcher {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 12px 20px 12px 16px;
	border: 0;
	border-radius: 999px;
	background: var(--sac-accent);
	color: #fff;
	box-shadow: 0 6px 20px rgba(47, 42, 37, 0.22);
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.sac-launcher:hover {
	transform: translateY(-1px);
	box-shadow: 0 8px 24px rgba(47, 42, 37, 0.28);
}

.sac-launcher:focus-visible,
.sac-root button:focus-visible,
.sac-input:focus-visible {
	outline: 2px solid var(--sac-accent);
	outline-offset: 2px;
}

.sac-launcher-label {
	font-size: 14px;
	line-height: 1;
	white-space: nowrap;
}

/* ---------- パネル ---------- */

.sac-panel {
	display: flex;
	flex-direction: column;
	background: var(--sac-bg);
	border: 1px solid var(--sac-line);
	border-radius: var(--sac-radius);
	overflow: hidden;
}

.sac-root--floating .sac-panel {
	width: 380px;
	height: min(620px, calc(100vh - 120px));
	box-shadow: 0 16px 48px rgba(47, 42, 37, 0.2);
}

.sac-root--inline .sac-panel {
	width: 100%;
	max-width: 720px;
	height: 600px;
	margin: 0 auto;
}

.sac-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 12px 12px 12px 18px;
	border-bottom: 1px solid var(--sac-line);
	background: var(--sac-bg);
}

.sac-title {
	font-size: 15px;
	font-weight: 600;
	color: var(--sac-ink);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.sac-header-actions {
	display: flex;
	align-items: center;
	gap: 4px;
	flex-shrink: 0;
}

.sac-text-btn,
.sac-icon-btn {
	border: 0;
	background: transparent;
	color: var(--sac-muted);
	border-radius: 8px;
	padding: 6px 8px;
	line-height: 1;
}

.sac-text-btn {
	font-size: 12px;
}

.sac-text-btn:hover,
.sac-icon-btn:hover {
	background: var(--sac-bot);
	color: var(--sac-ink);
}

.sac-icon-btn {
	display: inline-flex;
	padding: 6px;
}

.sac-preview {
	padding: 6px 18px;
	font-size: 12px;
	color: #8a5a00;
	background: #fff6e0;
	border-bottom: 1px solid #f1e2b8;
}

/* ---------- メッセージ ---------- */

.sac-log {
	flex: 1;
	overflow-y: auto;
	padding: 18px 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	overscroll-behavior: contain;
	background: var(--sac-bg);
}

.sac-msg {
	max-width: 88%;
	padding: 10px 14px;
	border-radius: 14px;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

.sac-msg--bot {
	align-self: flex-start;
	background: var(--sac-bot);
	border-top-left-radius: 4px;
}

.sac-msg--user {
	align-self: flex-end;
	background: var(--sac-accent);
	color: #fff;
	border-top-right-radius: 4px;
	white-space: pre-wrap;
}

.sac-msg--error {
	background: #fdf0ef;
	color: #8a2d24;
}

.sac-msg p {
	margin: 0;
	padding: 0;
	font-size: inherit;
	line-height: inherit;
	color: inherit;
}

.sac-msg p + p,
.sac-msg p + .sac-list,
.sac-msg .sac-list + p {
	margin-top: 0.6em;
}

.sac-msg .sac-list {
	margin: 0;
	padding: 0 0 0 1.3em;
	list-style-position: outside;
}

.sac-msg ul.sac-list {
	list-style-type: disc;
}

.sac-msg ol.sac-list {
	list-style-type: decimal;
}

.sac-msg .sac-list li {
	margin: 0.15em 0;
	padding: 0;
}

.sac-msg strong {
	font-weight: 600;
}

.sac-msg a.sac-link {
	color: var(--sac-accent);
	text-decoration: underline;
	text-underline-offset: 2px;
	word-break: break-all;
}

.sac-msg--error a.sac-link {
	color: inherit;
}

/* 入力中の表示 */
.sac-typing {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	color: var(--sac-muted);
	font-size: 13px;
}

.sac-dots {
	display: inline-flex;
	gap: 4px;
}

.sac-dots span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--sac-muted);
	opacity: 0.4;
	animation: sac-blink 1.2s infinite ease-in-out;
}

.sac-dots span:nth-child(2) {
	animation-delay: 0.2s;
}

.sac-dots span:nth-child(3) {
	animation-delay: 0.4s;
}

@keyframes sac-blink {
	0%, 80%, 100% { opacity: 0.25; }
	40% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
	.sac-dots span { animation: none; opacity: 0.6; }
	.sac-launcher { transition: none; }
}

/* ---------- 入力欄 ---------- */

.sac-form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	margin: 0;
	padding: 10px 12px;
	border-top: 1px solid var(--sac-line);
	background: var(--sac-bg);
}

.sac-input {
	flex: 1;
	min-height: 42px;
	max-height: 120px;
	margin: 0;
	padding: 10px 12px;
	border: 1px solid var(--sac-line);
	border-radius: 10px;
	background: #fff;
	color: var(--sac-ink);
	font: inherit;
	font-size: 16px; /* iOSでの自動ズーム防止 */
	line-height: 1.5;
	resize: none;
	box-shadow: none;
}

.sac-input:focus {
	border-color: var(--sac-accent);
	outline: none;
}

.sac-send {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	flex-shrink: 0;
	padding: 0;
	border: 0;
	border-radius: 10px;
	background: var(--sac-accent);
	color: #fff;
}

.sac-send:disabled {
	opacity: 0.45;
	cursor: default;
}

.sac-disclaimer {
	padding: 0 14px 10px;
	font-size: 11px;
	line-height: 1.5;
	color: var(--sac-muted);
	background: var(--sac-bg);
}

/* ---------- スマートフォン ---------- */

@media (max-width: 480px) {
	.sac-root--floating {
		right: max(12px, env(safe-area-inset-right));
		bottom: max(12px, env(safe-area-inset-bottom));
		left: auto;
	}

	.sac-root--floating.sac-open {
		left: 8px;
		right: 8px;
		bottom: 8px;
		top: 8px;
	}

	.sac-root--floating.sac-open .sac-launcher {
		display: none;
	}

	.sac-root--floating .sac-panel {
		width: 100%;
		height: 100%;
	}

	.sac-root--inline .sac-panel {
		height: 75vh;
	}

	.sac-msg {
		max-width: 92%;
	}
}
