:root {
	--bg: #14161a;
	--panel: #1b1e26;
	--panel-2: #12141a;
	--border: #2a2f3d;
	--text: #c9d1e0;
	--muted: #8a93a6;
	--accent: #8b9bff;
	--danger: #ff6b6b;
	color-scheme: dark;
}

* { box-sizing: border-box; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
		"Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
	font-size: 14px;
	line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; color: #eef1f7; }
.brand a { color: #eef1f7; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); display: inline-block; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.top-actions form { margin: 0; }

main { max-width: 1100px; margin: 0 auto; padding: 20px; }

button {
	font: inherit;
	cursor: pointer;
	border-radius: 7px;
	border: 1px solid var(--border);
	background: var(--panel);
	color: var(--text);
	padding: 6px 12px;
}
button:hover { border-color: var(--accent); color: #fff; }
button.primary { background: var(--accent); border-color: var(--accent); color: #10121a; font-weight: 600; }
button.primary:hover { filter: brightness(1.08); color: #10121a; }
button.ghost { background: transparent; }
button.danger { color: var(--danger); }
button.danger:hover { border-color: var(--danger); color: var(--danger); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input, textarea {
	font: inherit;
	color: var(--text);
	background: var(--panel-2);
	border: 1px solid var(--border);
	border-radius: 7px;
	padding: 7px 10px;
	outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }

.flash { padding: 9px 12px; border-radius: 8px; margin-bottom: 14px; border: 1px solid var(--border); }
.flash.ok { border-color: #2f6b4f; background: rgba(47, 107, 79, 0.15); }
.flash.error { border-color: #7a2f2f; background: rgba(122, 47, 47, 0.15); }

.new-post { display: flex; gap: 8px; margin: 8px 0 20px; }
.new-post input:first-child { flex: 0 0 260px; }
.new-post input:nth-child(2) { flex: 1; }

table.posts { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.posts th, .posts td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.posts th { font-size: 12px; color: var(--muted); font-weight: 500; background: var(--panel-2); }
.posts tr:last-child td { border-bottom: none; }
.posts .slug { color: var(--muted); font-size: 12px; font-family: ui-monospace, Consolas, monospace; }
.posts .nowrap { white-space: nowrap; color: var(--muted); }
.row-actions { display: flex; gap: 8px; align-items: center; }
.row-actions form { margin: 0; }

.tag { display: inline-block; margin-right: 4px; padding: 1px 7px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.badge { font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid #2f6b4f; color: #7ddcaa; }
.badge.draft { border-color: #7a6a2f; color: #e0cf84; }
.empty { color: var(--muted); text-align: center; padding: 30px 0; }

/* 编辑页 */
.edit { max-width: 1400px; }
.meta-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.meta-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.meta-grid label.wide { grid-column: span 2; }
.meta-grid .check { flex-direction: row; align-items: center; gap: 6px; align-self: end; padding-bottom: 8px; font-size: 13px; color: var(--text); }

.toolbar {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	align-items: center;
	padding: 8px;
	background: var(--panel);
	border: 1px solid var(--border);
	border-bottom: none;
	border-radius: 10px 10px 0 0;
}
.toolbar button { padding: 4px 9px; font-size: 13px; background: var(--panel-2); }
.toolbar .spacer { flex: 1; }

.panes { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--border); border-radius: 0 0 10px 10px; overflow: hidden; }
.panes textarea {
	width: 100%;
	height: calc(100vh - 400px);
	min-height: 420px;
	resize: none;
	border: none;
	border-radius: 0;
	border-right: 1px solid var(--border);
	padding: 14px;
	font-family: ui-monospace, Consolas, "JetBrains Mono", monospace;
	font-size: 13px;
	line-height: 1.7;
}
.panes textarea:focus { border-color: transparent; }

.preview {
	height: calc(100vh - 400px);
	min-height: 420px;
	overflow: auto;
	padding: 14px 20px;
	background: #101217;
}
.preview h1, .preview h2, .preview h3 { color: #eef1f7; line-height: 1.35; margin: 1.2em 0 0.5em; }
.preview h2 { font-size: 1.35em; padding-bottom: 0.3em; border-bottom: 1px solid var(--border); }
.preview p { margin: 0.6em 0; }
.preview code { background: #1c2029; padding: 1px 5px; border-radius: 4px; font-size: 0.92em; }
.preview pre { background: #0b0d11; border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow: auto; }
.preview pre code { background: none; padding: 0; }
.preview blockquote { margin: 1em 0; padding: 2px 0 2px 14px; border-left: 3px solid var(--accent); color: var(--muted); }
.preview img { max-width: 100%; border-radius: 6px; }
.preview table { border-collapse: collapse; width: 100%; margin: 1em 0; }
.preview th, .preview td { border: 1px solid var(--border); padding: 6px 10px; }
.preview hr { border: none; border-top: 1px solid var(--border); margin: 1.4em 0; }

.publish { margin-top: 18px; }
.publish h2 { font-size: 13px; color: var(--muted); font-weight: 500; }
#publish-log {
	background: #0b0d11;
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 12px;
	font-family: ui-monospace, Consolas, monospace;
	font-size: 12px;
	line-height: 1.6;
	max-height: 260px;
	overflow: auto;
	white-space: pre-wrap;
	color: #a8b3c7;
	margin: 0;
}
.save-state { color: var(--muted); font-size: 12px; }

/* 登录 */
.login-page { display: grid; place-items: center; min-height: 100vh; }
.login { display: flex; flex-direction: column; gap: 12px; width: 300px; padding: 26px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; }
.login h1 { font-size: 18px; margin: 0 0 6px; color: #eef1f7; }

@media (max-width: 1000px) {
	.meta-grid { grid-template-columns: repeat(2, 1fr); }
	.panes { grid-template-columns: 1fr; }
	.panes textarea, .preview { height: 40vh; min-height: 260px; border-right: none; border-bottom: 1px solid var(--border); }
}
