/* ============================================================
   颜色、字体、版心宽度都集中在这里，想换风格改这一段就够了
   ============================================================ */
:root {
  --bg: #fbfcfd;
  --ink: #23262b;
  --muted: #6c727c;
  --accent: #2f5496;      /* 链接色：靛蓝 */
  --rule: #e3e6ea;
  --code-bg: #f2f4f7;

  /* 正文用衬线（西文 Charter/Georgia + 中文宋体），界面文字用无衬线 */
  --serif: "Iowan Old Style", Charter, Georgia, "Noto Serif SC", "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", "STSong", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Noto Sans CJK SC", sans-serif;
  --mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --measure: 58rem;       /* 版心最大宽度 */
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181c;
    --ink: #d8dbe0;
    --muted: #8d939c;
    --accent: #93b1ea;
    --rule: #2b2f36;
    --code-bg: #1e2127;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.85;
  text-autospace: normal;   /* 中英文之间自动留空隙，新浏览器支持，旧的会忽略 */
}

::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}
a:hover { text-decoration-thickness: 2px; }
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.site-header,
main,
.site-footer {
  max-width: var(--measure);
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

/* ---------- 页头 / 页脚 ---------- */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-top: 2.5rem;
  padding-bottom: 3.5rem;
  font-family: var(--sans);
  font-size: 0.9375rem;
}
.site-title {
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}
.site-header nav a {
  color: var(--muted);
  text-decoration: none;
}
.site-header nav a:hover { color: var(--accent); }

.site-footer {
  margin-top: 5rem;
  padding-bottom: 3rem;
  font-family: var(--sans);
  font-size: 0.8125rem;
  color: var(--muted);
}

/* ---------- 订阅页 ---------- */
.feed-label,
.feed-controls,
.copy-status {
  font-family: var(--sans);
  font-size: 0.9375rem;
}
.feed-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.4rem;
}
.feed-controls input,
.feed-controls button {
  padding: 0.65em 0.85em;
  border: 1px solid var(--rule);
  border-radius: 4px;
  font: inherit;
}
.feed-controls input {
  flex: 1 1 20rem;
  min-width: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.875rem;
}
.feed-controls button {
  background: var(--accent);
  color: var(--bg);
  cursor: pointer;
}
.feed-controls :focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.copy-status {
  min-height: 1.85em;
  color: var(--muted);
}

/* ---------- 首页文章列表 ---------- */
.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.post-list li {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 0 1.25rem;
  align-items: baseline;
  padding: 0.5rem 0;
}
.post-list time,
.reading-time {
  font-family: var(--sans);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.post-list .reading-time { display: block; }
.post-list a {
  color: var(--ink);
  font-size: 1.125rem;
  text-decoration: none;
}
.post-list a:hover { color: var(--accent); }
.post-list .summary {
  margin: 0.1rem 0 0;
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--muted);
}
.post-list .empty {
  display: block;
  color: var(--muted);
}

.draft-badge {
  margin-left: 0.6em;
  padding: 0.1em 0.5em;
  border-radius: 3px;
  background: var(--muted);
  color: var(--bg);
  font-family: var(--sans);
  font-size: 0.75rem;
  vertical-align: 0.15em;
}

/* ---------- 文章页 ---------- */
.post-header { margin-bottom: 2.75rem; }
.post-header h1 {
  margin: 0 0 0.5rem;
  font-size: 2.125rem;
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-wrap: balance;     /* 标题折行时尽量两行等长，避免最后一行只剩一个字 */
}
.post-header .subtitle {
  margin: -0.2rem 0 0.7rem;   /* 上边距为负，抵消标题的下边距，让副标题贴着标题 */
  font-size: 1.25rem;
  line-height: 1.45;
  color: var(--muted);
  text-wrap: balance;
}
.post-header time {
  font-family: var(--sans);
  font-size: 0.875rem;
  color: var(--muted);
}

.post-body h2,
.post-body h3,
.post-body h4 {
  margin: 2.2em 0 0.6em;
  line-height: 1.4;
}
.post-body h2 { font-size: 1.4rem; }
.post-body h3 { font-size: 1.2rem; }
.post-body h4 { font-size: 1.0625rem; }

.post-body p,
.post-body ul,
.post-body ol,
.post-body dl,
.post-body blockquote,
.post-body pre,
.post-body table,
.post-body .highlight {
  margin: 0 0 1.2em;
}

.post-body ul,
.post-body ol { padding-left: 1.5em; }
.post-body li + li { margin-top: 0.25em; }

.post-body blockquote {
  padding-left: 1.1em;
  border-left: 3px solid var(--rule);
  color: var(--muted);
}

.post-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.8em auto;
}

.post-body hr {
  width: 4rem;
  margin: 2.8em auto;
  border: 0;
  border-top: 1px solid var(--rule);
}

/* 表格：太宽时在自己内部横向滚动 */
.post-body table {
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 0.9375rem;
}
.post-body th,
.post-body td {
  padding: 0.45em 0.9em;
  border-bottom: 1px solid var(--rule);
  text-align: left;
}
.post-body th {
  font-family: var(--sans);
  font-weight: 600;
}

/* ---------- 代码 ---------- */
code {
  font-family: var(--mono);
  font-size: 0.88em;
}
:not(pre) > code {
  padding: 0.12em 0.35em;
  border-radius: 4px;
  background: var(--code-bg);
}
pre {
  font-family: var(--mono);
  font-size: 0.875rem;
  line-height: 1.6;
}
pre code { font-size: inherit; }

.highlight,
.post-body pre {
  border-radius: 6px;
  background: var(--code-bg);
}
.post-body pre {
  padding: 1em 1.1em;
  overflow-x: auto;
}
.highlight pre {
  margin: 0;
  background: transparent;
}

/* ---------- 脚注 ---------- */
.footnote {
  margin-top: 3.5em;
  font-size: 0.875rem;
  color: var(--muted);
}
.footnote hr {
  width: 100%;
  margin: 0 0 1em;
}

/* ---------- 文章底部导航 ---------- */
.post-footer {
  margin-top: 3.5rem;
  font-family: var(--sans);
  font-size: 0.9375rem;
}

/* ---------- 窄屏 ---------- */
@media (max-width: 34rem) {
  .site-header {
    padding-top: 1.5rem;
    padding-bottom: 2.25rem;
  }
  .post-list li { grid-template-columns: 1fr; }
  .post-header h1 { font-size: 1.7rem; }
  .post-header .subtitle { font-size: 1.125rem; }
}
