* {
	box-sizing: border-box;
}

html,
body {
	height: 100%;
	margin: 0;
}

body {
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	background: linear-gradient(135deg, #4f46e5, #2563eb);
	display: grid;
	place-items: center;
	padding: 1rem;
	color: #1e293b;
}

.app {
	width: 100%;
	max-width: 640px;
	height: min(90vh, 760px);
	background: #fff;
	border-radius: 20px;
	box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.topbar {
	padding: 0.9rem 1rem;
	border-bottom: 1px solid #e2e8f0;
	display: flex;
	align-items: center;
	gap: 0.75rem;
	flex-wrap: wrap;
}

.title {
	font-weight: 700;
	font-size: 1.1rem;
	flex: 1;
}

.controls {
	display: flex;
	gap: 0.4rem;
	align-items: center;
}

select {
	padding: 0.5rem;
	border: 2px solid #e2e8f0;
	border-radius: 10px;
	font-size: 0.85rem;
	font-family: inherit;
	max-width: 180px;
}

.topbar button {
	padding: 0.5rem 0.8rem;
	border: none;
	border-radius: 10px;
	background: #4f46e5;
	color: #fff;
	font-weight: 600;
	cursor: pointer;
	font-size: 0.85rem;
}

.topbar button:hover:not(:disabled) {
	background: #4338ca;
}

.topbar button:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

#clear {
	background: #f1f5f9;
	color: #475569;
}

#clear:hover:not(:disabled) {
	background: #e2e8f0;
}

.chat {
	flex: 1;
	overflow-y: auto;
	padding: 1rem;
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	background: #f8fafc;
}

.msg {
	display: flex;
}

.msg.user {
	justify-content: flex-end;
}

.bubble {
	max-width: 80%;
	padding: 0.7rem 0.95rem;
	border-radius: 16px;
	line-height: 1.45;
	font-size: 0.95rem;
	white-space: pre-wrap;
	word-wrap: break-word;
}

.msg.bot .bubble {
	background: #fff;
	border: 1px solid #e2e8f0;
	border-bottom-left-radius: 4px;
}

.msg.user .bubble {
	background: #4f46e5;
	color: #fff;
	border-bottom-right-radius: 4px;
}

.bubble.typing::after {
	content: "▍";
	animation: blink 1s steps(2) infinite;
}

@keyframes blink {
	50% {
		opacity: 0;
	}
}

.status {
	padding: 0.5rem 1rem;
	font-size: 0.8rem;
	color: #64748b;
	background: #fff;
	border-top: 1px solid #e2e8f0;
	text-align: center;
	min-height: 2em;
}

.composer {
	display: flex;
	gap: 0.5rem;
	padding: 0.8rem;
	border-top: 1px solid #e2e8f0;
	background: #fff;
}

.composer input {
	flex: 1;
	padding: 0.75rem 0.9rem;
	border: 2px solid #e2e8f0;
	border-radius: 12px;
	font-size: 1rem;
	font-family: inherit;
}

.composer input:focus {
	outline: none;
	border-color: #4f46e5;
}

.composer button {
	padding: 0 1.2rem;
	border: none;
	border-radius: 12px;
	background: #4f46e5;
	color: #fff;
	font-weight: 600;
	cursor: pointer;
	font-size: 1rem;
}

.composer button:hover:not(:disabled) {
	background: #4338ca;
}

.composer button:disabled,
.composer input:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}
