:root {
	--accent: #e8590c;
	--accent-dark: #c74a08;
	--bg: #f6f4f1;
	--panel: #ffffff;
	--border: #e4ded7;
	--text: #2b2622;
	--muted: #8d847b;
	--danger: #c0392b;
	--radius: 12px;
}

* {
	box-sizing: border-box;
}

[hidden] {
	display: none !important;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family:
		-noto-sans-sc, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
	font-size: 14px;
}

button,
input,
select,
textarea {
	font: inherit;
	color: inherit;
}

button {
	cursor: pointer;
	border: 0;
	border-radius: 8px;
	padding: 0.55rem 0.95rem;
	transition:
		background-color 0.2s ease,
		opacity 0.2s ease;
}

button:disabled {
	opacity: 0.55;
	cursor: not-allowed;
}

button.primary {
	background: var(--accent);
	color: #fff;
}

button.primary:hover:not(:disabled) {
	background: var(--accent-dark);
}

button.ghost {
	background: #fff;
	border: 1px solid var(--border);
	color: var(--text);
}

button.ghost:hover:not(:disabled) {
	border-color: var(--accent);
	color: var(--accent);
}

button.danger {
	background: transparent;
	border: 1px solid rgba(192, 57, 43, 0.4);
	color: var(--danger);
}

button.danger:hover:not(:disabled) {
	background: var(--danger);
	color: #fff;
}

button.small {
	padding: 0.35rem 0.65rem;
	font-size: 13px;
}

button.block {
	width: 100%;
	padding: 0.7rem;
	font-weight: 600;
}

input,
select,
textarea {
	width: 100%;
	background: #fff;
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 0.55rem 0.7rem;
	outline: none;
	transition: border-color 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
	border-color: var(--accent);
}

textarea {
	resize: vertical;
}

/* 登录 */
.login-mask {
	position: fixed;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(160deg, #1877b5, #6fd2c3);
	z-index: 50;
}

.login-card {
	width: min(360px, 88vw);
	background: #fff;
	border-radius: 18px;
	padding: 2rem 1.6rem 1.6rem;
	display: flex;
	flex-direction: column;
	gap: 0.85rem;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
}

.login-card h1 {
	margin: 0;
	font-size: 1.4rem;
}

.login-card p {
	margin: 0 0 0.5rem;
	color: var(--muted);
}

.login-card small {
	color: var(--muted);
	line-height: 1.5;
}

.login-error {
	margin: 0;
	color: var(--danger);
	font-size: 13px;
}

/* 顶栏 */
.app {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
}

.topbar {
	position: sticky;
	top: 0;
	z-index: 20;
	display: flex;
	align-items: center;
	justify-content: space-between;
	background: rgba(255, 255, 255, 0.92);
	backdrop-filter: blur(10px);
	border-bottom: 1px solid var(--border);
	padding: 0.7rem 1.4rem;
}

.brand {
	font-weight: 700;
	font-size: 1.05rem;
}

.brand span {
	font-weight: 400;
	font-size: 0.85rem;
	color: var(--muted);
	margin-left: 0.4rem;
}

.top-actions {
	display: flex;
	align-items: center;
	gap: 0.8rem;
}

.top-actions a {
	color: var(--accent);
	text-decoration: none;
	font-size: 0.9rem;
}

/* 主体 */
.layout {
	display: grid;
	grid-template-columns: 300px minmax(0, 1fr);
	gap: 1.1rem;
	width: min(1280px, 100%);
	margin: 0 auto;
	padding: 1.1rem 1.4rem;
	flex: 1;
	min-height: 0;
}

.sidebar {
	display: flex;
	flex-direction: column;
	gap: 0.7rem;
	position: sticky;
	top: 4rem;
	align-self: start;
	max-height: calc(100vh - 5rem);
}

.post-list {
	list-style: none;
	margin: 0;
	padding: 0;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 0.45rem;
}

.post-list li {
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 0.65rem 0.75rem;
	cursor: pointer;
	transition:
		border-color 0.2s ease,
		box-shadow 0.2s ease;
}

.post-list li:hover {
	border-color: rgba(232, 89, 12, 0.5);
}

.post-list li.active {
	border-color: var(--accent);
	box-shadow: 0 0 0 2px rgba(232, 89, 12, 0.15);
}

.post-list .post-title {
	font-weight: 600;
	line-height: 1.4;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.post-list .post-meta {
	color: var(--muted);
	font-size: 12px;
	margin-top: 0.25rem;
}

/* 编辑器 */
.editor {
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 1.1rem 1.2rem 1.2rem;
	display: flex;
	flex-direction: column;
	gap: 0.8rem;
	min-width: 0;
}

.field {
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
	font-weight: 600;
	color: #57504a;
	font-size: 13px;
}

/* 智能识别粘贴 */
.smart-import {
	background: #fbf9f7;
	border: 1px dashed rgba(232, 89, 12, 0.45);
	border-radius: var(--radius);
	padding: 0.8rem 0.9rem;
	display: flex;
	flex-direction: column;
	gap: 0.55rem;
}

.smart-head {
	display: flex;
	align-items: baseline;
	gap: 0.6rem;
	flex-wrap: wrap;
}

.smart-head strong {
	color: var(--accent);
}

.smart-head span {
	color: var(--muted);
	font-size: 12.5px;
}

#import-text {
	min-height: 120px;
	font-size: 13px;
}

.import-images {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
	gap: 0.5rem;
}

.import-item {
	border: 1px solid var(--border);
	border-radius: 8px;
	overflow: hidden;
	background: #fff;
}

.import-item img {
	width: 100%;
	height: 80px;
	object-fit: cover;
	display: block;
	background: #f3efeb;
}

.import-item .url {
	font-size: 11px;
	color: var(--muted);
	padding: 0.3rem 0.4rem;
	word-break: break-all;
	overflow: hidden;
}

.grid-2 {
	display: grid;
	grid-template-columns: 1fr 160px;
	gap: 0.8rem;
}

.category-options {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	padding-top: 0.15rem;
}

.category-option {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	padding: 0.35rem 0.8rem;
	border: 1px solid var(--border);
	border-radius: 999px;
	background: #fff;
	color: #57504a;
	font-size: 13px;
	font-weight: 500;
	line-height: 1.4;
	cursor: pointer;
	user-select: none;
	transition:
		border-color 0.15s ease,
		background-color 0.15s ease,
		color 0.15s ease;
}

.category-option:hover {
	border-color: var(--accent);
}

.category-option:has(input:checked) {
	border-color: var(--accent);
	background: #fff3ea;
	color: var(--accent-dark);
}

.category-option input {
	margin: 0;
	accent-color: var(--accent);
}

.cover-row {
	display: flex;
	gap: 0.9rem;
	align-items: flex-start;
}

.cover-preview {
	width: 190px;
	aspect-ratio: 16 / 9;
	border: 1px dashed var(--border);
	border-radius: 10px;
	background: #faf8f6 center / cover no-repeat;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--muted);
	font-size: 13px;
	flex: none;
	overflow: hidden;
}

.cover-preview.has-image {
	border-style: solid;
	color: transparent;
}

.cover-actions {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
}

.btns {
	display: flex;
	gap: 0.5rem;
	flex-wrap: wrap;
	align-items: center;
}

.editor-toolbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-weight: 600;
	color: #57504a;
	font-size: 13px;
	margin-top: 0.2rem;
}

.netdisk-panel {
	margin-top: 0.6rem;
	padding: 0.8rem 0.9rem;
	border: 1px dashed var(--border);
	border-radius: 12px;
	background: #fffdfb;
	display: grid;
	gap: 0.55rem;
}

.netdisk-panel[hidden] {
	display: none;
}

.netdisk-panel .btns {
	display: flex;
	justify-content: flex-end;
	gap: 0.5rem;
}

.body {
	min-height: 420px;
	font-family: "JetBrains Mono", Consolas, "Courier New", monospace;
	font-size: 13.5px;
	line-height: 1.7;
	tab-size: 4;
}

.editor-footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	color: var(--muted);
	font-size: 12.5px;
}

/* 正文图片预览 */
.body-images {
	margin-top: 0.7rem;
	padding: 0.8rem 0.9rem;
	border: 1px dashed var(--border);
	border-radius: 12px;
	background: #fffdfb;
}

.body-images-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 0.6rem;
	font-size: 13px;
	font-weight: 600;
	color: #57504a;
}

.body-images-grid {
	display: flex;
	flex-wrap: wrap;
	gap: 0.7rem;
	align-items: flex-start;
	min-height: 74px;
}

.body-images-empty {
	color: var(--muted);
	font-size: 13px;
	line-height: 74px;
}

.body-images-hint {
	margin-top: 0.5rem;
	font-size: 12px;
	color: var(--muted);
}

.body-images.dragging {
	border-color: var(--accent);
	background: #fff7f0;
}

.body-image-item {
	position: relative;
	width: 112px;
	margin: 0;
}

.body-image-item.dragging {
	opacity: 0.45;
}

.body-image-item.drop-target img {
	border-color: var(--accent);
	box-shadow: 0 0 0 2px rgba(232, 89, 12, 0.45);
}

.body-image-remove {
	position: absolute;
	top: 4px;
	right: 4px;
	z-index: 1;
	width: 20px;
	height: 20px;
	padding: 0;
	border-radius: 50%;
	background: #e03131;
	color: #fff;
	font-size: 15px;
	line-height: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.body-image-remove:hover {
	background: #c92a2a;
}

.body-image-item img {
	display: block;
	width: 112px;
	height: 76px;
	object-fit: cover;
	border-radius: 9px;
	border: 1px solid var(--border);
	background: #f5f1ed;
	cursor: zoom-in;
}

.body-image-name {
	display: block;
	margin-top: 0.3rem;
	font-size: 11px;
	color: var(--muted);
	text-align: center;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.image-lightbox {
	position: fixed;
	inset: 0;
	z-index: 1000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 2rem;
	background: rgba(24, 18, 15, 0.82);
}

.image-lightbox[hidden] {
	display: none;
}

.image-lightbox img {
	max-width: min(92vw, 1200px);
	max-height: 82vh;
	border-radius: 12px;
	background: #fff;
	box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}

.image-lightbox button {
	position: absolute;
	top: 1.2rem;
	right: 1.4rem;
}

/* Git 面板 */
.git-panel {
	width: min(1280px, 100%);
	margin: 0 auto 1.4rem;
	padding: 1rem 1.4rem;
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	display: flex;
	flex-direction: column;
	gap: 0.65rem;
}

.git-head {
	display: flex;
	align-items: center;
	gap: 0.7rem;
}

.git-head strong {
	font-size: 14.5px;
}

.muted {
	color: var(--muted);
	font-size: 12.5px;
}

.git-status,
.git-output {
	margin: 0;
	background: #fbf9f7;
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 0.6rem 0.75rem;
	font-family: Consolas, monospace;
	font-size: 12.5px;
	line-height: 1.55;
	max-height: 180px;
	white-space: pre-wrap;
	overflow: auto;
}

.git-output {
	background: #f3f7f3;
}

.git-actions {
	display: flex;
	gap: 0.6rem;
}

.git-actions input {
	flex: 1;
}

/* 提示 */
.toast {
	position: fixed;
	left: 50%;
	bottom: 1.6rem;
	transform: translateX(-50%);
	background: rgba(43, 38, 34, 0.92);
	color: #fff;
	padding: 0.6rem 1.1rem;
	border-radius: 999px;
	font-size: 13px;
	z-index: 40;
	max-width: 80vw;
}

/* 手机端提示改到顶部，避免被软键盘/底部操作栏遮挡 */
@media (max-width: 640px) {
	.toast {
		top: 1rem;
		bottom: auto;
	}
}

/* 提交/推送等成功提示固定显示在下方，不受上面手机端改到顶部的规则影响 */
.toast.toast-success {
	top: auto;
	bottom: 1.6rem;
}

@media (max-width: 900px) {
	.layout {
		grid-template-columns: 1fr;
	}

	.sidebar {
		position: static;
		max-height: none;
	}

	.post-list {
		max-height: 240px;
	}

	.grid-2,
	.grid-3 {
		grid-template-columns: 1fr;
	}

	.cover-row {
		flex-direction: column;
	}

	.cover-preview {
		width: 100%;
	}

	.git-actions {
		flex-wrap: wrap;
	}

	.git-actions input {
		flex-basis: 100%;
	}
}

/* 云端发布状态 */
.editor-footer {
	flex-wrap: wrap;
	gap: 0.5rem;
}

.status-badge {
	display: inline-flex;
	align-items: center;
	padding: 0.18rem 0.6rem;
	border-radius: 999px;
	font-size: 12px;
	font-weight: 600;
	line-height: 1.6;
	background: #f1ecea;
	color: #6b5b5d;
}

.status-badge[data-status="draft"] {
	background: #fff2d9;
	color: #8a5a00;
}

.status-badge[data-status="dirty"] {
	background: #ffe3e6;
	color: #a8354a;
}

.status-badge[data-status="deleted"] {
	background: #f7dcdc;
	color: #a12f2f;
}

.status-badge[data-status="published"] {
	background: #e4f3e8;
	color: #2c6b3f;
}

.publish-panel .git-head {
	align-items: center;
}

.publish-panel .git-output {
	max-height: 220px;
}
