:root {
	/* 底部输入区高度（可以调整） */
	--input-height: 72px;
}

* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

/* 保证高度计算稳定 */
html,
body {
	height: 100%;
}

body {
	font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
	/* 移除页面背景色 / 渐变，保持透明或默认背景 */
	background: transparent;
	min-height: 100vh;
	display: flex;
	justify-content: center;
	/* 使容器垂直拉伸到视窗高度以便底部固定生效 */
	align-items: stretch;
	padding: 20px;
	/* ---- 我保留了这个（上下各 20px），容器高度会做相应补偿 ---- */
}

/* 主容器占满视窗高度，但扣除 body 上下 padding（40px），避免超出视窗 */
.container {
	width: 100%;
	background: white;
	border-radius: 20px;
	overflow: hidden;
	/* 关键修复：从 100vh 改为 扣除 body 上下 padding 的值 */
	height: calc(100vh - 40px);
	max-height: calc(100vh - 40px);
	display: flex;
	flex-direction: column;
	position: relative;
	/* 使内部绝对定位以 bottom:0 生效 */
}

/* header 保留原样（若无 header 可以删除该样式块） */
header {
	color: white;
	padding: 20px 30px;
	display: flex;
	justify-content: space-between;
	align-items: center;
}

header h1 {
	font-size: 24px;
	font-weight: 600;
}

.header-actions {
	display: flex;
	gap: 10px;
}

.btn-secondary {
	padding: 8px 20px;
	background: rgba(255, 255, 255, 0.2);
	color: white;
	border: 1px solid rgba(255, 255, 255, 0.3);
	border-radius: 8px;
	cursor: pointer;
	transition: all 0.3s;
	font-size: 14px;
}

.btn-secondary:hover {
	background: rgba(255, 255, 255, 0.3);
}

main {
	flex: 1;
	display: flex;
	overflow: hidden;
}

/* 聊天主体区域 */
.chat-container {
	flex: 1;
	display: flex;
	flex-direction: column;
	/* 让 chat-input-container 在此容器内进行绝对定位 */
	position: relative;
}

/* 消息列表：底部增加 padding 避免被固定的输入区遮挡（使用变量） */
.chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 20px;
	padding-bottom: calc(var(--input-height) + 24px);
	display: flex;
	flex-direction: column;
	gap: 15px;
}

/* 消息样式保留原有 */
.message {
	display: flex;
	gap: 12px;
	animation: fadeIn 0.3s;
}

@keyframes fadeIn {
	from {
		opacity: 0;
		transform: translateY(10px);
	}

	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.message-avatar {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 20px;
	flex-shrink: 0;
}

.user-message .message-avatar {
	background: #667eea;
}

.bot-message .message-avatar {
	background: #764ba2;
}

.message-content {
	flex: 1;
	padding: 12px 16px;
	border-radius: 12px;
	background: white;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.user-message .message-content {
	background: #667eea;
	color: white;
	margin-left: auto;
	max-width: 90%;
}

.bot-message .message-content {
	background: white;
	max-width: 90%;
}

.message-content ul {
	margin-left: 20px;
	margin-top: 10px;
}

.message-content li {
	margin: 5px 0;
}

/* ===== 底部输入区：固定在父容器底部 =====
   使用绝对定位，使其始终贴靠容器底部（容器已设为 position:relative）。
   宽度会随容器宽度变化，因此响应窗口大小。 */
.chat-input-container {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	height: var(--input-height);
	padding: 12px 20px;
	background: white;
	border-top: 1px solid #e0e0e0;
	display: flex;
	align-items: center;
}

/* 输入组：输入框自适应，按钮随内容伸缩 */
.input-group {
	display: flex;
	gap: 10px;
	width: 100%;
}

#userInput {
	flex: 1;
	padding: 12px 16px;
	border: 2px solid #e0e0e0;
	border-radius: 10px;
	font-size: 15px;
	transition: border-color 0.3s;
	min-width: 0;
	/* 防止在 flex 中溢出 */
}

#userInput:focus {
	outline: none;
	border-color: #667eea;
}

.btn-primary {
	padding: 12px 30px;
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	color: white;
	border: none;
	border-radius: 10px;
	cursor: pointer;
	font-size: 15px;
	font-weight: 600;
	transition: transform 0.2s;
	white-space: nowrap;
}

.btn-primary:hover {
	transform: scale(1.05);
}

.btn-primary:active {
	transform: scale(0.95);
}

/* 侧边栏（如有）保持在右侧 */
.sidebar {
	width: 300px;
	background: white;
	border-left: 1px solid #e0e0e0;
	padding: 20px;
	overflow-y: auto;
}

.info-panel,
.tips-panel {
	background: #f8f9fa;
	border-radius: 10px;
	padding: 15px;
	margin-bottom: 20px;
}

.info-panel h3,
.tips-panel h3 {
	color: #333;
	margin-bottom: 12px;
	font-size: 16px;
}

.tips-panel ul {
	list-style: none;
}

.tips-panel li {
	padding: 8px 0;
	color: #666;
	font-size: 14px;
	display: flex;
	align-items: start;
	gap: 8px;
}

#systemInfo {
	font-size: 14px;
	color: #666;
}

#systemInfo p {
	margin: 5px 0;
}

.loading {
	display: inline-block;
	width: 20px;
	height: 20px;
	border: 3px solid #f3f3f3;
	border-top: 3px solid #667eea;
	border-radius: 50%;
	animation: spin 1s linear infinite;
}

@keyframes spin {
	0% {
		transform: rotate(0deg);
	}

	100% {
		transform: rotate(360deg);
	}
}

/* 响应式设计：手机上去掉圆角并占满视窗
   这里同样扣除了 body 的上下 padding（40px）以避免溢出 */
@media (max-width: 768px) {
	.container {
		width: 100%;
		height: calc(100vh - 40px);
		border-radius: 0;
	}

	.sidebar {
		display: none;
	}

	header h1 {
		font-size: 18px;
	}

	.header-actions {
		flex-direction: column;
		gap: 5px;
	}

	.btn-secondary {
		padding: 6px 12px;
		font-size: 12px;
	}

	/* 手机上减小输入区高度 */
	:root {
		--input-height: 64px;
	}

	.chat-input-container {
		padding: 10px 12px;
	}
}

/* 滚动条样式 */
.chat-messages::-webkit-scrollbar {
	width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
	background: #f1f1f1;
}

.chat-messages::-webkit-scrollbar-thumb {
	background: #888;
	border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
	background: #555;
}