/* ============================================================
   设计概念：「诗页（留白）」—— 文字浮在屏幕正中，四周大量留白
   浅色 = 暖纸；深色 = 夜读。两者皆为"氛围"，非简单反色。
   不用红、线极少、留白是均匀的呼吸（非边距叠加的空洞）。
   ============================================================ */

/* ---------- 浅色：暖纸 ---------- */
:root {
  --bg: oklch(0.965 0.020 95);
  --text: oklch(0.27 0.022 75);
  --ink-soft: oklch(0.45 0.020 75);
  --muted: oklch(0.55 0.015 75);
  --line: oklch(0.90 0.018 90);
  --brand: oklch(0.45 0.075 256);
  --brand-soft: oklch(0.94 0.030 256);
  --code-bg: oklch(0.24 0.01 80);
  --code-fg: oklch(0.96 0 0);
  --code-inline-bg: oklch(0.93 0.01 90);
  --th-bg: oklch(0.96 0.012 95);
  --serif: "Noto Serif SC", "Songti SC", "STSong", Georgia, serif;
  --sans: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --measure: 44em;        /* 正文阅读宽度（诗页要窄、留白多） */
  --rail-extra: 18rem;    /* 正文两侧给目录/导航的余量 */
  --card-soft: oklch(0.95 0.015 95);  /* 列表轻卡片底（比纸深一档） */
}

/* ---------- 深色：夜读 ---------- */
[data-theme="dark"] {
  --bg: oklch(0.16 0.014 95);
  --text: oklch(0.91 0.012 95);
  --ink-soft: oklch(0.78 0.012 95);
  --muted: oklch(0.62 0.012 95);
  --line: oklch(0.28 0.010 95);
  --brand: oklch(0.72 0.10 255);
  --brand-soft: oklch(0.22 0.05 255);
  --code-bg: oklch(0.12 0.01 95);
  --code-fg: oklch(0.92 0.005 95);
  --code-inline-bg: oklch(0.30 0.01 95);
  --th-bg: oklch(0.26 0.008 95);
  --card-soft: oklch(0.22 0.012 95);
}

*, *::before, *::after { transition: background-color .25s ease, border-color .25s ease, color .25s ease, fill .25s ease; }
* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); line-height: 1.75; font-size: 16px; padding-bottom: 3rem; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--brand-soft); color: var(--text); }

/* ============================================================
   顶部极轻导航条（不画线，靠留白分隔）
   ============================================================ */
.topnav { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between; gap: 16px; max-width: calc(var(--measure) + var(--rail-extra)); margin: 0 auto; padding: 18px 24px; background: color-mix(in oklch, var(--bg) 82%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transition: padding .3s ease, background .3s ease; }
.topnav.scrolled { padding-top: 11px; padding-bottom: 11px; background: color-mix(in oklch, var(--bg) 90%, transparent); }
.topnav .brand { font-family: var(--serif); font-weight: 700; font-size: 18px; color: var(--text); cursor: pointer; }
.topnav .brand:hover { text-decoration: none; }
.topnav .nav-right { display: flex; align-items: center; gap: 20px; }
.topnav .nav-right a { color: var(--ink-soft); font-size: 14px; }
.topnav .nav-right a:hover { color: var(--brand); text-decoration: none; }
.topnav .nav-right a.active { color: var(--brand); }
.topnav .nav-right a.primary { color: var(--brand); background: var(--brand-soft); padding: 6px 14px; border-radius: 999px; font-weight: 600; }
.topnav .nav-right a.primary:hover { color: var(--brand); text-decoration: none; }
.topnav .nav-right .visitors { color: var(--muted); font-size: 12px; letter-spacing: .3px; }

/* ============================================================
   首页：一句引言 + 时间倒序纯文字清单（无线、无卡片、无月份分组）
   ============================================================ */
.lede { max-width: var(--measure); margin: 0 auto; padding: 9vh 24px 6vh; text-align: center; }
.lede .kicker { font-family: var(--serif); font-weight: 700; font-size: clamp(22px, 3vw, 30px); line-height: 1.5; margin: 0; color: var(--text); }
.lede .sub { margin: 16px 0 0; color: var(--muted); font-size: 14px; letter-spacing: .3px; }

.home-wrap { max-width: var(--measure); margin: 0 auto; padding: 0 24px 16vh; }

/* 标签筛选：顶部一行极轻文字链接，不进侧栏 */
.filters { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 30px; }
.filters .tag.filter { font-size: 13px; padding: 2px 0; margin: 0; background: none; color: var(--muted); }
.filters .tag.filter:hover { color: var(--brand); background: none; }
.filters .tag.filter.active { color: var(--brand); font-weight: 600; }

/* 文章清单 */
.post-list { display: flex; flex-direction: column; gap: 14px; }
.post-card { display: block; color: inherit; text-decoration: none; padding: 20px 24px; border-radius: 12px; background: transparent; border: 1px solid transparent; transition: background .18s, border-color .18s, transform .18s, box-shadow .18s; }
.post-card:hover { text-decoration: none; background: color-mix(in oklch, var(--bg) 82%, var(--ink-soft) 6%); border-color: color-mix(in oklch, var(--ink-soft) 14%, transparent); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(20,30,28,.05); }
[data-theme="dark"] .post-card:hover { background: color-mix(in oklch, var(--bg) 70%, var(--ink-soft) 10%); border-color: color-mix(in oklch, var(--ink-soft) 22%, transparent); }
.post-card h2 { font-family: var(--serif); font-weight: 700; font-size: 21px; line-height: 1.45; margin: 0 0 9px; text-wrap: balance; transition: color .15s; }
.post-card:hover h2 { color: var(--brand); }
.post-card .excerpt { margin: 0; color: var(--ink-soft); font-size: 14.5px; line-height: 1.78; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post-card .post-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.post-card .date { color: var(--muted); font-size: 12px; letter-spacing: .3px; font-variant-numeric: tabular-nums; }
.post-card .tag { font-size: 11.5px; padding: 2px 9px; margin: 0; }
.post-card .views { margin-left: auto; }

/* 阅读量（弱化） */
.views { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.views svg { width: 13px; height: 13px; opacity: .7; }

/* 标签药丸（文章内/筛选） */
.tag { display: inline-block; font-size: 12px; padding: 3px 11px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); margin: 3px 6px 3px 0; }
.tag:hover { text-decoration: none; }
.tag.filter { cursor: pointer; }

/* ============================================================
   阅读页：正文真正居中、衬线、宽松行距；无首字下沉
   ============================================================ */
.reader { max-width: var(--measure); margin: 0 auto; padding: 7vh 24px 14vh; }
.reader h1#r-title { font-family: var(--serif); font-weight: 700; font-size: clamp(26px, 3.4vw, 34px); line-height: 1.35; margin: 0 0 14px; }
.reader .meta { color: var(--muted); font-size: 13px; margin-bottom: 36px; }

.article-body { font-family: var(--serif); font-size: 17px; line-height: 1.9; color: var(--text); }
.article-body > *:first-child { margin-top: 0; }
.article-body p { margin: 1.1em 0; }
.article-body h1, .article-body h2, .article-body h3, .article-body h4 { font-family: var(--serif); line-height: 1.4; margin: 1.7em 0 .6em; scroll-margin-top: 88px; }
.article-body h1 { font-size: 28px; }
.article-body h2 { font-size: 24px; }
.article-body h3 { font-size: 20px; }
.article-body h4 { font-size: 18px; }
.article-body ul, .article-body ol { margin: 1.1em 0; padding-left: 1.6em; }
.article-body li { margin: .4em 0; }
.article-body blockquote { margin: 1.6em 0; padding: 4px 0 4px 18px; border-left: 2px solid var(--line); color: var(--ink-soft); font-style: italic; }
.article-body pre { background: var(--code-bg); color: var(--code-fg); padding: 16px; border-radius: 8px; overflow: auto; font-size: 14px; }
.article-body code { background: var(--code-inline-bg); padding: 2px 6px; border-radius: 5px; font-size: .9em; }
.article-body pre code { background: transparent; padding: 0; color: inherit; }
.article-body a { text-decoration: underline; }
.article-body img { max-width: 100%; border-radius: 8px; margin: 20px 0; }
.article-body hr { border: none; border-top: 1px solid var(--line); margin: 2.4em 0; }
.article-body table { border-collapse: collapse; width: 100%; margin: 1.5em 0; font-size: 15px; }
.article-body th, .article-body td { border: 1px solid var(--line); padding: 9px 12px; text-align: left; }
.article-body th { background: var(--th-bg); }

/* 右侧目录：固定、垂直居中、不占栅格、极淡线；仅宽屏显示 */
.toc { position: fixed; top: 50%; transform: translateY(-50%); left: calc(50% + 22em + 2rem); width: 15rem; max-height: 72vh; overflow: auto; }
.toc-title { font-size: 11px; letter-spacing: 2px; color: var(--muted); margin-bottom: 10px; font-weight: 600; }
#toc-nav a { display: block; font-size: 13px; line-height: 1.55; color: var(--muted); padding: 4px 0 4px 12px; margin-left: -1px; border-left: 1px solid var(--line); transition: .15s; }
#toc-nav a.lvl-h3 { padding-left: 22px; font-size: 12.5px; }
#toc-nav a:hover { color: var(--brand); text-decoration: none; }
#toc-nav a.active { color: var(--brand); font-weight: 600; border-left-color: var(--brand); }

/* 上一篇 / 下一篇：底部一行极轻文字链接（去卡片） */
.post-nav { display: flex; justify-content: space-between; gap: 16px; margin-top: 9vh; }
.pn-item { display: flex; flex-direction: column; gap: 5px; }
.pn-item.next { text-align: right; }
.pn-item .pn-label { font-size: 12px; letter-spacing: 1px; color: var(--muted); }
.pn-item .pn-title { font-family: var(--serif); font-size: 15px; line-height: 1.5; color: var(--ink-soft); transition: color .15s; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pn-item:hover { text-decoration: none; }
.pn-item:hover .pn-title { color: var(--brand); }

/* ============================================================
   标签页 / 关于
   ============================================================ */
.wrap { max-width: var(--measure); margin: 0 auto; padding: 7vh 24px 14vh; }
.view-title { font-family: var(--serif); font-weight: 700; font-size: 26px; margin: 0 0 28px; }
.tag-stats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 30px; }
.tag.stat { cursor: pointer; font-size: 13px; transition: background .15s; }
.tag.stat:hover { background: oklch(0.90 0.03 256); }
.tag.stat b { color: var(--text); font-weight: 700; margin-left: 4px; }
.tag-group { margin-bottom: 30px; }
.tag-group h3 { font-family: var(--serif); font-size: 18px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.tag-group h3 .count { font-size: 12px; color: var(--muted); font-family: var(--sans); font-weight: 400; }
.tag-item { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 15px 0; border-bottom: 1px solid var(--line); cursor: pointer; color: inherit; text-decoration: none; }
.tag-item:last-of-type { border-bottom: none; }
.tag-item:hover { text-decoration: none; }
.tag-item .title { font-family: var(--serif); font-size: 18px; color: var(--text); transition: color .15s; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-item:hover .title { color: var(--brand); }
.tag-item-meta { display: inline-flex; align-items: center; gap: 12px; flex-shrink: 0; color: var(--muted); }
.tag-item em { font-style: normal; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.about { display: flex; justify-content: center; }
.about-card { text-align: center; padding: 48px 20px; max-width: 32em; }
.avatar { width: 60px; height: 60px; max-width: 38vw; color: var(--brand); }
.avatar svg { width: 100%; height: 100%; display: block; }
.about-card h1 { font-family: var(--serif); font-size: 30px; margin: 24px 0 10px; }
.about-intro { color: var(--ink-soft); font-size: 17px; margin: 0; }

/* 拾穗（收藏 / read later） */
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.spacer { flex: 1; }
.bm-list { display: flex; flex-direction: column; gap: 18px; }
.bm-card { padding: 22px 26px; border-radius: 14px; }
.bm-body { font-family: var(--serif); font-size: 16.5px; line-height: 1.9; color: var(--text); word-break: break-word; white-space: pre-wrap; }
.bm-body.clamp { max-height: 7.5em; overflow: hidden; -webkit-mask-image: linear-gradient(180deg, #000 62%, transparent); mask-image: linear-gradient(180deg, #000 62%, transparent); }
.bm-link { display: inline-block; margin-top: 10px; color: var(--brand); font-size: 13px; line-height: 1.5; word-break: break-all; text-decoration: none; }
.bm-link:hover { text-decoration: underline; }
.bm-toggle { display: block; margin-top: 6px; padding: 0; background: none; border: none; color: var(--brand); font: inherit; font-size: 13px; cursor: pointer; }

/* 首页分区：拾穗为主角，写作为辅 */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin: 0 0 22px; }
.section-title { font-family: var(--serif); font-weight: 700; font-size: 24px; margin: 0; }
.section-title--quiet { font-size: 17px; color: var(--muted); letter-spacing: .5px; }
.section-more { font-size: 13px; color: var(--brand); }
.section-more:hover { text-decoration: none; }
.home-bm { margin-bottom: 9vh; }
.bm-sentinel { height: 1px; }
.home-posts { margin-top: 2vh; }

/* 写作区弱化：纯文字行，去掉卡片底，仅细线分隔 */
.post-list--quiet { gap: 0; }
.post-list--quiet .post-card { background: transparent; border: none; border-bottom: 1px solid var(--line); border-radius: 0; padding: 16px 2px; }
.post-list--quiet .post-card:hover { background: transparent; border-bottom-color: color-mix(in oklch, var(--brand) 35%, transparent); transform: none; box-shadow: none; }
.post-list--quiet .post-card h2 { font-size: 18px; margin-bottom: 6px; }
.post-list--quiet .post-card .excerpt { -webkit-line-clamp: 1; font-size: 13.5px; color: var(--muted); }
.filters--quiet { margin-bottom: 16px; }
.bm-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.bm-date { color: var(--muted); font-size: 12px; letter-spacing: .3px; font-variant-numeric: tabular-nums; }
.bm-del { margin-left: auto; }
.save-form { max-width: 36em; }
.save-form label { margin-top: 18px; }
.save-form input, .save-form textarea { margin-top: 6px; }
.save-actions { display: flex; gap: 12px; align-items: center; margin-top: 22px; }

/* ============================================================
   极轻进入淡入（尊重 reduced-motion）
   ============================================================ */
.reveal { opacity: 0; transform: translateY(8px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }

/* ============================================================
   通用
   ============================================================ */
.btn { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; border: 1px solid var(--line); background: transparent; color: var(--text); padding: 9px 16px; border-radius: 8px; font-size: 14px; transition: .15s; font-family: var(--sans); }
.btn:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { opacity: .92; color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-soft); padding-left: 0; }
.btn.ghost:hover { color: var(--brand); }
.btn.sm { padding: 5px 11px; font-size: 13px; }
input[type=text], textarea, select { width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; font-family: inherit; background: transparent; color: var(--text); transition: border-color .15s; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); }
label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 5px; }

.hidden { display: none !important; }
.empty { color: var(--muted); text-align: center; padding: 30px 10px; font-size: 14px; }

/* 首屏兜底 */
html.is-post #home, html.is-post #home-main { display: none !important; }
html.is-post #reader { display: block !important; }

/* 二级页直接定位：避免刷新/深链时先闪首页 */
html[data-route]:not([data-route="home"]) #home,
html[data-route]:not([data-route="home"]) #home-main { display: none !important; }
html[data-route="bookmarks"] #bookmarks-view { display: block !important; }
html[data-route="save"] #save-view { display: block !important; }
html[data-route="about"] #about-view { display: block !important; }
html[data-route="tags"] #tags-view { display: block !important; }
html[data-route="reader"] #reader { display: block !important; }

/* 固定底部栏：访问计数（不随页面滚动；半透明底+模糊区分，不画线） */
.site-footer { position: fixed; bottom: 0; left: 0; right: 0; z-index: 40; text-align: center; padding: 11px 24px; font-size: 12px; letter-spacing: .3px; color: var(--muted); background: color-mix(in oklch, var(--bg) 86%, transparent); backdrop-filter: blur(8px); }

/* toast */
.toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(10px); background: oklch(0.24 0.012 80); color: #fff; padding: 11px 20px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: .22s; z-index: 60; }
[data-theme="dark"] .toast { background: oklch(0.32 0.01 95); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 1088px) {
  .toc { display: none; }
}
@media (max-width: 640px) {
  .topnav { padding: 16px 20px; }
  .lede { padding: 6vh 20px 4vh; }
  .home-wrap, .reader, .wrap { padding-left: 20px; padding-right: 20px; }
  .post-nav { flex-direction: column; gap: 22px; margin-top: 7vh; }
  .pn-item.next { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}
