/* 半页笔记 · 清爽学院风
   米白纸感 / 墨蓝主色 / 青绿点缀，只用系统字体，不请求任何外部资源 */

:root {
  --bg: #faf8f3;
  --bg-soft: #f2efe8;
  --paper: #fffdf9;
  --ink: #1e2c3b;
  --ink-2: #4c5a68;
  --muted: #8b949d;
  --line: #e8e2d7;
  --navy: #1f3a5f;
  --accent: #2e8b7a;
  --accent-soft: #e6f1ee;
  --warm: #b95c3c;
  --mark: #fff0bd;
  --shadow: 0 1px 2px rgba(30, 44, 59, .04), 0 10px 32px rgba(30, 44, 59, .05);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --serif: Georgia, "Songti SC", "STSong", "Source Han Serif SC", "Noto Serif CJK SC", "SimSun", serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

[data-theme="dark"] {
  --bg: #141a22;
  --bg-soft: #1c242e;
  --paper: #1a222c;
  --ink: #e7edf3;
  --ink-2: #b2bec9;
  --muted: #7d8996;
  --line: #2a3542;
  --navy: #9dc0ea;
  --accent: #61c4ac;
  --accent-soft: #1e3634;
  --warm: #e29576;
  --mark: #4a3d1c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .2), 0 10px 32px rgba(0, 0, 0, .22);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; }
button, input { font: inherit; }
button { cursor: pointer; }
::selection { background: var(--accent-soft); color: var(--ink); }
.wrap { max-width: 768px; margin: 0 auto; padding: 0 28px; }

/* ---------- 顶部 ---------- */
.site-header { border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; gap: 24px; min-height: 82px; }
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; flex-shrink: 0; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--navy); color: var(--bg);
  display: grid; place-items: center;
  font-family: var(--serif); font-size: 19px; font-weight: 600;
  letter-spacing: 0;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text b { font-size: 15.5px; font-weight: 650; letter-spacing: .5px; }
.brand-text small { font-size: 9px; color: var(--muted); letter-spacing: 1.5px; margin-top: 3px; }
.nav { display: flex; align-items: center; gap: 26px; margin-left: auto; }
.nav a { font-size: 14px; color: var(--ink-2); text-decoration: none; padding: 6px 0; position: relative; transition: color .18s; }
.nav a:hover, .nav a.active { color: var(--accent); }
.nav a.active::after {
  content: ""; position: absolute; left: 50%; bottom: -2px; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%; background: var(--accent);
}
.theme-toggle {
  width: 36px; height: 36px; flex-shrink: 0;
  display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--paper); color: var(--ink-2);
  transition: border-color .18s, color .18s, transform .18s;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); transform: rotate(-12deg); }

/* ---------- 首页 hero ---------- */
.hero { padding: 92px 0 60px; }
.hero-kicker { font-size: 11px; letter-spacing: 2.4px; color: var(--accent); font-weight: 600; text-transform: uppercase; }
.hero h1 {
  font-family: var(--serif); font-size: 46px; font-weight: 600;
  line-height: 1.35; letter-spacing: -.5px; margin: 22px 0 20px;
}
.hero-intro { color: var(--ink-2); font-size: 16px; line-height: 1.9; max-width: 540px; margin: 0; }
.hero-stats { display: flex; gap: 0; margin-top: 44px; }
.hero-stats > div { display: flex; flex-direction: column; padding: 0 32px; border-left: 1px solid var(--line); }
.hero-stats > div:first-child { padding-left: 0; border-left: none; }
.hero-stats b { font-family: var(--serif); font-size: 25px; font-weight: 600; line-height: 1.3; }
.hero-stats span { font-size: 11.5px; color: var(--muted); letter-spacing: .5px; margin-top: 2px; }

/* ---------- 列表区 ---------- */
.section-head { display: flex; align-items: center; gap: 16px; margin-bottom: 4px; }
.section-head h2 { font-size: 15px; font-weight: 650; margin: 0; letter-spacing: .5px; white-space: nowrap; }
.section-line { flex: 1; height: 1px; background: var(--line); }
.section-note { font-size: 12px; color: var(--muted); white-space: nowrap; }

.filter-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 22px 0 6px; }
.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: transparent; color: var(--ink-2);
  border-radius: 999px; padding: 5px 13px; font-size: 12.5px; line-height: 1.5;
  transition: background .18s, color .18s, border-color .18s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active { background: var(--navy); border-color: var(--navy); color: var(--bg); }
[data-theme="dark"] .chip.active { color: #141a22; }
.filter-right { display: flex; align-items: center; gap: 12px; }
.search { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 999px; padding: 6px 13px; color: var(--muted); background: var(--paper); }
.search:focus-within { border-color: var(--accent); color: var(--accent); }
.search input { border: none; outline: none; background: transparent; color: var(--ink); width: 176px; font-size: 12.5px; }
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.count { font-size: 12px; color: var(--muted); white-space: nowrap; }
.empty-state { text-align: center; color: var(--muted); font-size: 14px; padding: 56px 0; }

.post-card { padding: 30px 0 28px; border-bottom: 1px solid var(--line); }
.post-card:first-child { padding-top: 22px; }
.post-meta { display: flex; align-items: center; gap: 9px; font-size: 12px; color: var(--muted); letter-spacing: .2px; }
.post-meta .subject { color: var(--accent); font-weight: 600; }
.post-meta .sep { opacity: .55; }
.post-card h2 { font-family: var(--serif); font-size: 24px; font-weight: 600; line-height: 1.45; margin: 11px 0 9px; letter-spacing: -.2px; }
.post-card h2 a { text-decoration: none; transition: color .18s; }
.post-card:hover h2 a { color: var(--accent); }
.excerpt { color: var(--ink-2); font-size: 14.5px; line-height: 1.85; margin: 0; }
.post-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 15px; }
.tags { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.read-more { font-size: 13px; color: var(--accent); text-decoration: none; white-space: nowrap; transition: transform .18s; }
.read-more span { display: inline-block; transition: transform .18s; }
.post-card:hover .read-more span { transform: translateX(4px); }

/* ---------- 内页标题 ---------- */
.page-head { padding: 76px 0 28px; }
.page-head h1 { font-family: var(--serif); font-size: 40px; font-weight: 600; margin: 18px 0 10px; letter-spacing: -.5px; }
.page-head p { color: var(--ink-2); margin: 0; font-size: 15px; }

/* ---------- 归档 ---------- */
.archive-list { margin-top: 18px; padding-bottom: 20px; }
.archive-year { margin-bottom: 42px; }
.year { font-family: var(--serif); font-size: 30px; font-weight: 600; margin: 0 0 18px; }
.year small { font-size: 14px; color: var(--muted); font-family: var(--sans); font-weight: 400; }
.archive-month { margin-bottom: 22px; }
.archive-month h3 { font-size: 12px; color: var(--accent); letter-spacing: 1.5px; font-weight: 600; margin: 0 0 4px; }
.archive-month ul { list-style: none; margin: 0; padding: 0; }
.archive-item { display: grid; grid-template-columns: 46px 1fr auto; align-items: baseline; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.archive-item time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.archive-item a { font-size: 15.5px; text-decoration: none; transition: color .18s; }
.archive-item a:hover { color: var(--accent); }
.archive-subject { font-size: 12px; color: var(--muted); }

/* ---------- 文章正文 ---------- */
.post { padding-top: 52px; }
.back { font-size: 13px; color: var(--muted); text-decoration: none; transition: color .18s; }
.back:hover { color: var(--accent); }
.post-head { margin-top: 34px; }
.post-head h1 { font-family: var(--serif); font-size: 38px; font-weight: 600; line-height: 1.35; letter-spacing: -.5px; margin: 16px 0 12px; }
.post-summary { color: var(--ink-2); font-size: 16px; line-height: 1.85; margin: 0; }
.post-head-line { width: 46px; height: 3px; border-radius: 2px; background: var(--accent); margin: 30px 0 40px; }

.prose { font-size: 16.5px; line-height: 1.95; color: var(--ink); }
.prose > :first-child { margin-top: 0; }
.prose p { margin: 0 0 1.4em; }
.prose h2, .prose h3, .prose h4 { font-family: var(--serif); font-weight: 600; line-height: 1.45; color: var(--ink); }
.prose h2 { font-size: 25px; margin: 2.1em 0 .8em; }
.prose h3 { font-size: 20px; margin: 1.9em 0 .7em; }
.prose h4 { font-size: 17px; margin: 1.6em 0 .6em; }
.prose strong { font-weight: 650; }
.prose em { font-style: italic; }
.prose mark { background: var(--mark); color: inherit; padding: 1px 3px; border-radius: 3px; }
.prose del { color: var(--muted); }
.prose a { color: var(--accent); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: 3px; }
.prose a:hover { text-decoration-color: var(--accent); }
.prose ul, .prose ol { padding-left: 1.5em; margin: 0 0 1.5em; }
.prose li { margin: .42em 0; }
.prose li::marker { color: var(--accent); }
.prose blockquote {
  border-left: 3px solid var(--accent); background: var(--bg-soft);
  margin: 1.8em 0; padding: 14px 20px; border-radius: 0 10px 10px 0;
  color: var(--ink-2); font-size: 15.5px;
}
.prose hr { border: none; border-top: 1px solid var(--line); margin: 2.4em 0; }
.prose code { font-family: var(--mono); font-size: .86em; background: var(--bg-soft); color: var(--navy); padding: 2px 6px; border-radius: 4px; }
.prose pre.code-block {
  position: relative; background: #16212e; color: #e4ecf3;
  padding: 20px 20px 18px; border-radius: 12px; overflow-x: auto;
  font-family: var(--mono); font-size: 13.5px; line-height: 1.75; margin: 1.8em 0;
}
.prose pre.code-block code { background: none; color: inherit; padding: 0; font-size: inherit; }
.prose pre.code-block[data-lang]::before {
  content: attr(data-lang); position: absolute; top: 8px; right: 14px;
  font-size: 10px; letter-spacing: 1px; color: #7f93a7; text-transform: uppercase;
}
.prose .table-wrap { overflow-x: auto; margin: 1.8em 0; }
.prose table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
.prose th, .prose td { border-bottom: 1px solid var(--line); padding: 10px 14px; text-align: left; }
.prose th { background: var(--bg-soft); font-weight: 600; white-space: nowrap; }
.prose img { max-width: 100%; height: auto; border-radius: 10px; display: block; margin: 1.6em auto; }
.prose .task-item { list-style: none; margin-left: -1.2em; }
.task-box { display: inline-grid; place-items: center; width: 15px; height: 15px; border: 1.5px solid var(--muted); border-radius: 4px; margin-right: 8px; font-size: 10px; vertical-align: -1px; }
.task-box.checked { background: var(--accent); border-color: var(--accent); color: #fff; }
.task-item.done { color: var(--muted); }

.post-end { margin-top: 64px; padding-top: 24px; border-top: 1px solid var(--line); }
.post-tags { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-bottom: 28px; }
.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.post-nav a { display: flex; flex-direction: column; gap: 4px; padding: 15px 18px; border: 1px solid var(--line); border-radius: 12px; text-decoration: none; transition: border-color .18s, background .18s; }
.post-nav a:hover { border-color: var(--accent); background: var(--paper); }
.post-nav small { font-size: 11.5px; color: var(--muted); }
.post-nav b { font-size: 14.5px; font-weight: 600; line-height: 1.5; }
.nav-older { text-align: right; align-items: flex-end; }

.about-prose { margin-top: 12px; }
.about-card { margin: 46px 0 10px; padding: 22px 26px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 14px; }
.about-card-title { font-size: 13px; font-weight: 650; color: var(--accent); letter-spacing: .5px; margin-bottom: 10px; }
.about-card ol { margin: 0; padding-left: 1.4em; font-size: 14.5px; color: var(--ink-2); }
.about-card li { margin: .4em 0; }
.about-card code { font-family: var(--mono); font-size: .88em; background: var(--paper); padding: 1px 5px; border-radius: 4px; color: var(--navy); }

.notfound { text-align: center; padding: 120px 0 100px; }
.notfound h1 { font-family: var(--serif); font-size: 34px; font-weight: 600; margin: 18px 0 12px; }
.notfound p { color: var(--ink-2); margin: 0 0 28px; }
.btn { display: inline-block; border: 1px solid var(--navy); color: var(--navy); text-decoration: none; border-radius: 999px; padding: 8px 22px; font-size: 14px; }

/* ---------- 页脚 / 悬浮 ---------- */
.site-footer { margin-top: 96px; padding: 34px 0 54px; border-top: 1px solid var(--line); }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; font-size: 12.5px; color: var(--muted); }
.footer-links a { margin-left: 20px; text-decoration: none; color: var(--ink-2); }
.footer-links a:hover { color: var(--accent); }
.footer-note { font-family: var(--serif); font-size: 12.5px; color: var(--muted); margin-top: 12px; opacity: .8; }
.to-top {
  position: fixed; right: 28px; bottom: 28px; width: 40px; height: 40px;
  border: 1px solid var(--line); border-radius: 50%; background: var(--paper);
  color: var(--ink-2); font-size: 17px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .2s, color .2s, border-color .2s;
}
.to-top.show { opacity: 1; pointer-events: auto; }
.to-top:hover { color: var(--accent); border-color: var(--accent); }
.reading-progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 20; display: none; }
.page-post .reading-progress { display: block; }
.reading-progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .08s linear; }

/* ---------- 移动端 ---------- */
@media (max-width: 640px) {
  .wrap { padding: 0 20px; }
  .header-inner { flex-wrap: wrap; gap: 12px 16px; padding: 16px 0; min-height: 0; }
  .nav { order: 3; width: 100%; margin-left: 0; gap: 24px; justify-content: flex-start; }
  .theme-toggle { margin-left: auto; }
  .hero { padding: 62px 0 44px; }
  .hero h1 { font-size: 34px; margin: 18px 0 16px; }
  .hero-intro { font-size: 15px; }
  .hero-stats { margin-top: 34px; }
  .hero-stats > div { padding: 0 20px; }
  .hero-stats b { font-size: 21px; }
  .filter-bar { flex-direction: column; align-items: stretch; gap: 12px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex-shrink: 0; }
  .filter-right { justify-content: space-between; }
  .search { flex: 1; }
  .search input { width: 100%; }
  .post-card { padding: 25px 0 23px; }
  .post-card h2 { font-size: 21px; }
  .page-head { padding: 54px 0 20px; }
  .page-head h1 { font-size: 32px; }
  .post { padding-top: 36px; }
  .post-head h1 { font-size: 30px; }
  .prose { font-size: 16px; }
  .prose h2 { font-size: 22px; }
  .post-nav { grid-template-columns: 1fr; }
  .nav-older { text-align: left; align-items: flex-start; }
  .archive-item { grid-template-columns: 40px 1fr; gap: 8px; }
  .archive-subject { display: none; }
  .footer-inner { flex-direction: column; align-items: flex-start; gap: 8px; }
  .footer-links a { margin: 0 20px 0 0; }
  .to-top { right: 16px; bottom: 16px; }
  .site-footer { margin-top: 64px; }
}

/* 窄屏稳健性：避免长串文字或 flex 子项把页面撑宽 */
.wrap { min-width: 0; }
.chips, .filter-right, .search, .search input { min-width: 0; max-width: 100%; }
.hero-intro, .excerpt, .post-card h2, .post-head h1, .prose { overflow-wrap: break-word; }
body { overflow-x: clip; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
