/* ===========================================================
 * 主题变量
 * =========================================================== */
:root {
  --bg: #f3f1ec;
  --bg-soft: #efebe4;
  --card: #ffffff;
  --ink: #221f1b;
  --ink-2: #4c473f;
  --muted: #8c857a;
  --faint: #b3aca1;
  --line: #ebe7e0;
  --accent: #bd5a3c;
  --accent-soft: #f8ede8;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(30, 24, 16, .04), 0 12px 32px -20px rgba(30, 24, 16, .22);
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", system-ui, sans-serif;
  --serif: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", Georgia,
    "Times New Roman", serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #121110;
  --bg-soft: #1f1d1a;
  --card: #1a1918;
  --ink: #eceae4;
  --ink-2: #c3bdb1;
  --muted: #9b9488;
  --faint: #756e63;
  --line: #302c28;
  --accent: #e08a68;
  --accent-soft: #2a1e18;
  --shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 14px 34px -22px rgba(0, 0, 0, .9);
}

*,
*::before,
*::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image: radial-gradient(120% 70% at 50% -12%, rgba(255, 255, 255, .7), transparent 62%);
  background-repeat: no-repeat;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color .3s ease, color .3s ease;
}

[data-theme="dark"] body {
  background-image: radial-gradient(120% 70% at 50% -12%, rgba(255, 255, 255, .045), transparent 62%);
}

a { color: inherit; text-decoration: none; }
::selection { background: var(--accent-soft); color: var(--ink); }
button { font: inherit; }

/* ===========================================================
 * 布局：左内容 + 右资料栏
 * =========================================================== */
.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 44px 24px 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 302px;
  gap: 22px;
  align-items: start;
}

.main { min-width: 0; }

.side {
  position: sticky;
  top: 30px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.foot {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 11.5px;
  color: var(--faint);
  letter-spacing: .03em;
  padding: 14px 0 6px;
}

/* ===========================================================
 * 侧栏
 * =========================================================== */
.profile {
  padding: 28px 22px 22px;
  text-align: center;
}

.avatar {
  width: 84px;
  height: 84px;
  border-radius: 26px;
  display: block;
  margin: 0 auto 14px;
  object-fit: cover;
  background: var(--bg-soft);
  box-shadow: 0 10px 22px -14px rgba(30, 24, 16, .55);
}

.avatar-fallback {
  width: 84px;
  height: 84px;
  border-radius: 26px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  background: var(--bg-soft);
  color: var(--muted);
  font-family: var(--serif);
  font-size: 30px;
}

.profile-text { min-width: 0; }

.site-name {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: .08em;
  margin: 0 0 7px;
}

.bio {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--muted);
}

.bio-extra {
  margin: 14px 0 0;
  padding-top: 13px;
  border-top: 1px dashed var(--line);
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--faint);
}

.side-card { padding: 16px 14px 12px; }

.side-title {
  margin: 0 0 8px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .16em;
  color: var(--faint);
}

.list-plain {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.list-plain a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border-radius: 10px;
  font-size: 13px;
  color: var(--ink-2);
  transition: background .16s ease, color .16s ease;
}

.list-plain a:hover { background: var(--bg-soft); color: var(--ink); }

.list-plain .link-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 9px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--ink-2);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background .16s ease, color .16s ease;
}

.list-plain .link-btn:hover { background: var(--bg-soft); color: var(--ink); }
.list-plain .link-btn svg { flex: none; color: var(--muted); }
.list-plain .link-btn:hover svg { color: var(--ink); }
.list-plain svg { flex: none; color: var(--muted); }
.list-plain a:hover svg { color: var(--ink); }

.list-plain .num {
  margin-left: auto;
  font-size: 11px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.list-plain .row-sep {
  height: 1px;
  margin: 6px 9px;
  background: var(--line);
}

.list-plain .chev {
  margin-left: auto;
  display: flex;
  color: var(--faint);
  transition: transform .16s ease, color .16s ease;
}

.list-plain a:hover .chev { color: var(--muted); transform: translateX(2px); }

.list-plain a.is-active {
  color: var(--ink);
  font-weight: 600;
  background: var(--bg-soft);
}

.list-plain a.is-active .num { color: var(--accent); }

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 6px 6px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  color: var(--ink-2);
  transition: .16s ease;
}

.tag-chip:hover { border-color: var(--faint); background: var(--bg-soft); }

.tag-chip.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--card);
}

.tag-chip b {
  font-weight: 400;
  font-size: 10.5px;
  color: var(--faint);
}

.tag-chip.is-active b { color: var(--card); opacity: .7; }

/* ===========================================================
 * 文章列表
 * =========================================================== */
.card-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 22px 26px 12px;
}

.card-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: .04em;
}

.count {
  font-size: 11.5px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.active-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 26px 12px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--accent-soft);
  font-size: 12px;
  color: var(--ink-2);
}

.active-filter[hidden] { display: none; }

.active-filter .lbl { color: var(--muted); }
.active-filter b { font-weight: 600; color: var(--accent); }

.active-filter button {
  margin-left: auto;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  font-size: 11.5px;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.active-filter button:hover { color: var(--ink); }

.post-list {
  list-style: none;
  margin: 0;
  padding: 2px 12px 12px;
  display: flex;
  flex-direction: column;
}

.post-item + .post-item .post-link::before {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  top: 0;
  height: 1px;
  background: var(--line);
}

.post-item { animation: rise .45s both; }

.post-link {
  position: relative;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 17px 14px;
  border-radius: 12px;
  transition: background .16s ease;
}

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

.post-body { min-width: 0; flex: 1; }

.post-title {
  margin: 0 0 5px;
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.55;
  letter-spacing: .005em;
  transition: color .16s ease;
}

.post-link:hover .post-title { color: var(--accent); }

.post-summary {
  margin: 0 0 9px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.cat-pill {
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-soft);
}

.post-meta .tag { color: var(--muted); }

.post-arrow {
  flex: none;
  margin-top: 3px;
  color: var(--faint);
  opacity: 0;
  transform: translateX(-4px);
  transition: .18s ease;
}

.post-link:hover .post-arrow { opacity: 1; transform: translateX(0); }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===========================================================
 * 文章详情
 * =========================================================== */
.article { padding: 34px 40px 32px; }

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
  font-size: 12.5px;
  color: var(--muted);
  transition: color .16s ease;
}

.back:hover { color: var(--ink); }

.article-title {
  margin: 0 0 14px;
  font-family: var(--serif);
  font-size: 27px;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: .01em;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 26px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.prose {
  font-size: 15px;
  line-height: 1.95;
  color: var(--ink-2);
  overflow-wrap: break-word;
}

.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }

.prose h2 {
  margin: 2em 0 .7em;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: .01em;
}

.prose h3 {
  margin: 1.7em 0 .6em;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}

.prose h4 { margin: 1.5em 0 .5em; font-size: 14.5px; color: var(--ink); }
.prose p { margin: 0 0 1.15em; }

.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.prose blockquote {
  margin: 1.5em 0;
  padding: 2px 0 2px 16px;
  border-left: 2px solid var(--accent);
  color: var(--muted);
  font-size: 14.5px;
}

.prose blockquote p:last-child { margin-bottom: 0; }

.prose code {
  font-family: var(--mono);
  font-size: .86em;
  padding: .15em .42em;
  border-radius: 5px;
  background: var(--bg-soft);
  color: var(--ink);
}

.prose pre {
  margin: 1.5em 0;
  padding: 15px 17px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-soft);
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.72;
}

.prose pre code { padding: 0; background: none; font-size: inherit; }

.prose img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.6em auto;
  border-radius: 12px;
}

.prose ul,
.prose ol { margin: 0 0 1.15em; padding-left: 1.35em; }
.prose li { margin: .34em 0; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.4em 0; }

.table-wrap {
  margin: 1.5em 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.prose table {
  width: 100%;
  margin: 1.5em 0;
  border-collapse: collapse;
  font-size: 13px;
}

.table-wrap > table { margin: 0; }

.prose th,
.prose td {
  padding: 8px 11px;
  border: 1px solid var(--line);
  text-align: left;
  word-break: break-word;
}
.prose th { background: var(--bg-soft); font-weight: 600; color: var(--ink); }

.post-nav {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  margin-top: 46px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.post-nav a {
  display: block;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: .16s ease;
}

.post-nav a:hover { border-color: var(--faint); background: var(--bg-soft); }
.post-nav .lbl { display: block; margin-bottom: 4px; font-size: 11px; color: var(--faint); }

.post-nav .ttl {
  display: block;
  font-size: 13px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-nav .next { grid-column: 2; text-align: right; }
.post-nav .empty { visibility: hidden; }

/* ===========================================================
 * 归档
 * =========================================================== */
.archive-body { padding: 4px 18px 20px; }

.year-group { padding: 4px 0 10px; }

.year {
  margin: 12px 8px 6px;
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .12em;
  color: var(--faint);
}

.archive-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  transition: background .16s ease;
}

.archive-row:hover { background: var(--bg-soft); }
.archive-row time { flex: none; font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.archive-row .t { font-size: 13.5px; color: var(--ink); }
.archive-row:hover .t { color: var(--accent); }
.archive-row .c { margin-left: auto; flex: none; font-size: 11px; color: var(--muted); }

/* ===========================================================
 * 二维码弹层
 * =========================================================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal[hidden] { display: none; }

.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(26, 21, 16, .46);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: fade .2s ease both;
}

.modal-card {
  position: relative;
  width: min(318px, 100%);
  padding: 26px 24px 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 30px 70px -24px rgba(0, 0, 0, .5);
  text-align: center;
  animation: pop .22s ease both;
}

.modal-qr {
  display: block;
  width: 200px;
  height: 200px;
  margin: 0 auto 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.modal-title {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 15.5px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: .02em;
}

.modal-note {
  margin: 0;
  font-size: 12px;
  line-height: 1.8;
  color: var(--muted);
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--faint);
  cursor: pointer;
  transition: .16s ease;
}

.modal-close:hover { background: var(--bg-soft); color: var(--ink); }

body.modal-open { overflow: hidden; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===========================================================
 * 空状态 / 加载
 * =========================================================== */
.state {
  padding: 46px 26px 52px;
  text-align: center;
  color: var(--faint);
  font-size: 12.5px;
  line-height: 2;
}

.state code {
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--bg-soft);
  color: var(--ink-2);
}

/* ===========================================================
 * 右下角按钮
 * =========================================================== */
.fab {
  position: fixed;
  right: 22px;
  bottom: 24px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fab button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  color: var(--muted);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: .18s ease;
}

.fab button:hover { color: var(--ink); transform: translateY(-1px); }

.fab .to-top {
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
}

.fab .to-top.show { opacity: 1; pointer-events: auto; transform: translateY(0); }

/* ===========================================================
 * 响应式
 * =========================================================== */
@media (max-width: 960px) {
  .page {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    max-width: 720px;
    padding: 20px 16px 16px;
    gap: 14px;
  }

  /* 手机上：资料卡在最上，文章列表紧跟，其余卡片排到后面 */
  .side { display: contents; }
  .profile { order: 1; }
  .main { order: 2; }
  .side-card { order: 3; }
  .foot { order: 4; }

  .profile { display: flex; align-items: center; gap: 16px; text-align: left; padding: 18px 20px; }
  .avatar, .avatar-fallback { margin: 0; width: 60px; height: 60px; border-radius: 18px; flex: none; }
  .site-name { font-size: 17px; }
  .bio-extra { display: none; }

  .article { padding: 26px 20px; }
  .article-title { font-size: 22px; }
  .prose { font-size: 14.5px; }
  .card-head { padding: 20px 20px 10px; }
  .active-filter { margin: 0 20px 12px; }
  .post-list { padding: 2px 6px 10px; }
  .fab { right: 16px; bottom: 18px; }
}

@media (max-width: 520px) {
  .post-summary { -webkit-line-clamp: 3; }
  .post-nav { grid-template-columns: 1fr; }
  .post-nav .next { grid-column: 1; text-align: left; }
}
