.ragcb-widget {
	--ragcb-theme-color: #2271b1;
	position: fixed;
	bottom: 20px;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.ragcb-widget.ragcb-position-right {
	right: 20px;
}

.ragcb-widget.ragcb-position-left {
	left: 20px;
}

.ragcb-toggle-button {
	width: 56px;
	height: 56px;
	border-radius: 50%;
	border: none;
	background: var( --ragcb-theme-color );
	color: #fff;
	font-size: 24px;
	cursor: pointer;
	box-shadow: 0 4px 12px rgba( 0, 0, 0, 0.2 );
	display: flex;
	align-items: center;
	justify-content: center;
}

.ragcb-toggle-button:hover {
	filter: brightness( 0.95 );
}

.ragcb-chat-window {
	position: absolute;
	bottom: 70px;
	width: 340px;
	max-width: calc( 100vw - 40px );
	height: 460px;
	max-height: calc( 100vh - 120px );
	background: #fff;
	border-radius: 12px;
	box-shadow: 0 8px 30px rgba( 0, 0, 0, 0.2 );
	display: none;
	flex-direction: column;
	overflow: hidden;
}

/* display:flexをここで指定することで、[hidden]属性より自作CSSが優先されて
   常時表示になってしまう問題を防ぐ（[hidden]を持たない=表示中のときだけflex化する） */
.ragcb-chat-window:not( [hidden] ) {
	display: flex;
}

.ragcb-position-right .ragcb-chat-window {
	right: 0;
}

.ragcb-position-left .ragcb-chat-window {
	left: 0;
}

.ragcb-chat-header {
	background: var( --ragcb-theme-color );
	color: #fff;
	padding: 12px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-weight: 600;
}

.ragcb-close-button {
	background: none;
	border: none;
	color: #fff;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	padding: 0;
}

.ragcb-messages {
	flex: 1;
	overflow-y: auto;
	padding: 12px;
	font-size: 14px;
}

.ragcb-message {
	margin-bottom: 10px;
	max-width: 85%;
}

.ragcb-message p {
	margin: 0;
	padding: 8px 12px;
	border-radius: 10px;
	line-height: 1.5;
	word-wrap: break-word;
}

.ragcb-message-user {
	margin-left: auto;
}

.ragcb-message-user p {
	background: var( --ragcb-theme-color );
	color: #fff;
}

.ragcb-message-bot p {
	background: #f0f0f1;
	color: #1d2327;
}

.ragcb-sources {
	margin-top: 4px;
	font-size: 12px;
}

.ragcb-sources ul {
	margin: 4px 0 0 16px;
	padding: 0;
}

.ragcb-input-form {
	display: flex;
	border-top: 1px solid #e0e0e0;
	padding: 8px;
	gap: 8px;
}

.ragcb-input {
	flex: 1;
	border: 1px solid #ccd0d4;
	border-radius: 6px;
	padding: 8px 10px;
	font-size: 14px;
}

.ragcb-send-button {
	background: var( --ragcb-theme-color );
	color: #fff;
	border: none;
	border-radius: 6px;
	padding: 0 16px;
	cursor: pointer;
	font-size: 14px;
}

.ragcb-send-button:hover {
	filter: brightness( 0.95 );
}

@media ( max-width: 480px ) {
	.ragcb-chat-window {
		width: calc( 100vw - 24px );
	}
}
