dtx-chatbot {
	--width: 720px;

	header {
		position: static;
		padding: 16px;
		.close { margin-left: auto; }
	}

	/* chat container (has the skeleton) */
	chat {
		display: flex;
		flex-direction: column;
		gap: 24px;
		width: 100%;
		padding-inline: calc((100% - var(--width)) / 2);
		overflow: hidden auto;
		scrollbar-gutter: stable;

		&::-webkit-scrollbar { width: 8px; }
		&::-webkit-scrollbar-thumb {
			border: none;
			width: 8px;
			background: var(--border);
		}

		/* actual chat */
		#chat { display: contents; }

		.prompt {
			max-width: 80%;
			margin-left: auto;
			padding: 12px;
			border-radius: 12px;
			background: var(--accent-light);
			line-height: 1.5;
		}
		.response {
			span { line-height: 1.5; }

			.references {
				display: flex;
				flex-wrap: wrap;
				gap: 8px;
				margin-block: 12px 8px;

				li {
					display: flex;
					align-items: center;
					gap: 8px;
					padding: 4px 16px 4px 12px;
					border-radius: 24px;
					background: var(--border);

					span { font-size: 20px; }
				}
			}

			.actions {
				display: flex;
				gap: 8px;

				dtx-button {
					width: 44px;
					height: 44px;

					span { font-size: 18px; }
				}
			}
		}

		> * { flex-shrink: 0; }
	}

	skeleton {
		display: none;
		width: var(--width);
		height: 200px;
		margin-inline: auto;
	}
	&.skeleton skeleton {
		display: flex;
		opacity: .7;

		@starting-style {
			width: 0;
		}
	}

	footer {
		view-transition-name: chatbot-footer;

		display: flex;
		align-items: flex-end;
		width: var(--width);
		margin-top: auto;
		border: 1px solid var(--accent-light);
		border-radius: 12px;
		background: var(--border);
		transition: border-color .2s, opacity .3s;

		&:focus-within {
			border-color: var(--accent);
		}

		#prompt-field, #recognizer-text {
			flex-grow: 1;
			max-height: 250px;
			min-height: 53px;
			padding: 17px 16px;
			border: none;
			background: transparent;
			field-sizing: content;
			resize: none;
			line-height: 18px;
			outline: none;
		}

		#interim-span {
			margin-left: 1ch;
			font-style: italic;
			opacity: .5;
		}
	}

	/* STATES */
	&[state="input"] {
		header, chat, skeleton, #particles { display: none; }
	}

	&[state="full"] {
		position: fixed;
		inset: 0;
		display: flex;
		flex-direction: column;
		width: 100%;
		margin: 0;
		gap: 12px;
		border: 1px solid var(--border);
		background: var(--background-transparent);
		backdrop-filter: blur(20px);
		z-index: 1;

		footer {
			margin: auto auto 40px;
		}
	}

	&.recording #prompt-field,
	&:not(.recording) #recognizer-text { display: none; }

	&.recording #mic-button {
		color: var(--background);
		background: var(--border);
		animation: outline-ripple 1.5s infinite;
	}

	/* FILTER MENU */
	#info-sources-toggle {
		anchor-name: --info-sources-toggle;
	}
	#info-sources-menu {
		position-anchor: --info-sources-toggle;
		position-area: top;
		max-width: 500px;
		min-width: 400px;
		margin-bottom: 8px;
		border: 1px solid var(--accent-light);
		border-radius: 12px;
		background: var(--border);

		item {
			display: flex;
			flex-direction: column;
			min-width: 300px;
			border-bottom: 1px solid var(--accent-light);
		}

		div.space-between {
			justify-content: space-between;
			padding-right: 16px;
		}

		[icon="swap_vert"] { cursor: grab; }

		dtx-switch[type="switch"] {
			border: none;
			label { padding-left: 0; }
			input { border: 1px solid var(--background); }
		}
		dtx-switch[type="checkbox"] {
			padding-left: 16px;
			label { gap: 16px; }
		}

		dtx-chips-input {
			display: none;
			min-height: 0;
			height: 0;
			padding: 0 8px 0 48px;
			border: none;
			background: transparent;
			overflow: hidden;
			transition: .3s allow-discrete;
		}

		item:has(input:checked) dtx-chips-input {
			display: flex;
			height: auto;
			margin-top: -16px;
			padding-block: 8px;

			@starting-style {
				height: 0;
				margin-top: 0;
				padding-block: 0;
			}
		}

		&:has(item.dragging) item:not(.dragging) {
			outline: 2px dashed var(--accent-light);
			outline-offset: -4px;
		}
	}
}

@keyframes outline-ripple {
	0% {
		outline: 2px solid var(--accent-light);
		outline-offset: -2px;
	}
	80% {
		outline: 2px solid transparent;
		outline-offset: 24px;
	}
}
