/* =========================================================
   基础变量 & Reset
   ========================================================= */
:root {
  --bg-body: #f7f8fa;
  --bg-main: #ffffff;
  --bg-soft: #f3f4f6;

  --text-main: #1f2937;
  --text-light: #6b7280;
  --text-muted: #9ca3af;

  --border: #e5e7eb;

  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;

  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
               Roboto, Helvetica, Arial, "Apple Color Emoji";
  background: var(--bg-body);
  color: var(--text-main);
  line-height: 1.6;
}

/* =========================================================
   Header
   ========================================================= */
header {
  height: 56px;
  background: #111827;
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 24px;
  justify-content: space-between;
}

header h1 {
  font-size: 16px;
  font-weight: 500;
  margin: 0;
}

header a {
  color: #c7d2fe;
  text-decoration: none;
  font-size: 14px;
}

header a:hover {
  color: #ffffff;
}

/* =========================================================
   Layout
   ========================================================= */
main {
  display: flex;
  height: calc(100vh - 56px);
  overflow: hidden;
}

aside {
  width: 260px;
  background: var(--bg-main);
  border-right: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
}

section {
  flex: 1;
  background: var(--bg-main);
  overflow-y: auto;
}

nav {
  width: 240px;
  background: #fafafa;
  border-left: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
}

/* =========================================================
   文章列表
   ========================================================= */
.post-item {
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  margin-bottom: 4px;
  font-size: 14px;
  color: var(--text-main);
  transition: background 0.15s;
}

.post-item:hover {
  background: var(--bg-soft);
}

.post-item.active {
  background: #e5e7eb;
  font-weight: 600;
}

/* =========================================================
   Markdown 内容
   ========================================================= */
article {
  max-width: 880px;
  margin: 0 auto;
  padding: 40px 24px 120px;
}

article h1 {
  font-size: 30px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 18px;
}

article h2 {
  margin-top: 40px;
  font-size: 24px;
}

article h3 {
  margin-top: 28px;
  font-size: 18px;
}

article p {
  margin: 14px 0;
  color: #374151;
}

article img {
  max-width: 100%;
  border-radius: 6px;
  margin: 16px 0;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

article a {
  color: var(--primary);
  text-decoration: none;
}

article a:hover {
  text-decoration: underline;
}

blockquote {
  margin: 20px 0;
  padding-left: 16px;
  border-left: 4px solid var(--border);
  color: var(--text-light);
}

pre {
  background: #0d1117;          /* ✅ 黑色背景 */
  color: #e6edf3;               /* ✅ 浅色字体 */
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  font-family: Consolas, Monaco, "Courier New", monospace;
  font-size: 14px;
}

pre code {
  background: none;             /* ✅ 防止嵌套变灰 */
  color: inherit;
  padding: 0;
}

/* 行内代码（非代码块） */
code {
  background: #111827;
  color: #f9fafb;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

/* 表格 */
table {
  border-collapse: collapse;
  width: 100%;
  margin: 20px 0;
}

th, td {
  border: 1px solid var(--border);
  padding: 10px;
  font-size: 14px;
}

th {
  background: #f3f4f6;
}

/* =========================================================
   TOC
   ========================================================= */
nav h3 {
  font-size: 14px;
  margin-top: 0;
  margin-bottom: 12px;
}

.toc a {
  display: block;
  font-size: 13px;
  color: #374151;
  text-decoration: none;
  padding: 4px 0;
  padding-left: calc(var(--lv) * 14px);
}

.toc a:hover {
  color: var(--primary);
}

/* =========================================================
   Admin 通用元素
   ========================================================= */
button {
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
}

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

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

button.secondary {
  background: #e5e7eb;
}

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

/* 输入框 */
input, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  outline: none;
}

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

/* =========================================================
   Admin 编辑器
   ========================================================= */
.editor-layout {
  display: flex;
  height: 100vh;
}

.editor-left,
.editor-right {
  width: 50%;
  padding: 16px;
  overflow-y: auto;
}

.editor-left {
  background: #ffffff;
  border-right: 1px solid var(--border);
}

.editor-right {
  background: #fafafa;
}

.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.toolbar button {
  font-size: 13px;
  padding: 6px 10px;
}

/* =========================================================
   Modal
   ========================================================= */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.show {
  display: flex;
}

.modal-box {
  background: #ffffff;
  padding: 24px;
  border-radius: 10px;
  width: 400px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.modal-box h2 {
  margin-top: 0;
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* =========================================================
   响应式
   ========================================================= */
@media (max-width: 1200px) {
  nav { display: none; }
}

@media (max-width: 900px) {
  aside { display: none; }
  article { padding: 24px 16px; }
}

.site-footer {
  height: 48px;
  display: flex;
  align-items: center;     /* ✅ 垂直居中 */
  justify-content: center; /* ✅ 水平居中 */

  font-size: 12px;
  color: #9ca3af;

  background: #f7f8fa;
  border-top: 1px solid #e5e7eb;
}

.site-footer a {
  color: #9ca3af;
  text-decoration: none;
}

.site-footer a:hover {
  color: #2563eb;
}
