:root {
	--bg: #fdfcfd;
	--bg-side: #f8f6f9;
	--bg-elev: #f3eef5;
	--bg-input: #ffffff;
	--line: #e9e2ee;
	--text: #1f1a22;
	--muted: #7a7080;
	--accent: #ec4899;
	--accent-strong: #db2777;
	--accent-soft: #fdeaf4;
	--accent-line: #f9c9e0;
	--danger: #ef4444;
	--shadow: rgba(120, 70, 110, 0.08);
	--radius: 16px;
}

* {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	height: 100%;
	background: var(--bg);
	color: var(--text);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
	-webkit-font-smoothing: antialiased;
}

body {
	overflow: hidden;
}

.app {
	display: flex;
	height: 100dvh;
}

/* ---------------- 侧栏 ---------------- */
.sidebar {
	width: 268px;
	flex: 0 0 268px;
	display: flex;
	flex-direction: column;
	background: var(--bg-side);
	border-right: 1px solid var(--line);
	padding: 12px 10px;
	gap: 8px;
	z-index: 30;
}

.sidebar-head {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 4px 6px 8px;
}

.brand {
	display: flex;
	align-items: center;
	gap: 8px;
	font-weight: 600;
	letter-spacing: 0.04em;
	font-size: 15px;
	color: var(--text);
}

.brand-mark {
	font-size: 18px;
}

.btn-new {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	width: 100%;
	padding: 10px 12px;
	background: linear-gradient(180deg, #fdeaf4, #fbd9e9);
	border: 1px solid var(--accent-line);
	color: #a1195c;
	border-radius: 12px;
	cursor: pointer;
	font-size: 13.5px;
	font-weight: 500;
	transition: 0.15s;
}

.btn-new:hover {
	background: linear-gradient(180deg, #fbd9e9, #f8c9df);
	border-color: #f3a8d0;
}

.conv-list {
	flex: 1;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: 4px 2px;
}

.conv-list::-webkit-scrollbar {
	width: 6px;
}

.conv-list::-webkit-scrollbar-thumb {
	background: #e3dbe8;
	border-radius: 3px;
}

.conv-item {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 9px 10px;
	border-radius: 10px;
	cursor: pointer;
	color: var(--muted);
	font-size: 13.5px;
	line-height: 1.3;
	transition: 0.12s;
	position: relative;
}

.conv-item:hover {
	background: var(--bg-elev);
	color: var(--text);
}

.conv-item.active {
	background: var(--accent-soft);
	color: #8d1550;
	font-weight: 500;
}

.conv-item .title {
	flex: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.conv-item .acts {
	display: none;
	gap: 2px;
}

.conv-item:hover .acts,
.conv-item.active .acts {
	display: flex;
}

.mini-btn {
	background: none;
	border: none;
	color: var(--muted);
	cursor: pointer;
	font-size: 12px;
	padding: 2px 4px;
	border-radius: 6px;
	line-height: 1;
}

.mini-btn:hover {
	background: #f0e5f2;
	color: var(--accent-strong);
}

.sidebar-foot {
	border-top: 1px solid var(--line);
	padding: 8px 6px 2px;
}

.ghost-btn {
	background: none;
	border: 1px solid var(--line);
	color: var(--muted);
	padding: 8px 12px;
	border-radius: 10px;
	cursor: pointer;
	font-size: 13px;
	width: 100%;
}

.ghost-btn:hover {
	color: var(--accent-strong);
	border-color: var(--accent-line);
	background: var(--accent-soft);
}

/* ---------------- 主区 ---------------- */
.main {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-width: 0;
	position: relative;
}

.topbar {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 18px;
	border-bottom: 1px solid var(--line);
	background: rgba(253, 252, 253, 0.86);
	backdrop-filter: blur(8px);
	z-index: 10;
}

.topbar h1 {
	flex: 1;
	font-size: 14.5px;
	font-weight: 500;
	margin: 0;
	color: var(--text);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.icon-btn {
	background: none;
	border: none;
	color: var(--muted);
	font-size: 16px;
	cursor: pointer;
	padding: 6px 8px;
	border-radius: 8px;
	line-height: 1;
}

.icon-btn:hover {
	background: var(--bg-elev);
	color: var(--accent-strong);
}

.only-mobile {
	display: none;
}

.messages {
	flex: 1;
	overflow-y: auto;
	padding: 26px 18px 12px;
	scroll-behavior: smooth;
}

.messages::-webkit-scrollbar {
	width: 8px;
}

.messages::-webkit-scrollbar-thumb {
	background: #e6deea;
	border-radius: 4px;
}

.empty {
	max-width: 620px;
	margin: 8vh auto 0;
	text-align: center;
	color: var(--muted);
}

.empty-mark {
	font-size: 44px;
}

.empty h2 {
	color: var(--text);
	font-size: 22px;
	font-weight: 600;
	margin: 14px 0 8px;
}

.empty p {
	margin: 0 0 22px;
	font-size: 14px;
}

.chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	justify-content: center;
}

.chip {
	background: #fff;
	border: 1px solid var(--line);
	color: var(--muted);
	padding: 9px 14px;
	border-radius: 999px;
	cursor: pointer;
	font-size: 13px;
	box-shadow: 0 1px 2px var(--shadow);
}

.chip:hover {
	color: var(--accent-strong);
	border-color: var(--accent-line);
	background: var(--accent-soft);
}

.msg {
	max-width: 780px;
	margin: 0 auto 20px;
	display: flex;
	gap: 12px;
	animation: fade 0.18s ease;
}

@keyframes fade {
	from {
		opacity: 0;
		transform: translateY(4px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

.avatar {
	flex: 0 0 30px;
	width: 30px;
	height: 30px;
	border-radius: 9px;
	display: grid;
	place-items: center;
	font-size: 15px;
	background: #fff;
	border: 1px solid var(--line);
	box-shadow: 0 1px 2px var(--shadow);
}

.msg.user .avatar {
	background: var(--accent-soft);
	border-color: var(--accent-line);
}

.bubble {
	flex: 1;
	min-width: 0;
	padding-top: 4px;
}

.msg.user .bubble {
	background: var(--accent-soft);
	border: 1px solid var(--accent-line);
	border-radius: 14px 14px 4px 14px;
	padding: 10px 14px;
	white-space: pre-wrap;
	word-break: break-word;
	font-size: 14.5px;
	line-height: 1.65;
	margin-left: auto;
	max-width: 85%;
	color: #3a2230;
}

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

.msg.assistant .bubble {
	font-size: 15px;
	line-height: 1.75;
	word-break: break-word;
}

.bubble > *:first-child {
	margin-top: 0;
}

.bubble > *:last-child {
	margin-bottom: 0;
}

.bubble p {
	margin: 0 0 10px;
}

.bubble h1,
.bubble h2,
.bubble h3 {
	margin: 16px 0 8px;
	font-size: 1.08em;
	font-weight: 600;
	color: #2a1f2e;
}

.bubble ul,
.bubble ol {
	margin: 6px 0 10px;
	padding-left: 22px;
}

.bubble li {
	margin: 3px 0;
}

.bubble code {
	background: #f7f1f9;
	border: 1px solid #ecdfee;
	color: #a1195c;
	padding: 1px 5px;
	border-radius: 6px;
	font-size: 0.88em;
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.bubble pre {
	background: #faf8fb;
	border: 1px solid #eee4f1;
	border-radius: 12px;
	padding: 12px 14px;
	overflow-x: auto;
	margin: 10px 0;
	position: relative;
}

.bubble pre code {
	background: none;
	border: none;
	padding: 0;
	color: #3a2f3f;
	font-size: 12.8px;
	line-height: 1.6;
	display: block;
	white-space: pre;
}

.bubble blockquote {
	margin: 10px 0;
	padding: 2px 0 2px 12px;
	border-left: 3px solid var(--accent-line);
	color: var(--muted);
}

.bubble a {
	color: var(--accent-strong);
}

.msg-meta {
	display: flex;
	gap: 8px;
	margin-top: 6px;
	opacity: 0;
	transition: 0.15s;
}

.msg.assistant:hover .msg-meta,
.msg.assistant.reveal .msg-meta {
	opacity: 1;
}

.time {
	font-size: 11px;
	color: #b3a8ba;
}

.copy-btn {
	background: none;
	border: none;
	color: #b3a8ba;
	font-size: 11px;
	cursor: pointer;
	padding: 0;
}

.copy-btn:hover {
	color: var(--accent-strong);
}

.typing::after {
	content: "▍";
	color: var(--accent);
	animation: blink 1s steps(2) infinite;
}

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

/* ---------------- 输入框 ---------------- */
.composer-wrap {
	padding: 6px 18px 16px;
	background: linear-gradient(180deg, rgba(253, 252, 253, 0), var(--bg) 22%);
}

.composer {
	max-width: 780px;
	margin: 0 auto;
	display: flex;
	align-items: flex-end;
	gap: 8px;
	background: var(--bg-input);
	border: 1px solid var(--line);
	border-radius: 18px;
	padding: 8px 8px 8px 16px;
	transition: border-color 0.15s, box-shadow 0.15s;
	box-shadow: 0 2px 10px var(--shadow);
}

.composer:focus-within {
	border-color: var(--accent-line);
	box-shadow: 0 2px 14px rgba(236, 72, 153, 0.14);
}

.composer textarea {
	flex: 1;
	background: none;
	border: none;
	outline: none;
	color: var(--text);
	font-size: 15px;
	line-height: 1.55;
	resize: none;
	max-height: 220px;
	padding: 6px 0;
	font-family: inherit;
}

.composer textarea::placeholder {
	color: #b3a8ba;
}

.send-btn {
	flex: 0 0 34px;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	border: none;
	background: var(--accent);
	color: #fff;
	font-size: 17px;
	font-weight: 700;
	cursor: pointer;
	transition: 0.15s;
	box-shadow: 0 2px 8px rgba(236, 72, 153, 0.28);
}

.send-btn:hover:not(:disabled) {
	background: var(--accent-strong);
}

.send-btn:disabled {
	background: #f0e7f1;
	color: #c3b6c9;
	cursor: default;
	box-shadow: none;
}

.send-btn.stop {
	background: var(--danger);
	color: #fff;
	box-shadow: 0 2px 8px rgba(239, 68, 68, 0.25);
}

.hint {
	max-width: 780px;
	margin: 8px auto 0;
	text-align: center;
	font-size: 11px;
	color: #c2b8c8;
}

/* ---------------- 弹层 ---------------- */
.overlay {
	position: fixed;
	inset: 0;
	background: rgba(60, 40, 60, 0.28);
	backdrop-filter: blur(4px);
	display: grid;
	place-items: center;
	z-index: 100;
	padding: 18px;
}

.hidden {
	display: none !important;
}

.card {
	background: #fff;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 22px;
	width: 100%;
	max-width: 560px;
	max-height: 88dvh;
	overflow-y: auto;
	box-shadow: 0 24px 60px rgba(120, 70, 110, 0.16);
}

.card h2 {
	margin: 0 0 6px;
	font-size: 17px;
}

.card-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 14px;
}

.login-card {
	max-width: 340px;
	text-align: center;
}

.login-card p {
	color: var(--muted);
	font-size: 13px;
	margin: 6px 0 18px;
}

.login-card input {
	width: 100%;
	padding: 11px 14px;
	background: #fff;
	border: 1px solid var(--line);
	border-radius: 10px;
	color: var(--text);
	font-size: 14px;
	outline: none;
	margin-bottom: 12px;
}

.login-card input:focus {
	border-color: var(--accent-line);
	box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.1);
}

.login-card button {
	width: 100%;
	padding: 11px;
	border: none;
	border-radius: 10px;
	background: var(--accent);
	color: #fff;
	font-weight: 600;
	cursor: pointer;
	font-size: 14px;
	box-shadow: 0 2px 10px rgba(236, 72, 153, 0.24);
}

.login-card button:hover {
	background: var(--accent-strong);
}

.error {
	color: var(--danger);
	font-size: 12px;
	margin-top: 10px;
	min-height: 16px;
}

.field {
	display: block;
	margin-bottom: 18px;
}

.field > span {
	display: block;
	font-size: 13px;
	margin-bottom: 7px;
	color: var(--text);
}

.field small {
	display: block;
	margin-top: 6px;
	color: #a89db0;
	font-size: 11.5px;
}

.field textarea,
.field select {
	width: 100%;
	background: #fff;
	border: 1px solid var(--line);
	border-radius: 10px;
	color: var(--text);
	padding: 11px 13px;
	font-size: 13.5px;
	font-family: inherit;
	line-height: 1.6;
	outline: none;
	resize: vertical;
}

.field textarea:focus,
.field select:focus {
	border-color: var(--accent-line);
	box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.1);
}

.card-actions {
	display: flex;
	gap: 10px;
}

.card-actions .ghost-btn {
	width: auto;
	flex: 1;
}

.primary {
	flex: 1;
	padding: 10px 16px;
	border: none;
	border-radius: 10px;
	background: var(--accent);
	color: #fff;
	font-weight: 600;
	cursor: pointer;
	font-size: 13.5px;
	box-shadow: 0 2px 10px rgba(236, 72, 153, 0.22);
}

.primary:hover {
	background: var(--accent-strong);
}

.status {
	margin-top: 12px;
	font-size: 12px;
	color: var(--muted);
	min-height: 16px;
}

.scrim {
	display: none;
}

/* ---------------- 移动端 ---------------- */
@media (max-width: 780px) {
	.only-mobile {
		display: block;
	}

	.sidebar {
		position: fixed;
		top: 0;
		bottom: 0;
		left: 0;
		transform: translateX(-102%);
		transition: transform 0.22s ease;
		box-shadow: 12px 0 40px rgba(120, 70, 110, 0.16);
	}

	.sidebar.open {
		transform: none;
	}

	.scrim.show {
		display: block;
		position: fixed;
		inset: 0;
		background: rgba(60, 40, 60, 0.28);
		z-index: 20;
	}

	.messages {
		padding: 18px 12px 6px;
	}

	.msg.user .bubble {
		max-width: 92%;
	}

	.composer-wrap {
		padding: 6px 10px 12px;
	}
}

/* ---------------- 粉色强调 / 情绪排版 ---------------- */
.bubble b,
.bubble strong {
	color: #b3186a;
	font-weight: 700;
}

.bubble i,
.bubble em {
	color: var(--accent-strong);
	font-style: italic;
}

.bubble u {
	text-decoration-color: var(--accent-line);
	text-underline-offset: 3px;
}

.bubble .pink {
	color: var(--accent-strong);
	font-weight: 600;
}

.bubble .soft {
	color: #a3909e;
	font-style: normal;
}

.bubble .whisper {
	color: #a3909e;
	font-style: italic;
}

.bubble small {
	color: var(--muted);
	font-size: 0.86em;
}

.bubble hr {
	border: none;
	border-top: 1px dashed var(--accent-line);
	margin: 14px 0;
}

.bubble blockquote {
	background: var(--accent-soft);
	border-left: 3px solid var(--accent-line);
	border-radius: 0 10px 10px 0;
	padding: 8px 12px;
	color: #7a4a63;
	font-style: italic;
}

.bubble div + div {
	margin-top: 8px;
}

.bubble br + br {
	line-height: 2.1;
}
