/* ===========================================================================
   Blog theme — a minimal, reading-focused single-column design
   (Spoon's information architecture + Bear Blog's typography).
   =========================================================================== */

:root {
  --bg: #fdfdfc;
  --fg: #1c1c1c;
  --muted: #6b6b6b;
  --faint: #9a9a9a;
  --border: #e8e8e4;
  --accent: #7a5c2e;
  --accent-strong: #5c441f;
  --code-bg: #f6f8fa;
  --code-fg: #24292f;
  --inline-code-bg: rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] {
  --bg: #141414;
  --fg: #e4e4e4;
  --muted: #a0a0a0;
  --faint: #707070;
  --border: #2a2a2a;
  --accent: #d8b64c;
  --accent-strong: #e6c96a;
  --code-bg: #f6f8fa; /* chroma "github" is a light style — keep code light */
  --code-fg: #24292f;
  --inline-code-bg: rgba(255, 255, 255, 0.12);
  --shadow: none;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue",
    Arial, sans-serif;
  font-size: 17px;
  line-height: 1.75;
  transition: background 0.2s ease, color 0.2s ease;
}

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

/* 自适应宽度：小屏接近全宽，大屏封顶更宽（可读性优先） */
.wrap {
  width: min(100% - 2.5rem, 56rem);
  margin-inline: auto;
}

/* ---- header ---- */
.site-head {
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.site-head.is-scrolled {
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.08);
}
.head-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1.1rem;
  padding-bottom: 1.1rem;
}
.brand {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--fg);
  white-space: nowrap;
}
.brand:hover { color: var(--accent); text-decoration: none; }

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  font-size: 0.95rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.site-nav a { color: var(--muted); }
.site-nav a:hover { color: var(--fg); text-decoration: none; }
.site-nav a.active { color: var(--fg); font-weight: 600; }

.theme-toggle {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  width: 1.9rem;
  height: 1.9rem;
  line-height: 1;
  cursor: pointer;
  font-size: 0.95rem;
}
.theme-toggle:hover { color: var(--fg); border-color: var(--faint); }

/* ---- main / sections ---- */
main { padding: 2rem 0 3rem; min-height: 60vh; }
.section-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
  margin: 0 0 1rem;
  font-weight: 600;
}
.featured { margin-bottom: 2.5rem; }

.page-title {
  font-size: 1.6rem;
  margin: 0.2rem 0 1.5rem;
  line-height: 1.3;
}
.empty { color: var(--muted); }

/* ---- post list ---- */
.post-list { list-style: none; margin: 0; padding: 0; }
.post-item {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}
.post-item:first-child { padding-top: 0; }
.post-item-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}
.post-title {
  font-size: 1.12rem;
  font-weight: 600;
  color: var(--fg);
  line-height: 1.4;
}
.post-title:hover { color: var(--accent); text-decoration: none; }
.post-date { color: var(--faint); font-size: 0.85rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.post-meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}
.post-meta .sep { margin: 0 0.4rem; color: var(--faint); }
.post-item-tags .tag { margin-right: 0.5rem; }
.post-summary { color: var(--muted); margin: 0.5rem 0 0; font-size: 0.95rem; }

/* ---- tags ---- */
.tag { color: var(--muted); font-size: 0.85rem; }
.tag:hover { color: var(--accent); }
.post-tags { margin-top: 0.6rem; }
.post-tags .tag { margin-right: 0.75rem; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.tag-lg {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  color: var(--muted);
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}
.tag-lg:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }
.tag-count { color: var(--faint); font-size: 0.75rem; }

/* ---- archive ---- */
.archive-year-title { font-size: 1.25rem; margin: 1.5rem 0 0.6rem; }
.archive-list { list-style: none; margin: 0; padding: 0; }
.archive-list li {
  display: flex;
  gap: 1.25rem;
  padding: 0.4rem 0;
  border-bottom: 1px dashed var(--border);
  align-items: baseline;
}
.archive-list .post-date { min-width: 2.6rem; }

/* ---- article ---- */
.post-header { margin-bottom: 1.75rem; }
.post-header .post-title {
  font-size: 1.9rem;
  line-height: 1.3;
  margin: 0 0 0.5rem;
  letter-spacing: -0.01em;
}
.post-body {
  font-size: 1.02rem;
  line-height: 1.85;
}
.post-body > :first-child { margin-top: 0; }
.post-body h1, .post-body h2, .post-body h3, .post-body h4 {
  line-height: 1.4;
  margin: 2rem 0 0.8rem;
  font-weight: 700;
}
.post-body h1 { font-size: 1.5rem; }
.post-body h2 { font-size: 1.3rem; }
.post-body h3 { font-size: 1.12rem; }
.post-body p { margin: 0 0 1.1rem; }
.post-body img { max-width: 100%; height: auto; border-radius: 4px; }
.post-body blockquote {
  margin: 1.25rem 0;
  padding: 0.1rem 0 0.1rem 1.1rem;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}
.post-body hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }
.post-body ul, .post-body ol { padding-left: 1.5rem; margin: 0 0 1.1rem; }
.post-body li { margin: 0.3rem 0; }
.post-body table {
  border-collapse: collapse;
  margin: 1.25rem 0;
  width: 100%;
  font-size: 0.92rem;
}
.post-body th, .post-body td { border: 1px solid var(--border); padding: 0.5rem 0.75rem; text-align: left; }
.post-body th { background: var(--inline-code-bg); }
.post-body a { border-bottom: 1px solid var(--accent); }
.post-body a:hover { text-decoration: none; }

/* inline code */
.post-body code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--inline-code-bg);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}
/* code blocks (chroma output) */
.post-body pre {
  background: var(--code-bg);
  color: var(--code-fg);
  border-radius: 6px;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  font-size: 0.88rem;
  line-height: 1.6;
  margin: 1.25rem 0;
}
.post-body pre code { background: transparent; padding: 0; font-size: inherit; }
.post-body .footnotes { font-size: 0.85rem; color: var(--muted); border-top: 1px solid var(--border); margin-top: 2rem; }

/* ---- prev / next ---- */
.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}
.post-nav-link {
  flex: 1;
  max-width: 48%;
  font-size: 0.92rem;
  color: var(--muted);
}
.post-nav-link span { display: block; font-size: 0.78rem; color: var(--faint); margin-bottom: 0.2rem; }
.post-nav-link.next { text-align: right; }
.post-nav-link.empty-nav { pointer-events: none; }

/* ---- footer ---- */
.site-foot {
  border-top: 1px solid var(--border);
  color: var(--faint);
  font-size: 0.85rem;
  padding: 1.25rem 1.25rem 2rem;
  text-align: center;
}
.site-foot p { margin: 0; }
.site-foot a { color: var(--muted); }

/* ===========================================================================
   Admin editor
   =========================================================================== */
.admin-body { height: 100vh; overflow: hidden; }
.admin-app { display: flex; height: 100vh; }
.admin-side {
  width: 16rem;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.admin-side-head {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.admin-actions { display: flex; gap: 0.5rem; }
.admin-list { list-style: none; margin: 0; padding: 0.5rem 0; overflow-y: auto; flex: 1; }
.admin-list li {
  padding: 0.55rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: baseline;
}
.admin-list li:hover { background: var(--inline-code-bg); color: var(--fg); }
.admin-list li.active { color: var(--fg); background: var(--inline-code-bg); border-right: 2px solid var(--accent); }
.admin-list .al-date { font-size: 0.75rem; color: var(--faint); white-space: nowrap; }
.admin-list .al-draft { color: var(--accent); font-size: 0.7rem; }

.admin-main { flex: 1; overflow-y: auto; padding: 1.25rem; }
.editor-row { display: flex; gap: 0.75rem; margin-bottom: 0.75rem; }
.editor-row input[type="text"], .editor-row input:not([type]),
.editor-row input[type="datetime-local"] {
  flex: 1;
  min-width: 0;
}
.editor-row-center { align-items: center; }
.editor-row-center input { flex: 1; }
.check { display: flex; align-items: center; gap: 0.35rem; font-size: 0.9rem; color: var(--muted); white-space: nowrap; }

input, textarea {
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
  width: 100%;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
.editor-panes { display: flex; gap: 1rem; height: calc(100vh - 15rem); }
.editor-panes textarea, .editor-panes .preview {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.85rem 1rem;
}
.editor-panes textarea {
  resize: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.6;
}
.preview { background: var(--bg); font-size: 0.95rem; }

.editor-foot { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.75rem; justify-content: flex-end; }
.editor-status { margin-right: auto; font-size: 0.85rem; color: var(--muted); }

.btn {
  font: inherit;
  font-size: 0.88rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  border-radius: 6px;
  padding: 0.4rem 0.85rem;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-danger { color: #c0392b; }
.btn-danger:hover { border-color: #c0392b; }
.btn-ghost { color: var(--muted); }

/* login */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
}
.login-form {
  width: 100%;
  max-width: 20rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1.5rem;
}
.login-form h1 { margin: 0; font-size: 1.4rem; }
.login-sub { margin: 0; color: var(--muted); font-size: 0.9rem; }
.login-err { color: #c0392b; font-size: 0.85rem; margin: 0; min-height: 1.2em; }

/* ---- responsive ---- */
@media (max-width: 640px) {
  .head-inner { flex-direction: column; align-items: flex-start; gap: 0.6rem; }
  .site-nav { justify-content: flex-start; }
  .post-header .post-title { font-size: 1.5rem; }
  .admin-side { width: 11rem; }
  .editor-panes { flex-direction: column; height: auto; }
  .editor-panes textarea { height: 16rem; }
  .editor-panes .preview { min-height: 12rem; }
}

/* ---- like + comments (public interactions) ---- */
.post-actions { margin: 2rem 0; }
.like-btn {
  font: inherit;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.4rem 1.1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}
.like-btn:hover { color: var(--accent); border-color: var(--accent); }
.like-btn.liked { color: #e0245e; border-color: #e0245e; }
.like-icon { font-size: 1.05rem; }

.comments { margin-top: 3rem; border-top: 1px solid var(--border); padding-top: 1.5rem; }
.comment { margin-bottom: 1rem; }
.comment-head { display: flex; gap: 0.6rem; align-items: baseline; }
.comment-name { font-weight: 600; font-size: 0.92rem; }
.comment-date { color: var(--faint); font-size: 0.78rem; }
.comment-body { margin: 0.25rem 0 0; }
.comment-children { margin-left: 1.5rem; padding-left: 1rem; border-left: 1px solid var(--border); margin-top: 0.6rem; }
/* 无限级回复：缩进最多 3 层，再深不再缩进（结构仍完整，避免越缩越窄） */
.comment-children .comment-children .comment-children .comment-children {
  margin-left: 0;
  padding-left: 0.6rem;
  border-left-style: dashed;
}
.comment-reply-to { color: var(--faint); font-size: 0.78rem; }
.comment-reply-to b { color: var(--muted); font-weight: 600; }
.comment-actions { display: flex; gap: 1rem; margin-top: 0.35rem; }
.comment-like, .comment-reply {
  font: inherit;
  font-size: 0.78rem;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--faint);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.comment-like:hover, .comment-reply:hover { color: var(--accent); }
.comment-like.liked { color: #e0245e; }
.reply-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--inline-code-bg);
  border-radius: 6px;
  padding: 0.45rem 0.7rem;
}
.reply-cancel {
  font: inherit;
  font-size: 0.78rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.5rem;
  cursor: pointer;
  color: var(--muted);
}
.reply-cancel:hover { color: var(--accent); border-color: var(--accent); }
.comment-form { margin-top: 1.5rem; display: flex; flex-direction: column; gap: 0.6rem; }
.comment-form-row { display: flex; gap: 0.6rem; }
.comment-form-row input { flex: 1; }
.comment-form input, .comment-form textarea {
  font: inherit; color: var(--fg); background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px; padding: 0.5rem 0.65rem;
}
.comment-form input:focus, .comment-form textarea:focus { outline: none; border-color: var(--accent); }
.comment-form textarea { min-height: 6rem; resize: vertical; }
.comment-form .btn { align-self: flex-start; }
.comment-hint { color: var(--muted); font-size: 0.82rem; margin: 0; min-height: 1.2em; }

/* ---- 关于我 ---- */
.about-head { display: flex; gap: 1.5rem; align-items: center; margin-bottom: 1.5rem; }
.about-avatar { width: 6rem; height: 6rem; border-radius: 50%; object-fit: cover; flex-shrink: 0; border: 1px solid var(--border); }
.about-name { margin: 0; font-size: 1.7rem; line-height: 1.3; }
.about-tagline { margin: 0.4rem 0 0; color: var(--muted); }
.about-meta { margin: 0.5rem 0 0; color: var(--faint); font-size: 0.85rem; }
.about-meta .sep { margin: 0 0.4rem; }
.about-links { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1.5rem 0; }
.about-link {
  display: inline-flex; align-items: center; gap: 0.4rem;
  border: 1px solid var(--border); border-radius: 999px;
  padding: 0.35rem 0.9rem; font-size: 0.88rem; color: var(--muted);
}
.about-link:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }
.about-link svg { flex-shrink: 0; }
.about-bio { margin-top: 1.5rem; }
.about-skills { margin-top: 2rem; }
@media (max-width: 640px) {
  .about-head { flex-direction: column; align-items: flex-start; gap: 1rem; }
}

/* ---- header：站名后面的站点描述 ---- */
.brand-box { display: flex; align-items: baseline; gap: 0.6rem; min-width: 0; }
.brand-desc {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 640px) {
  .brand-box { max-width: 100%; }
  .brand-desc { font-size: 0.8rem; }
}
