/* --- 基础重置 --- */
* {
	box-sizing: border-box;
	-webkit-tap-highlight-color: transparent;
}

body {
	margin: 0;
	padding: 0;
	/* 将字体改为系统字体 */
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	/* 背景改为浅色 */
	background: #f5f5f7;
	color: #222;
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	overflow: hidden;
	display: -webkit-flex;
	display: flex;
	-webkit-flex-direction: column;
	flex-direction: column;
}

/* --- 1. 顶部输入区 --- */
.top-input-area {
	/* 背景改为白色 */
	background: #ffffff;
	padding: 10px;
	z-index: 100;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
	display: -webkit-flex;
	display: flex;
	-webkit-align-items: flex-start;
	align-items: flex-start;
	min-height: 60px;
	-webkit-flex-shrink: 0;
	flex-shrink: 0;
	position: relative;
	border-bottom: 1px solid #e0e0e0;
}

#user-input {
	-webkit-flex: 1;
	flex: 1;
	/* 输入框背景改为浅色 */
	background: #f9f9f9;
	/* 字体颜色改为黑色 */
	color: #000;
	border: 1px solid #ccc;
	border-radius: 4px;
	padding: 10px;
	font-family: inherit;
	font-size: 16px;
	resize: none;
	height: 50px;
	line-height: 1.3;
	outline: none;
	min-width: 0;
}

.icon-btn {
	/* 按钮背景改为白色 */
	background: #ffffff;
	color: #333;
	border: 1px solid #ccc;
	width: 50px;
	height: 50px;
	border-radius: 4px;
	cursor: pointer;
	display: -webkit-flex;
	display: flex;
	-webkit-align-items: center;
	align-items: center;
	-webkit-justify-content: center;
	justify-content: center;
	-webkit-flex-shrink: 0;
	flex-shrink: 0;
	position: relative;
}

.icon-btn:active {
	background: #f0f0f0;
}

#img-btn {
	margin-right: 10px;
}

#img-btn svg {
	/* 图标颜色改为深灰 */
	fill: #555;
	width: 24px;
	height: 24px;
}

#img-btn.has-file svg {
	fill: #007aff;
}

/* 图片数量角标 */
.img-badge {
	position: absolute;
	top: -5px;
	right: -5px;
	background: #ff3b30;
	color: white;
	border-radius: 50%;
	width: 20px;
	height: 20px;
	font-size: 11px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: bold;
	border: 1px solid #fff;
	display: none;
}

#send-btn {
	background: #007aff;
	color: white;
	border: none;
	margin-left: 10px;
	font-weight: bold;
	font-size: 20px;
}

#send-btn:active {
	background: #005bb5;
}

#send-btn:disabled {
	background: #ccc;
	color: #888;
}

/* 图片预览浮层 */
#img-preview-area {
	display: none;
	position: absolute;
	bottom: 65px;
	left: 10px;
	/* 背景改为白色 */
	background: #ffffff;
	border: 1px solid #ccc;
	padding: 5px;
	border-radius: 4px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	z-index: 101;
}

#preview-thumb {
	max-height: 80px;
	max-width: 120px;
	display: block;
}

#clear-img {
	position: absolute;
	top: -8px;
	right: -8px;
	background: #ff0000;
	color: #fff;
	border: 2px solid #fff;
	border-radius: 50%;
	width: 20px;
	height: 20px;
	font-size: 12px;
	line-height: 16px;
	text-align: center;
	cursor: pointer;
	font-weight: bold;
}

/* 图片操作菜单 */
#img-action-menu {
	display: none;
	position: absolute;
	top: 65px;
	left: 10px;
	background: #fff;
	border: 1px solid #ccc;
	box-shadow: 0 4px 12px rgba(0,0,0,0.15);
	z-index: 2000;
	width: 140px;
	border-radius: 4px;
}

.action-item {
	padding: 12px 15px;
	font-weight: bold;
	cursor: pointer;
	border-bottom: 1px solid #eee;
	font-size: 14px;
	color: #333;
}

.action-item:last-child {
	border-bottom: none;
}

.action-item:hover {
	background: #f5f5f7;
	color: #000;
}

/* 图片管理菜单 */
#img-manage-menu {
	display: none;
	position: absolute;
	top: 65px;
	left: 10px;
	background: #fff;
	border: 1px solid #ccc;
	box-shadow: 0 4px 12px rgba(0,0,0,0.15);
	z-index: 2001;
	width: 220px;
	max-height: 300px;
	overflow-y: auto;
	padding: 10px;
	border-radius: 4px;
}

.manage-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 8px;
}

.manage-item {
	position: relative;
	width: 100%;
	padding-top: 100%;
	background: #eee;
	border: 1px solid #ccc;
}

.manage-thumb {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.manage-del {
	position: absolute;
	top: -5px;
	right: -5px;
	width: 18px;
	height: 18px;
	background: red;
	color: white;
	border-radius: 50%;
	text-align: center;
	line-height: 16px;
	font-size: 12px;
	cursor: pointer;
	border: 1px solid #fff;
	font-weight: bold;
}

.manage-add-btn {
	grid-column: 1 / -1;
	margin-top: 10px;
	padding: 8px;
	background: #007aff;
	color: white;
	text-align: center;
	font-weight: bold;
	cursor: pointer;
	font-size: 12px;
	border: 1px solid #005bb5;
	border-radius: 4px;
}

/* --- 自定义全屏相机界面 --- */
#custom-camera-overlay {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: #000;
	z-index: 4000;
}

#camera-viewport {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #000;
}

#camera-video {
	width: 100%;
	height: 100%;
	object-fit: contain;
	display: block;
	transform-origin: center;
}

.cam-floating-btn {
	position: absolute;
	bottom: 40px;
	width: 50px;
	height: 50px;
	background: rgba(0, 0, 0, 0.5);
	border: 2px solid #fff;
	border-radius: 50%;
	color: #fff;
	font-size: 12px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	z-index: 4002;
	backdrop-filter: blur(4px);
}

.cam-floating-btn:active {
	background: rgba(255, 255, 255, 0.3);
}

#cam-close {
	left: 30px;
}

#cam-switch {
	right: 30px;
}

/* --- 图片编辑器 --- */
#img-editor-overlay {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: #f5f5f7; /* 改为浅色 */
	z-index: 3000;
	-webkit-flex-direction: column;
	flex-direction: column;
	overflow: hidden;
}

#editor-wrapper {
	-webkit-flex: 1;
	flex: 1;
	width: 100%;
	height: calc(100% - 60px);
	background: #e0e0e0; /* 略深一点的灰色 */
	position: relative;
}

#editor-img {
	display: block;
	max-width: 100%;
}

.editor-controls {
	height: 60px;
	width: 100%;
	background: #fff; /* 改为白色 */
	display: -webkit-flex;
	display: flex;
	-webkit-align-items: center;
	align-items: center;
	-webkit-justify-content: space-between;
	justify-content: space-between;
	padding: 0 10px;
	-webkit-flex-shrink: 0;
	flex-shrink: 0;
	border-top: 1px solid #ccc;
}

.editor-btn-group {
	display: -webkit-flex;
	display: flex;
}

.editor-btn {
	color: #333; /* 改为深色 */
	background: transparent;
	border: 1px solid #ccc;
	padding: 8px 12px;
	font-weight: bold;
	border-radius: 4px;
	cursor: pointer;
	font-size: 12px;
	margin-right: 5px;
}

.editor-btn:active {
	background: #f0f0f0;
}

.editor-btn.confirm {
	background: #007aff;
	border-color: #007aff;
	color: #fff;
	margin-right: 0;
}

/* --- 中间聊天区 --- */
#chat-container {
	-webkit-flex: 1;
	flex: 1;
	overflow-y: auto;
	padding: 20px;
	padding-bottom: 20px;
	display: -webkit-flex;
	display: flex;
	-webkit-flex-direction: column;
	flex-direction: column;
	width: 100%;
}

.message-row {
	display: -webkit-flex;
	display: flex;
	margin-bottom: 20px;
	width: 100%;
	-webkit-align-items: flex-start;
	align-items: flex-start;
	-webkit-flex-shrink: 0;
	flex-shrink: 0;
}

.user-row {
	-webkit-justify-content: flex-end;
	justify-content: flex-end;
}

.ai-row {
	-webkit-justify-content: flex-start;
	justify-content: flex-start;
}

.bubble {
	max-width: 90%;
	border-radius: 8px;
	font-size: 15px;
	line-height: 1.6;
	display: inline-block;
	position: relative;
	box-shadow: 2px 2px 0px rgba(0, 0, 0, 0.05); /* 阴影变浅 */
	user-select: text;
	-webkit-user-select: text;
	cursor: auto;
	word-wrap: break-word;
	overflow-wrap: break-word;
	overflow: hidden;
}

.user-row .bubble {
	background: #fff;
	color: #000;
	border: 1px solid #ccc; /* 边框变细变浅 */
}

.ai-row .bubble {
	/* AI气泡改为浅灰色 */
	background: #f2f2f2;
	color: #222;
	border: 1px solid #ccc;
}

.msg-images-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
	gap: 5px;
	padding: 10px 14px 0 14px;
}

.msg-image {
	display: block;
	width: 100%;
	max-height: 300px;
	object-fit: cover;
	border-radius: 4px;
	border: 1px solid #ccc;
	cursor: pointer;
}

.bubble .md-content,
.bubble .md-content.-dark {
	font-family: inherit !important;
	background-color: transparent !important;
	color: inherit !important;
	padding: 10px 14px;
}

.bubble .md-content p {
	margin-bottom: 0.8em;
}

.bubble .md-content p:last-child {
	margin-bottom: 0;
}

.bubble a {
	text-decoration: none;
	border-bottom: 1px dashed currentColor;
}

.user-row .bubble a {
	color: #007aff;
}

.ai-row .bubble a {
	color: #0056b3; /* AI链接颜色微调 */
}

.thinking-trace {
	margin: 10px 14px 0 14px;
	padding: 8px;
	/* 思维链背景改为极浅的黑色半透明 */
	background: rgba(0, 0, 0, 0.05);
	border-left: 3px solid #999;
	font-size: 0.9em;
	color: #666;
	border-radius: 4px;
	margin-bottom: 10px;
}

.user-row .thinking-trace {
	display: none;
}

.thinking-trace summary {
	cursor: pointer;
	font-weight: bold;
	opacity: 0.8;
	outline: none;
}

.thinking-content {
	margin-top: 8px;
	white-space: pre-wrap;
	font-style: italic;
}

.thinking-content .md-content {
	padding: 0 !important;
	font-style: normal;
	font-size: 0.95em;
}

/* --- 底部控制栏 --- */
.footer-controls {
	background: #f9f9f9; /* 浅色背景 */
	border-top: 1px solid #ccc;
	height: 50px;
	display: -webkit-flex;
	display: flex;
	-webkit-align-items: center;
	align-items: center;
	padding: 0 10px;
	-webkit-justify-content: space-between;
	justify-content: space-between;
	-webkit-flex-shrink: 0;
	flex-shrink: 0;
}

.footer-btn {
	background: #fff;
	border: 1px solid #ccc;
	padding: 5px 10px;
	font-family: inherit;
	font-weight: bold;
	cursor: pointer;
	font-size: 12px;
	box-shadow: 2px 2px 0 rgba(0,0,0,0.1);
	margin-right: 5px;
	white-space: nowrap;
	height: 32px;
	display: -webkit-flex;
	display: flex;
	-webkit-align-items: center;
	align-items: center;
	border-radius: 4px;
	color: #333;
}

.footer-btn:active {
	transform: translate(1px, 1px);
	box-shadow: 1px 1px 0 rgba(0,0,0,0.1);
	background: #f0f0f0;
}

select#model-select {
	-webkit-flex: 1;
	flex: 1;
	margin: 0 5px;
	padding: 0 5px;
	border: 1px solid #ccc;
	border-radius: 4px;
	background: #fff;
	font-family: inherit;
	font-size: 12px;
	min-width: 0;
	height: 32px;
	color: #333;
}

/* --- 菜单与弹窗 --- */
#context-menu {
	display: none;
	position: absolute;
	background: #fff;
	border: 1px solid #ccc;
	box-shadow: 0 4px 12px rgba(0,0,0,0.15);
	z-index: 1000;
	min-width: 120px;
	border-radius: 4px;
}

.menu-item {
	padding: 12px 15px;
	font-weight: bold;
	cursor: pointer;
	border-bottom: 1px solid #eee;
	color: #333;
}

.menu-item:last-child {
	border-bottom: none;
}

.menu-item:hover {
	background: #f5f5f7;
	color: #000;
}

.menu-item.delete {
	color: #ff0000;
}

.menu-item.delete:hover {
	background: #fff5f5;
	color: #ff0000;
}

/* --- 弹窗样式优化 (自适应) --- */
#edit-overlay,
#settings-overlay {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.4); /* 遮罩层变淡 */
	z-index: 1100;
	-webkit-align-items: center;
	align-items: center;
	-webkit-justify-content: center;
	justify-content: center;
}

/* 编辑框与设置框通用样式优化 */
#edit-box,
.settings-box {
	background: #fff; /* 改为纯白 */
	border: 1px solid #ccc;
	box-shadow: 0 8px 24px rgba(0,0,0,0.15);
	padding: 15px;
	width: 90%;
	max-width: 500px;
	max-height: 90vh;
	display: -webkit-flex;
	display: flex;
	-webkit-flex-direction: column;
	flex-direction: column;
	border-radius: 8px;
}

.settings-box {
	max-width: 400px;
}

.edit-title {
	font-weight: bold;
	margin-bottom: 10px;
	font-size: 18px;
	border-bottom: 1px solid #eee;
	padding-bottom: 5px;
	-webkit-flex-shrink: 0;
	flex-shrink: 0;
	color: #000;
}

/* 内容滚动区域 */
.edit-inputs-wrapper,
.settings-content-wrapper {
	-webkit-flex: 1;
	flex: 1;
	overflow-y: auto;
	margin-bottom: 10px;
	padding-right: 5px;
	-webkit-overflow-scrolling: touch;
}

#edit-textarea {
	width: 100%;
	height: 150px;
	min-height: 100px;
	border: 1px solid #ccc;
	padding: 10px;
	font-family: inherit;
	font-size: 14px;
	resize: vertical;
	display: block;
	border-radius: 4px;
	background: #fff;
	color: #000;
}

#edit-thinking {
	width: 100%;
	height: 100px;
	border: 1px solid #ccc;
	background: #f9f9f9;
	color: #444;
	padding: 10px;
	font-family: inherit;
	font-size: 13px;
	margin-bottom: 10px;
	resize: vertical;
	display: none;
	border-radius: 4px;
}

.edit-actions {
	text-align: right;
	-webkit-flex-shrink: 0;
	flex-shrink: 0;
}

.setting-row {
	margin-bottom: 15px;
}

.setting-label {
	font-weight: bold;
	font-size: 12px;
	display: block;
	margin-bottom: 5px;
	color: #333;
}

.setting-select {
	width: 100%;
	padding: 8px;
	border: 1px solid #ccc;
	font-family: inherit;
	font-size: 14px;
	background: #fff;
	border-radius: 4px;
	color: #333;
}

.setting-input {
	width: 100%;
	padding: 8px;
	border: 1px solid #ccc;
	font-family: inherit;
	font-size: 14px;
	background: #fff;
	border-radius: 4px;
	box-sizing: border-box;
	color: #333;
}

#history-panel {
	position: fixed;
	bottom: -100%;
	left: 0;
	width: 100%;
	height: 70%;
	background: #fff;
	border-top: 1px solid #ccc;
	z-index: 200;
	transition: bottom 0.3s ease-in-out;
	display: -webkit-flex;
	display: flex;
	-webkit-flex-direction: column;
	flex-direction: column;
	box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
}

#history-panel.show {
	bottom: 0;
}

.panel-header {
	padding: 10px;
	background: #f9f9f9;
	color: #000;
	display: -webkit-flex;
	display: flex;
	-webkit-justify-content: space-between;
	justify-content: space-between;
	-webkit-align-items: center;
	align-items: center;
	border-bottom: 1px solid #ccc;
}

#history-list {
	-webkit-flex: 1;
	flex: 1;
	overflow-y: auto;
	padding: 10px;
}

.history-item {
	padding: 15px;
	border-bottom: 1px solid #eee;
	cursor: pointer;
	border-radius: 4px;
}

.history-item:hover {
	background: #f5f5f7;
}

.history-title {
	font-weight: bold;
	font-size: 14px;
	margin-bottom: 5px;
	color: #333;
}

.history-preview {
	color: #666;
	font-size: 12px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.history-time {
	font-size: 10px;
	color: #999;
	text-align: right;
	margin-top: 4px;
}

.loading-indicator {
	text-align: center;
	color: #555;
	padding: 10px;
	display: none;
}