/* ============================================================
   个人博客 · 编辑部风格（纸感底色 + 衬线标题 + 发丝分隔线）
   ============================================================ */

/* ---------- 设计令牌 ---------- */
:root {
  --bg: #faf9f7;             /* 暖纸底 */
  --surface: #ffffff;
  --surface-2: #f4f2ee;
  --text: #1c1b18;           /* 暖墨 */
  --muted: #6f6b63;
  --faint: #a09b91;
  --border: #e8e4dc;
  --border-strong: #d6d1c6;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --ring: rgba(37, 99, 235, .15);
  --code-bg: #f4f2ee;
  --chip-bg: #f0ede7;
  --shadow: 0 12px 32px rgba(60, 52, 40, .08);

  --font-display: Georgia, "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", SimSun, serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace;

  --ease: cubic-bezier(.2, .7, .3, 1);
}
html.dark {
  --bg: #141412;
  --surface: #1c1b19;
  --surface-2: #232220;
  --text: #eceae4;
  --muted: #a39f95;
  --faint: #6e6b63;
  --border: #2c2b27;
  --border-strong: #3d3b35;
  --accent: #7aa2f7;
  --accent-hover: #9db9f9;
  --danger: #ef4444;
  --danger-hover: #f87171;
  --ring: rgba(122, 162, 247, .2);
  --code-bg: #232220;
  --chip-bg: #26251f;
  --shadow: 0 12px 32px rgba(0, 0, 0, .45);
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color .3s var(--ease), color .3s var(--ease);
}
main { flex: 1; width: 100%; }
a { color: var(--accent); text-decoration: none; }
::selection { background: rgba(37, 99, 235, .16); }
html.dark ::selection { background: rgba(122, 162, 247, .24); }

/* 入场动效 */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- 顶部导航 ---------- */
header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid var(--border);
  transition: background-color .3s var(--ease), border-color .3s var(--ease);
}
.header-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 13px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.brand { display: flex; align-items: center; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-logo { display: block; width: 124px; height: auto; transition: transform .25s var(--ease), filter .3s; }
.brand:hover .brand-logo { transform: translateY(-1px); }
html.dark .brand-logo { filter: invert(1); }
.nav { display: flex; gap: 4px; margin-left: 4px; }
.nav-link {
  position: relative;
  padding: 6px 12px; font-size: 14px; font-weight: 500;
  color: var(--muted);
  border-radius: 7px;
  transition: color .18s;
}
.nav-link::after {
  content: "";
  position: absolute; left: 12px; right: 12px; bottom: 1px;
  height: 2px; border-radius: 2px;
  background: var(--accent);
  transform: scaleX(0); transform-origin: left;
  transition: transform .22s var(--ease);
}
.nav-link:hover { color: var(--text); text-decoration: none; }
.nav-link.active { color: var(--text); }
.nav-link.active::after { transform: scaleX(1); }
.spacer { flex: 1; }
.icon-btn {
  border: 1px solid transparent; background: transparent; color: var(--muted);
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background-color .18s, color .18s, border-color .18s;
  line-height: 1; padding: 0;
}
.icon-btn:hover { background: var(--chip-bg); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; display: block; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 8px; padding: 9px 16px;
  font-size: 14px; font-weight: 500; font-family: inherit;
  cursor: pointer; color: #fff; background: var(--accent);
  transition: background-color .18s, border-color .18s, color .18s, transform .15s var(--ease);
  line-height: 1; text-decoration: none;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: var(--danger-hover); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border-strong); }
.btn.ghost:hover { background: var(--chip-bg); }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 7px; }

/* ---------- 首页 · 海报式首屏 ---------- */
.home { max-width: 880px; margin: 0 auto; padding: 56px 20px 72px; }
.hero {
  margin-bottom: 48px;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 8px 48px;
  align-items: center;
}
.hero-text { min-width: 0; }
.hero-art { min-width: 0; display: flex; justify-content: center; }
.hero-art .art-svg {
  display: block; width: 100%; max-width: 360px; height: auto;
}

.hero-eyebrow {
  display: flex; align-items: center; gap: 12px;
  font-size: 11px; font-weight: 600; letter-spacing: .2em;
  text-transform: uppercase; color: var(--faint);
  margin-bottom: 18px;
}
.hero-eyebrow::before {
  content: ""; width: 30px; height: 1px; background: var(--border-strong);
}
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(38px, 7.5vw, 60px);
  font-weight: 700; letter-spacing: -0.015em; line-height: 1.08;
  margin: 0 0 14px;
}
.hero .hero-desc {
  color: var(--muted); font-size: 16px; line-height: 1.7;
  margin: 0 0 34px; max-width: 34em;
}

/* 搜索：下划线式 */
.search-box {
  position: relative; max-width: 420px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border-strong);
  padding: 6px 2px 8px;
  transition: border-color .2s;
}
.search-box:focus-within { border-bottom-color: var(--accent); }
.search-box .search-icon {
  color: var(--faint); display: flex; flex-shrink: 0;
  transition: color .2s;
}
.search-box:focus-within .search-icon { color: var(--accent); }
.search-box .search-icon svg { width: 15px; height: 15px; display: block; }
.search-box input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 15px; color: var(--text); font-family: inherit;
  padding: 2px 0; min-width: 0;
}
.search-box input::placeholder { color: var(--faint); }
.search-box kbd {
  font-family: var(--font-mono); font-size: 11px; color: var(--faint);
  border: 1px solid var(--border); border-radius: 5px;
  padding: 2px 7px; flex-shrink: 0;
  transition: opacity .2s;
}
.search-box:focus-within kbd, .search-box.filled kbd { opacity: 0; }

/* ---------- 标签筛选：文字式 ---------- */
.tag-bar {
  display: flex; flex-wrap: wrap; align-items: baseline;
  gap: 4px 22px; margin-bottom: 34px;
  animation: fadeUp .6s var(--ease) .26s both;
}
.chip {
  position: relative;
  border: none; background: transparent; color: var(--muted);
  padding: 3px 1px 6px; font-size: 13.5px; font-weight: 500;
  cursor: pointer; font-family: inherit; line-height: 1.4;
  transition: color .18s;
}
.chip::after {
  content: ""; position: absolute; left: 1px; right: 1px; bottom: 0;
  height: 2px; border-radius: 2px; background: var(--accent);
  transform: scaleX(0); transform-origin: left;
  transition: transform .22s var(--ease);
}
.chip:hover { color: var(--text); }
.chip.active { color: var(--text); }
.chip.active::after { transform: scaleX(1); }
.chip .cnt { color: var(--faint); font-size: 11.5px; margin-left: 4px; font-variant-numeric: tabular-nums; }

/* ---------- 文章索引：编辑部式列表（无卡片） ---------- */
.post-list { display: flex; flex-direction: column; border-top: 1px solid var(--border); }
.post-card {
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 6px 30px;
  padding: 27px 0 25px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.post-card:hover { text-decoration: none; }
.pc-date {
  font-size: 12.5px; color: var(--faint); letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
  padding-top: 5px;
  transition: color .2s;
}
.post-card:hover .pc-date { color: var(--muted); }
.pc-title {
  font-family: var(--font-display);
  font-size: 20px; font-weight: 600; letter-spacing: -0.01em;
  line-height: 1.4;
  display: flex; align-items: baseline; gap: 8px;
  transition: color .2s;
}
.pc-arrow {
  font-family: var(--font-body); font-size: 15px; font-weight: 400;
  color: var(--accent);
  opacity: 0; transform: translateX(-6px);
  transition: opacity .22s var(--ease), transform .22s var(--ease);
  flex-shrink: 0;
}
.post-card:hover .pc-title { color: var(--accent); }
.post-card:hover .pc-arrow { opacity: 1; transform: none; }
.post-card-summary {
  color: var(--muted); font-size: 14px; line-height: 1.75;
  margin: 8px 0 12px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-card-meta {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  color: var(--faint); font-size: 12.5px;
}
.mini-tag { color: var(--faint); transition: color .18s; }
.mini-tag:hover { color: var(--accent); }

.empty-state { text-align: left; color: var(--muted); padding: 64px 0 44px; }
.empty-state .big {
  font-family: var(--font-display);
  font-size: 19px; font-weight: 600; color: var(--text); margin-bottom: 8px;
}
.empty-state .small { font-size: 13.5px; }

/* ---------- 分页 ---------- */
.pagination {
  display: flex; align-items: center; justify-content: center; gap: 18px;
  margin-top: 38px; color: var(--muted); font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}
.pagination button {
  border: 1px solid var(--border); background: transparent; color: var(--text);
  border-radius: 8px; padding: 8px 15px; font-size: 13.5px; cursor: pointer;
  font-family: inherit;
  transition: border-color .18s, background-color .18s;
}
.pagination button:hover:not(:disabled) { border-color: var(--border-strong); background: var(--surface); }
.pagination button:disabled { opacity: .35; cursor: not-allowed; }

/* ---------- 阅读进度条 ---------- */
.read-progress {
  position: fixed; top: 0; left: 0; height: 2px; width: 0;
  background: var(--accent); z-index: 40;
  transition: width .12s linear;
  pointer-events: none;
}

/* ---------- 文章页 ---------- */
.post-page { max-width: 700px; margin: 0 auto; padding: 48px 20px 72px; }
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--muted); font-size: 13.5px; margin-bottom: 34px;
  transition: color .18s, gap .2s var(--ease);
}
.back-link:hover { color: var(--accent); gap: 9px; }
.post-header { margin-bottom: 34px; animation: fadeUp .55s var(--ease) both; }
.post-header h1 {
  font-family: var(--font-display);
  font-size: clamp(28px, 5.5vw, 40px);
  font-weight: 700; letter-spacing: -0.015em; line-height: 1.28;
  margin: 0 0 18px;
}
.post-header .post-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  color: var(--faint); font-size: 13px; letter-spacing: .02em;
}
.post-header .post-meta a { color: var(--faint); transition: color .18s; }
.post-header .post-meta a:hover { color: var(--accent); }
.post-header .post-meta .dot { opacity: .55; }
.badge {
  display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 500; letter-spacing: .04em;
  background: rgba(217, 119, 6, .12); color: #b45309;
}
html.dark .badge { background: rgba(251, 191, 36, .14); color: #fbbf24; }

/* ---------- 文章排版 ---------- */
.article {
  font-size: 16.5px; line-height: 1.95; word-break: break-word;
  animation: fadeUp .55s var(--ease) .08s both;
}
.article p { margin: 0 0 1.15em; }
.article h1, .article h2, .article h3, .article h4 {
  font-family: var(--font-display);
  font-weight: 700; letter-spacing: -0.01em; line-height: 1.4; margin: 1.9em 0 .7em;
}
.article h1 { font-size: 1.5em; }
.article h2 { font-size: 1.32em; padding-bottom: .34em; border-bottom: 1px solid var(--border); }
.article h3 { font-size: 1.14em; }
.article h4 { font-size: 1em; }
.article h1:first-child, .article h2:first-child, .article h3:first-child { margin-top: 0; }
.article ul, .article ol { padding-left: 1.5em; margin: 0 0 1.15em; }
.article li { margin: .32em 0; }
.article li > p { margin: 0 0 .4em; }
.article blockquote {
  margin: 1.5em 0; padding: 2px 0 2px 22px;
  border-left: 2px solid var(--accent);
  color: var(--muted);
}
.article blockquote p { margin: .5em 0; }
.article img { max-width: 100%; height: auto; border-radius: 10px; margin: 1.4em 0; }
.article hr { border: none; border-top: 1px solid var(--border); margin: 2.4em 0; }
.article a {
  color: var(--accent);
  text-decoration: underline; text-decoration-color: rgba(37, 99, 235, .35);
  text-underline-offset: 3px;
  transition: text-decoration-color .18s;
}
.article a:hover { text-decoration-color: var(--accent); }
html.dark .article a { text-decoration-color: rgba(122, 162, 247, .4); }

/* 行内代码 */
.article code, .slug-preview code {
  font-family: var(--font-mono);
  background: var(--code-bg); padding: .15em .45em; border-radius: 5px;
  font-size: .86em; color: var(--text);
}
/* 代码块（无 pygments 时的兜底样式） */
.article pre {
  background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 15px 17px; overflow: auto; margin: 1.4em 0; line-height: 1.65;
}
.article pre code { background: transparent; padding: 0; font-size: 13.5px; border-radius: 0; }
/* 代码块（pygments codehilite） */
.article .codehilite {
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: 10px; margin: 1.4em 0; overflow: hidden;
}
.article .codehilite pre { background: transparent; border: none; margin: 0; padding: 15px 17px; }
.article .codehilite code { background: transparent; padding: 0; font-size: 13.5px; }

.article table {
  border-collapse: collapse; width: 100%; margin: 1.4em 0; font-size: 14.5px;
  display: block; overflow-x: auto;
}
.article th, .article td { border: 1px solid var(--border); padding: 8px 13px; text-align: left; }
.article th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.article tbody tr:nth-child(even) { background: var(--surface-2); }

/* ---------- 后台（工具面：实用优先） ---------- */
.admin { max-width: 960px; margin: 0 auto; padding: 26px 20px 64px; }
.admin-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.admin-toolbar .title {
  font-family: var(--font-display);
  font-size: 19px; font-weight: 700; margin-right: 4px;
}
.admin-list { display: flex; flex-direction: column; border-top: 1px solid var(--border); }
.admin-item {
  display: flex; align-items: center; gap: 14px;
  padding: 15px 0;
  border-bottom: 1px solid var(--border);
  transition: border-color .18s;
  animation: fadeUp .45s var(--ease) both;
}
.admin-item:hover { border-bottom-color: var(--border-strong); }
.admin-item .ai-main { flex: 1; min-width: 0; }
.admin-item .ai-title {
  font-family: var(--font-display);
  font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: color .18s;
}
.admin-item:hover .ai-title { color: var(--accent); }
.admin-item .ai-title .draft-mark { color: #b45309; font-size: 12px; font-weight: 500; margin-left: 6px; }
html.dark .admin-item .ai-title .draft-mark { color: #fbbf24; }
.admin-item .ai-sub { color: var(--faint); font-size: 12.5px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-item .ai-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* 编辑器 */
.editor-grid { display: grid; grid-template-columns: 1fr 280px; gap: 18px; align-items: start; }
.editor-main { display: flex; flex-direction: column; gap: 12px; }
input[type="text"], input:not([type]), input[type="datetime-local"], input[type="password"], textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; outline: none; background: var(--surface-2); color: var(--text);
  transition: border-color .18s, box-shadow .18s, background-color .18s; font-family: inherit;
}
input:focus, textarea:focus {
  border-color: var(--accent); background: var(--surface);
  box-shadow: 0 0 0 3px var(--ring);
}
.ed-title { font-size: 20px !important; font-weight: 600 !important; }
.ed-content {
  min-height: 480px; resize: vertical; line-height: 1.7; font-size: 14px;
  font-family: var(--font-mono);
}
.editor-side {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; display: flex; flex-direction: column; gap: 13px;
  position: sticky; top: 76px;
}
.editor-side label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.editor-side label .hint { font-weight: 400; color: var(--faint); margin-left: 4px; }
.editor-side input, .editor-side textarea { margin-top: 6px; }
.editor-side textarea { resize: vertical; min-height: 64px; font-size: 13px; }
.editor-side .check {
  display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 500;
  color: var(--text); cursor: pointer;
}
.editor-side .check input { width: auto; margin: 0; }
.editor-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.editor-actions .btn { flex: 1; min-width: 84px; }
.slug-preview { font-size: 12px; color: var(--faint); word-break: break-all; margin-top: 5px; }
.slug-preview code { padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }

/* 预览弹层 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20, 18, 14, .55);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  z-index: 60; display: flex; align-items: flex-start; justify-content: center;
  padding: 5vh 16px; overflow: auto;
  animation: fadeIn .2s ease both;
}
.modal-mask[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } }
.modal-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  max-width: 720px; width: 100%; padding: 30px 32px;
  max-height: 90vh; overflow: auto; position: relative;
  box-shadow: var(--shadow);
  animation: fadeUp .3s var(--ease) both;
}
.modal-close {
  position: sticky; top: 0; float: right; margin: -12px -10px 0 0;
  border: none; background: var(--chip-bg); color: var(--text);
  width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 15px;
}

/* ---------- 通用 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 30px;
  transform: translateX(-50%) translateY(8px);
  background: var(--text); color: var(--bg);
  padding: 11px 18px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s var(--ease);
  z-index: 99; max-width: 88vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

footer {
  border-top: 1px solid var(--border);
  padding: 30px 0 36px;
  transition: border-color .3s var(--ease);
}
.footer-inner {
  max-width: 860px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  color: var(--faint); font-size: 13px;
  animation: fadeUp .6s var(--ease) .3s both;
}
.footer-brand {
  font-family: var(--font-display);
  font-weight: 700; color: var(--muted); font-size: 14px;
}
.footer-nav { display: flex; align-items: baseline; gap: 18px; }
.footer-nav a { color: var(--muted); transition: color .18s; }
.footer-nav a:hover { color: var(--accent); }
.footer-copy { font-variant-numeric: tabular-nums; }
.footer-icp {
  color: var(--faint); font-size: 12.5px; letter-spacing: .02em;
  transition: color .18s; text-decoration: none;
  white-space: nowrap;
}
.footer-icp:hover { color: var(--accent); text-decoration: none; }

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .brand-logo { width: 110px; }
  .header-inner { gap: 10px; padding: 12px 14px; }
  .home { padding: 36px 16px 56px; }
  .hero { grid-template-columns: 1fr; gap: 6px; margin-bottom: 32px; }
  .hero-art { max-width: 250px; margin: 4px auto 12px; }
  .hero .hero-desc { margin-bottom: 26px; font-size: 15px; }
  .search-box kbd { display: none; }
  .tag-bar { gap: 4px 16px; margin-bottom: 26px; }
  .post-card { grid-template-columns: 1fr; gap: 0; padding: 22px 0 20px; }
  .pc-date { padding: 0; margin-bottom: 7px; }
  .pc-title { font-size: 18px; }
  .post-card-summary { -webkit-line-clamp: 3; }
  .post-page { padding: 30px 16px 60px; }
  .editor-grid { grid-template-columns: 1fr; }
  .editor-side { position: static; }
  .admin-item { flex-wrap: wrap; }
  .admin-item .ai-actions { width: 100%; justify-content: flex-end; }
  .modal-card { padding: 22px 18px; }
  .footer-inner { flex-direction: column; gap: 10px; align-items: flex-start; }
}
