:root {
  --paper: #f6f1e7;
  --paper-2: #efe8d8;
  --ink: #2b2823;
  --ink-soft: #5c554a;
  --muted: #908676;
  --line: #e2d8c4;
  --seal: #b23a2e;
  --seal-deep: #8f2c22;
  --accent: #3f6b5e;
  --card: #fbf8f0;
  --shadow: 0 8px 30px rgba(70, 55, 30, 0.10);
  --radius: 14px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Noto Serif SC", "Songti SC", "STSong", "SimSun", Georgia, serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 80% -10%, #fbf6ea 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 10%, #f3ecdc 0%, transparent 55%),
    var(--paper);
  line-height: 1.85;
  font-size: 16.5px;
  -webkit-font-smoothing: antialiased;
}

.paper-grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  opacity: .5;
  background-image:
    repeating-linear-gradient(0deg, rgba(120,95,55,.025) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(120,95,55,.025) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: rgba(246, 241, 231, 0.86);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: 1080px; margin: 0 auto; padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); }
.seal {
  width: 42px; height: 42px; display: grid; place-items: center;
  background: var(--seal); color: #fdf3e7; font-size: 24px; font-weight: 700;
  border-radius: 8px; box-shadow: inset 0 0 0 2px rgba(255,255,255,.18);
  transform: rotate(-3deg);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-title { font-size: 22px; font-weight: 700; letter-spacing: 4px; }
.brand-sub { font-size: 11px; color: var(--muted); letter-spacing: 1px; }
.site-nav { display: flex; gap: 6px; }
.site-nav a {
  text-decoration: none; color: var(--ink-soft); padding: 8px 14px; border-radius: 999px;
  font-size: 15px; transition: all .2s ease;
}
.site-nav a:hover { color: var(--seal); background: rgba(178,58,46,.08); }
.site-nav a.active { color: var(--seal); background: rgba(178,58,46,.12); font-weight: 600; }

/* ---------- Layout ---------- */
.layout {
  position: relative; z-index: 1;
  max-width: 1080px; margin: 28px auto; padding: 0 24px;
  display: grid; grid-template-columns: 1fr 280px; gap: 36px; align-items: start;
}
.content { min-height: 60vh; }

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(135deg, #fbf8f0, #f1e9d7);
  border: 1px solid var(--line); border-left: 4px solid var(--seal);
  border-radius: var(--radius); padding: 30px 32px; margin-bottom: 30px;
  box-shadow: var(--shadow);
}
.hero h1 { margin: 0 0 8px; font-size: 30px; letter-spacing: 3px; }
.hero p { margin: 0; color: var(--ink-soft); }
.hero .hero-quote { margin-top: 14px; color: var(--seal-deep); font-style: italic; }

/* ---------- Section title ---------- */
.section-title {
  display: flex; align-items: baseline; gap: 12px; margin: 6px 0 18px;
}
.section-title h2 { margin: 0; font-size: 22px; letter-spacing: 2px; }
.section-title .count { color: var(--muted); font-size: 14px; }
.section-title .back { margin-left: auto; font-size: 14px; }
.section-title .back a { color: var(--accent); text-decoration: none; }
.section-title .back a:hover { text-decoration: underline; }

/* ---------- Post list ---------- */
.post-list { display: flex; flex-direction: column; gap: 18px; }
.post-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 24px; box-shadow: var(--shadow); transition: transform .18s ease, box-shadow .18s ease;
  display: block; text-decoration: none; color: inherit;
}
.post-card:hover { transform: translateY(-3px); box-shadow: 0 14px 36px rgba(70,55,30,.16); }
.post-card h3 { margin: 0 0 8px; font-size: 21px; letter-spacing: 1px; color: var(--ink); }
.post-card .meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.post-card .summary { margin: 0; color: var(--ink-soft); }
.post-card .read-more { display: inline-block; margin-top: 12px; color: var(--seal); font-size: 14px; }
.post-card:hover .read-more { text-decoration: underline; }

.tag {
  display: inline-block; font-size: 12.5px; padding: 3px 11px; border-radius: 999px;
  background: rgba(63,107,94,.10); color: var(--accent); text-decoration: none; transition: all .15s ease;
  border: 1px solid transparent;
}
.tag:hover { background: rgba(63,107,94,.18); }
.tag.active { background: var(--accent); color: #fff; }

/* ---------- Detail ---------- */
.article-header { margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px dashed var(--line); }
.article-header h1 { margin: 0 0 10px; font-size: 30px; letter-spacing: 2px; }
.article-header .meta { color: var(--muted); font-size: 14px; display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }

.markdown { font-size: 17px; color: #34302a; }
.markdown h1, .markdown h2, .markdown h3 { letter-spacing: 1px; margin-top: 1.6em; }
.markdown h2 { border-left: 4px solid var(--seal); padding-left: 12px; }
.markdown p { margin: 1em 0; }
.markdown a { color: var(--seal); }
.markdown blockquote {
  margin: 1.4em 0; padding: 12px 18px; background: rgba(178,58,46,.06);
  border-left: 4px solid var(--seal); color: var(--seal-deep); border-radius: 0 8px 8px 0; font-style: italic;
}
.markdown ul, .markdown ol { padding-left: 1.4em; }
.markdown li { margin: .4em 0; }
.markdown code {
  background: rgba(63,107,94,.12); padding: 2px 6px; border-radius: 5px; font-size: .9em;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}
.markdown pre {
  background: #fbf8f0; border: 1px solid var(--line); border-radius: 10px;
  padding: 16px; overflow: auto; box-shadow: var(--shadow);
}
.markdown pre code { background: none; padding: 0; font-size: 14px; }
.markdown img { max-width: 100%; border-radius: 10px; }
.markdown table { border-collapse: collapse; width: 100%; margin: 1em 0; }
.markdown th, .markdown td { border: 1px solid var(--line); padding: 8px 12px; }
.markdown hr { border: none; border-top: 1px dashed var(--line); margin: 2em 0; }

/* ---------- Tags page ---------- */
.tag-group { margin-bottom: 22px; }
.tag-group h3 { font-size: 18px; margin: 0 0 10px; color: var(--accent); }
.tag-group .tag-list { display: flex; flex-wrap: wrap; gap: 10px; }
.tag-size-1 { font-size: 14px; }
.tag-size-2 { font-size: 16px; }
.tag-size-3 { font-size: 18px; }
.tag-size-4 { font-size: 21px; }

/* ---------- Sidebar ---------- */
.sidebar { position: sticky; top: 86px; display: flex; flex-direction: column; gap: 22px; }
.widget {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.widget-title {
  margin: 0 0 14px; font-size: 16px; letter-spacing: 2px; color: var(--ink);
  border-bottom: 1px solid var(--line); padding-bottom: 8px;
}
.tag-cloud { display: flex; flex-wrap: wrap; gap: 9px; }
.recent-list { list-style: none; margin: 0; padding: 0; }
.recent-list li { margin-bottom: 10px; }
.recent-list a { color: var(--ink-soft); text-decoration: none; font-size: 15px; }
.recent-list a:hover { color: var(--seal); }
.recent-list .recent-date { display: block; font-size: 12px; color: var(--muted); }
.quote-widget { background: linear-gradient(135deg, #fbf3e8, #f1e6d4); }
.quote-widget blockquote { margin: 0; font-size: 18px; color: var(--seal-deep); line-height: 1.7; }
.quote-by { margin: 8px 0 0; text-align: right; color: var(--muted); font-size: 13px; }

.muted { color: var(--muted); font-size: 14px; }
.loading { padding: 60px 0; text-align: center; color: var(--muted); letter-spacing: 2px; }

/* ---------- Footer ---------- */
.site-footer {
  position: relative; z-index: 1; text-align: center; padding: 30px 20px 40px;
  color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); margin-top: 20px;
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; flex-direction: row; flex-wrap: wrap; }
  .sidebar .widget { flex: 1 1 240px; }
  .brand-title { font-size: 19px; }
  .hero h1 { font-size: 24px; }
}

/* ---------- Markdown 编辑器 ---------- */
.editor-toolbar {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.editor-toolbar button {
  font-family: inherit; font-size: 14px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink-soft);
  border-radius: 7px; padding: 5px 11px; transition: all .15s ease;
}
.editor-toolbar button:hover { color: var(--seal); border-color: var(--seal); }
.editor-toolbar button.primary {
  background: var(--seal); color: #fdf3e7; border-color: var(--seal); font-weight: 600;
}
.editor-toolbar button.primary:hover { background: var(--seal-deep); color: #fff; }
.editor-toolbar .toolbar-spacer { flex: 1; }
.editor-wrap {
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); min-height: 62vh;
}
#ed-input {
  width: 100%; min-height: 60vh; resize: vertical; border: none; outline: none;
  background: #fbf8f0; color: #34302a; border-radius: 8px; padding: 14px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 14.5px; line-height: 1.7;
}
#ed-preview { overflow: auto; padding: 4px 6px; }
.editor-status { display: flex; gap: 14px; align-items: center; margin-top: 12px; font-size: 13px; color: var(--muted); }
.editor-meta { display: flex; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.editor-meta input {
  font-family: inherit; font-size: 15px; padding: 10px 14px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--card); color: var(--ink); outline: none; transition: border-color .15s ease;
}
.editor-meta input:focus { border-color: var(--seal); }
#ed-title { flex: 2 1 260px; }
#ed-tags { flex: 1 1 200px; }
@media (max-width: 860px) {
  .editor-wrap { grid-template-columns: 1fr; }
  #ed-input { min-height: 40vh; }
}

/* ---------- 管理页面 / 按钮 ---------- */
.btn, .btn-sm {
  font-family: inherit; cursor: pointer; text-decoration: none;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 9px; transition: all .15s ease; display: inline-block;
}
.btn { padding: 9px 16px; font-size: 15px; }
.btn-sm { padding: 4px 12px; font-size: 13px; }
.btn:hover, .btn-sm:hover { border-color: var(--seal); color: var(--seal); }
.btn.primary { background: var(--seal); color: #fdf3e7; border-color: var(--seal); font-weight: 600; }
.btn.primary:hover { background: var(--seal-deep); color: #fff; }
.btn-sm.danger { color: var(--seal-deep); }
.btn-sm.danger:hover { background: var(--seal); color: #fdf3e7; border-color: var(--seal); }

.admin-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.admin-table-wrap {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.admin-table th { background: #f3ecdc; font-size: 13px; color: var(--ink-soft); letter-spacing: 1px; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table .title-cell a { color: var(--ink); text-decoration: none; font-weight: 600; }
.admin-table .title-cell a:hover { color: var(--seal); }
.admin-table .tags-cell { color: var(--ink-soft); }
.admin-table .actions-cell { white-space: nowrap; display: flex; gap: 8px; }
.admin-table .tag { font-size: 12px; background: #f0e7d6; padding: 2px 8px; }

/* ---------- 作者简介 ---------- */
.bio-page { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 30px; }
.bio-head { display: flex; align-items: center; gap: 22px; margin-bottom: 22px; flex-wrap: wrap; }
.bio-photo { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; border: 3px solid #fff; box-shadow: var(--shadow); background: var(--paper-2); }
.bio-photo.placeholder { display: grid; place-items: center; color: var(--muted); font-size: 13px; border: 2px dashed var(--line); }
.bio-name { font-size: 24px; font-weight: 700; color: var(--ink); }
.bio-intro { margin-top: 6px; }

.bio-form { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px; max-width: 760px; }
.bio-form .field { display: block; margin-bottom: 20px; }
.bio-form .field-label { display: block; font-size: 14px; color: var(--ink-soft); margin-bottom: 8px; letter-spacing: 1px; }
.bio-form input[type="text"], .bio-form textarea {
  width: 100%; font-family: inherit; font-size: 15px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 10px; background: #fbf8f0; color: var(--ink); outline: none; transition: border-color .15s ease;
}
.bio-form input[type="text"]:focus, .bio-form textarea:focus { border-color: var(--seal); }
.bio-form textarea { resize: vertical; line-height: 1.7; }
.bio-form input[type="file"] { display: block; margin-bottom: 10px; font-size: 14px; }
.bio-preview { width: 110px; height: 110px; border-radius: 50%; object-fit: cover; margin-top: 10px; border: 3px solid #fff; box-shadow: var(--shadow); }

@media (max-width: 860px) {
  .admin-table th:nth-child(2), .admin-table td:nth-child(2) { display: none; }
  .bio-page, .bio-form { padding: 18px; }
}

.admin-only { display: none; }

/* ---------- 登录页 ---------- */
.login-wrap { display: flex; justify-content: center; padding: 40px 0; }
.login-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 30px; }
.login-card h2 { margin-bottom: 6px; color: var(--ink); }
.login-card .muted { margin-bottom: 18px; display: block; }
.login-card .field { display: block; margin-bottom: 16px; }
.login-card .field-label { display: block; font-size: 14px; color: var(--ink-soft); margin-bottom: 8px; letter-spacing: 1px; }
.login-card input[type="text"], .login-card input[type="password"] {
  width: 100%; font-family: inherit; font-size: 15px; padding: 11px 14px;
  border: 1px solid var(--line); border-radius: 10px; background: #fbf8f0; color: var(--ink); outline: none; transition: border-color .15s ease;
}
.login-card input:focus { border-color: var(--seal); }
.login-card .btn.primary { width: 100%; margin-top: 4px; }
.login-card #login-status { display: block; margin-top: 12px; }
