/* ============================================================
   主题系统
   html[data-theme="paper|ink|forest|ocean|plum|mono"]
   html[data-mode="light|dark"]
   变量兜底：JS 未执行时按 纸韵·浅色 渲染
   ============================================================ */

:root {
  --bg: #faf9f7;
  --bg-soft: #f3f1ec;
  --card: #ffffff;
  --fg: #1c1b19;
  --fg-soft: #4a4741;
  --muted: #868079;
  --line: #e7e3db;
  --accent: #a8501f;
  --accent-soft: #fdf0e7;
  --green: #2f9e5f;
  --red: #c8483d;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(28, 27, 25, 0.04), 0 8px 24px -16px rgba(28, 27, 25, 0.18);
  --tok-k: #a626a4;
  --tok-s: #2f8a4f;
  --tok-n: #b45309;
  --tok-f: #2563a8;
  --hero-weight: 600;
  --hero-space: -0.02em;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Noto Sans SC", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Georgia, "Songti SC", "Noto Serif SC", serif;
  color-scheme: light;
}

/* ---- 暗色基座（纸韵 · 深色） ---- */
:root[data-mode="dark"] {
  --bg: #141518;
  --bg-soft: #1b1d21;
  --card: #1b1d21;
  --fg: #e9e6e1;
  --fg-soft: #c3bfb8;
  --muted: #8b857c;
  --line: #2a2c31;
  --accent: #e08a54;
  --accent-soft: #2a1f16;
  --green: #4fc47f;
  --red: #e57368;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -16px rgba(0, 0, 0, 0.6);
  --tok-k: #d6a4e0;
  --tok-s: #8ed49a;
  --tok-n: #e0b57a;
  --tok-f: #86b8e8;
  color-scheme: dark;
}
/* 无 JS 时的系统暗色兜底 */
@media (prefers-color-scheme: dark) {
  :root:not([data-mode]) {
    --bg: #141518;
    --bg-soft: #1b1d21;
    --card: #1b1d21;
    --fg: #e9e6e1;
    --fg-soft: #c3bfb8;
    --muted: #8b857c;
    --line: #2a2c31;
    --accent: #e08a54;
    --accent-soft: #2a1f16;
    --green: #4fc47f;
    --red: #e57368;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -16px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

/* ---- 水墨：纸白墨黑，全衬线，锐角 ---- */
:root[data-theme="ink"] {
  --bg: #fdfcfa;
  --bg-soft: #f2f0eb;
  --card: #ffffff;
  --fg: #14120f;
  --fg-soft: #3a3630;
  --muted: #8a8378;
  --line: #e3ded4;
  --accent: #1c1917;
  --accent-soft: #ece8e0;
  --green: #3d7a52;
  --red: #b23b32;
  --radius: 5px;
  --shadow: 0 1px 0 rgba(20, 18, 15, 0.04), 0 10px 26px -20px rgba(20, 18, 15, 0.3);
  --tok-k: #7a4b8f;
  --tok-s: #2f6b45;
  --tok-n: #8a5a20;
  --tok-f: #2b4f74;
  --sans: "Iowan Old Style", "Palatino Linotype", Georgia, "Songti SC", "Noto Serif SC", serif;
  color-scheme: light;
}
:root[data-theme="ink"][data-mode="dark"] {
  --bg: #0e0e10;
  --bg-soft: #17171a;
  --card: #17171a;
  --fg: #efeee9;
  --fg-soft: #c9c5bc;
  --muted: #7d7a72;
  --line: #26262a;
  --accent: #e6e2d8;
  --accent-soft: #26262a;
  --green: #6cbb8c;
  --red: #e07068;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 26px -20px rgba(0, 0, 0, 0.8);
  --tok-k: #c9a0d8;
  --tok-s: #93cf9f;
  --tok-n: #d9b483;
  --tok-f: #9dbde0;
  color-scheme: dark;
}

/* ---- 苔原：米绿纸面，森林绿，圆角柔和 ---- */
:root[data-theme="forest"] {
  --bg: #f6f8f2;
  --bg-soft: #eaf0e0;
  --card: #ffffff;
  --fg: #1a2318;
  --fg-soft: #3e4a3a;
  --muted: #798471;
  --line: #dee6d3;
  --accent: #2f7a4a;
  --accent-soft: #e5f2e6;
  --green: #2f9e5f;
  --red: #c0553f;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(26, 35, 24, 0.04), 0 10px 28px -18px rgba(47, 122, 74, 0.28);
  --tok-k: #8c5aa0;
  --tok-s: #2c7a4e;
  --tok-n: #a26a1e;
  --tok-f: #2c6f96;
  --sans: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Georgia, "Songti SC", "Noto Serif SC", serif;
  color-scheme: light;
}
:root[data-theme="forest"][data-mode="dark"] {
  --bg: #0e1411;
  --bg-soft: #151d17;
  --card: #151d17;
  --fg: #e5ede4;
  --fg-soft: #bbc7b8;
  --muted: #7c8878;
  --line: #222c26;
  --accent: #6cc088;
  --accent-soft: #16281b;
  --green: #57c47f;
  --red: #e07468;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 28px -18px rgba(0, 0, 0, 0.7);
  --tok-k: #c9a8dc;
  --tok-s: #8fd49f;
  --tok-n: #dfbb85;
  --tok-f: #8fc0e4;
  color-scheme: dark;
}

/* ---- 静海：冷白蓝调，靛蓝强调，干净 ---- */
:root[data-theme="ocean"] {
  --bg: #f4f7fb;
  --bg-soft: #e8eef7;
  --card: #ffffff;
  --fg: #121a25;
  --fg-soft: #384659;
  --muted: #74839a;
  --line: #dce5f0;
  --accent: #2a5aa8;
  --accent-soft: #e4eefb;
  --green: #2c8f6a;
  --red: #c94a45;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(18, 26, 37, 0.04), 0 10px 26px -18px rgba(42, 90, 168, 0.25);
  --tok-k: #8a4bb0;
  --tok-s: #2b7a55;
  --tok-n: #a9670f;
  --tok-f: #1f6fb5;
  color-scheme: light;
}
:root[data-theme="ocean"][data-mode="dark"] {
  --bg: #0a1017;
  --bg-soft: #111a24;
  --card: #111a24;
  --fg: #e2eaf4;
  --fg-soft: #b4c2d4;
  --muted: #76859a;
  --line: #1c2735;
  --accent: #71a7f2;
  --accent-soft: #0f1d2d;
  --green: #4dc095;
  --red: #e57a74;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 10px 26px -18px rgba(0, 0, 0, 0.75);
  --tok-k: #c3a2e6;
  --tok-s: #84d3a8;
  --tok-n: #e6bd8a;
  --tok-f: #8dc2f5;
  color-scheme: dark;
}

/* ---- 暮紫：淡紫纸面，梅色强调，大圆角 ---- */
:root[data-theme="plum"] {
  --bg: #faf7fc;
  --bg-soft: #f2ecf7;
  --card: #ffffff;
  --fg: #1e1822;
  --fg-soft: #493d51;
  --muted: #897d92;
  --line: #e9e0ef;
  --accent: #7d3f91;
  --accent-soft: #f7ebfa;
  --green: #388a63;
  --red: #c4495a;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(30, 24, 34, 0.04), 0 12px 30px -20px rgba(125, 63, 145, 0.3);
  --tok-k: #9b3fa8;
  --tok-s: #2f7f5c;
  --tok-n: #a86a18;
  --tok-f: #3a6aab;
  --serif: "Iowan Old Style", "Palatino Linotype", Georgia, "Songti SC", "Noto Serif SC", serif;
  color-scheme: light;
}
:root[data-theme="plum"][data-mode="dark"] {
  --bg: #130f16;
  --bg-soft: #1b1520;
  --card: #1b1520;
  --fg: #eee7f1;
  --fg-soft: #c7bad0;
  --muted: #8a7d90;
  --line: #29212f;
  --accent: #cd93e2;
  --accent-soft: #241a29;
  --green: #55c08c;
  --red: #e3778a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 12px 30px -20px rgba(0, 0, 0, 0.8);
  --tok-k: #dda8ec;
  --tok-s: #93d8b0;
  --tok-n: #e5c08d;
  --tok-f: #9fbdf0;
  color-scheme: dark;
}

/* ---- 终端：灰阶 + 等宽字，硬边 ---- */
:root[data-theme="mono"] {
  --bg: #f4f4f5;
  --bg-soft: #e7e7ea;
  --card: #ffffff;
  --fg: #18181b;
  --fg-soft: #3f3f46;
  --muted: #77777f;
  --line: #d9d9de;
  --accent: #0a7d4b;
  --accent-soft: #e3f5ec;
  --green: #0a7d4b;
  --red: #c02b2b;
  --radius: 6px;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.05), 0 8px 20px -16px rgba(0, 0, 0, 0.3);
  --tok-k: #8a5fa8;
  --tok-s: #0a7d4b;
  --tok-n: #9a6212;
  --tok-f: #1f6ab0;
  --sans: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --serif: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
:root[data-theme="mono"][data-mode="dark"] {
  --bg: #0b0b0c;
  --bg-soft: #141416;
  --card: #131316;
  --fg: #dcdce0;
  --fg-soft: #a8a8b0;
  --muted: #6f6f78;
  --line: #232327;
  --accent: #4ade80;
  --accent-soft: #12251a;
  --green: #4ade80;
  --red: #f87171;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 8px 20px -16px rgba(0, 0, 0, 0.9);
  --tok-k: #c9a0e0;
  --tok-s: #4ade80;
  --tok-n: #e0bb7a;
  --tok-f: #7cc4f0;
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

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

img { max-width: 100%; display: block; }

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

::selection { background: var(--accent-soft); color: var(--accent); }

/* ============ 布局 ============ */
.wrap { max-width: 760px; margin: 0 auto; padding: 0 22px; }
.wrap-wide { max-width: 1180px; margin: 0 auto; padding: 0 22px; }

header.site {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: saturate(180%) blur(12px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-bottom: 1px solid var(--line);
}
header.site .inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 22px;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand .dot { color: var(--accent); }
.brand-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.brand-avatar {
  flex: 0 0 auto;
  display: block;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-soft);
  border: 1px solid var(--line);
}
.brand-avatar.ph {
  display: grid;
  place-items: center;
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--muted);
  user-select: none;
}
/* 站点描述：站名右侧的一句话，宽度不够先截断、再窄就整条隐藏 */
.brand-desc {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 300px;
  margin-left: -6px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
nav.top { display: flex; gap: 4px; margin-left: auto; align-items: center; flex-wrap: wrap; }nav.top a, nav.top button {
  padding: 6px 11px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--muted);
  background: none;
  border: 0;
  cursor: pointer;
}
nav.top a:hover, nav.top button:hover { color: var(--fg); background: var(--bg-soft); }
nav.top a.active { color: var(--fg); background: var(--bg-soft); }

.avatar-xs { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; border: 1px solid var(--line); }

/* ============ 通用元件 ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 14px;
  cursor: pointer;
  transition: 0.16s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.btn.primary:hover { opacity: 0.86; }
.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, var(--line)); }
.btn.sm { padding: 5px 11px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

input[type="text"], input[type="url"], input[type="email"], textarea, select {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  outline: none;
  transition: 0.16s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}
.tag:hover { background: var(--accent-soft); color: var(--accent); }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.sep-dot::before { content: "·"; margin: 0 7px; color: var(--line); }

/* ============ 首页 ============ */
.hero { padding: 52px 0 30px; }
.hero h1 {
  font-family: var(--serif);
  font-size: 34px;
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin: 0 0 10px;
  font-weight: 600;
}
.hero p { margin: 0; color: var(--muted); font-size: 15px; }

.toolbar { display: flex; gap: 10px; align-items: center; margin: 22px 0 18px; flex-wrap: wrap; }
.toolbar .search { flex: 1; min-width: 180px; position: relative; }
.toolbar .search input { padding-left: 34px; }
.toolbar .search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }

.tagbar { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 26px; align-items: center; }
.tagbar + .tagbar { margin-top: -14px; }
.bar-label { font-size: 12px; color: var(--muted); margin-right: 2px; }
.cat-chip { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
a.cat-chip:hover { filter: brightness(0.96); }

/* 栏目页 */
.tax-section { margin-bottom: 40px; }
.tax-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.tax-head h2 { font-size: 15px; margin: 0; letter-spacing: .02em; }
.tax-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.tax-cell {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--fg-soft); text-decoration: none; font-size: 14px;
  transition: border-color .15s, background .15s;
}
.tax-cell:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.tax-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tax-count {
  flex: 0 0 auto; font-size: 12px; color: var(--muted);
  background: var(--bg-soft); border-radius: 999px; padding: 1px 8px;
}
.tax-cell:hover .tax-count { background: transparent; color: inherit; }


.post-list { display: flex; flex-direction: column; gap: 14px; }

.post-card {
  display: flex;
  gap: 18px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: 0.18s;
  align-items: flex-start;
}
.post-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.post-card .thumb {
  width: 108px; height: 78px; flex: 0 0 108px;
  border-radius: 9px; object-fit: cover; background: var(--bg-soft);
}
.post-card .body { flex: 1; min-width: 0; }
.post-card h2 {
  font-size: 16.5px; margin: 0 0 5px; font-weight: 600; line-height: 1.45;
  letter-spacing: -0.01em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.post-card .excerpt {
  margin: 0 0 8px; color: var(--muted); font-size: 13.5px; line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.post-card .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--muted); }

.pagination { display: flex; gap: 8px; justify-content: center; margin: 34px 0 60px; align-items: center; }
.pagination .page-info { font-size: 13px; color: var(--muted); padding: 0 6px; }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); font-size: 14px; }

/* ============ 文章页 ============ */
.post-head { padding: 46px 0 26px; border-bottom: 1px solid var(--line); margin-bottom: 30px; }
.post-head h1 {
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1.35;
  letter-spacing: -0.02em;
  margin: 0 0 14px;
  font-weight: 600;
}
.post-head .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--muted); }

/* AI 摘要导语 */
.post-lead {
  margin: 0 0 32px;
  padding: 14px 18px 15px;
  border-radius: 10px;
  background: var(--bg-soft);
  border-left: 3px solid color-mix(in srgb, var(--accent) 60%, transparent);
}
.post-lead .lead-tag {
  display: inline-block;
  font-size: 10.5px; font-weight: 600; letter-spacing: .08em;
  color: var(--accent); margin-bottom: 5px;
}
.post-lead p { margin: 0; font-size: 14.5px; line-height: 1.75; color: var(--fg-soft); }
.post-body { font-size: 16px; line-height: 1.85; color: var(--fg-soft); }
.post-body > *:first-child { margin-top: 0; }

/* markdown 排版 */
.md h1, .md h2, .md h3, .md h4 { font-family: var(--serif); color: var(--fg); letter-spacing: -0.01em; line-height: 1.4; }
.md h1 { font-size: 26px; margin: 2em 0 0.7em; }
.md h2 { font-size: 21px; margin: 1.9em 0 0.6em; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.md h3 { font-size: 17.5px; margin: 1.6em 0 0.5em; }
.md h4 { font-size: 15.5px; margin: 1.4em 0 0.4em; }
.md p { margin: 0 0 1.15em; }
.md a { color: var(--accent); border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.md a:hover { border-bottom-color: var(--accent); }
.md ul, .md ol { margin: 0 0 1.15em; padding-left: 1.5em; }
.md li { margin: 0.3em 0; }
.md li > ul, .md li > ol { margin: 0.3em 0; }
.md blockquote {
  margin: 1.4em 0; padding: 2px 0 2px 18px;
  border-left: 3px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  color: var(--muted); font-style: italic;
}
.md blockquote p:last-child { margin-bottom: 0; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 2.2em 0; }
.md img { border-radius: 10px; margin: 1.5em auto; }
.md .md-img { text-align: center; }
.md code {
  font-family: var(--mono); font-size: 0.875em;
  background: var(--bg-soft); padding: 2px 6px; border-radius: 5px;
  color: var(--accent);
  white-space: nowrap;              /* 行内代码不折行，避免 "Ctrl/Cmd + S" 被拆断 */
}
.md pre code, .md .code-block code { white-space: pre; }
.md .code-wrap {
  margin: 1.5em 0; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; background: var(--bg-soft);
}
.md .code-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 12px; border-bottom: 1px solid var(--line);
  font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em;
  font-family: var(--mono);
}
.md .copy-btn {
  background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 11.5px;
  padding: 2px 6px; border-radius: 5px; text-transform: none; letter-spacing: 0;
}
.md .copy-btn:hover { background: var(--card); color: var(--fg); }
.md pre.code-block {
  margin: 0; padding: 14px 16px; overflow-x: auto;
  font-family: var(--mono); font-size: 13px; line-height: 1.7;
  background: transparent; color: var(--fg-soft);
}
.md pre.code-block code { background: none; padding: 0; color: inherit; font-size: inherit; }
.md .table-wrap { overflow-x: auto; margin: 1.5em 0; }
.md table { border-collapse: collapse; width: 100%; font-size: 14px; }
.md th, .md td { border: 1px solid var(--line); padding: 8px 12px; text-align: left; }
.md th { background: var(--bg-soft); font-weight: 600; color: var(--fg); }

/* 高亮 token（随主题切换） */
.tok-k { color: var(--tok-k); }
.tok-s { color: var(--tok-s); }
.tok-c { color: var(--muted); font-style: italic; }
.tok-n { color: var(--tok-n); }
.tok-f { color: var(--tok-f); }

.tag-inline {
  display: inline-block; padding: 0 6px; border-radius: 5px;
  background: var(--accent-soft); color: var(--accent) !important;
  font-size: 0.92em; border: 0 !important;
}

.post-foot { margin: 46px 0 0; padding-top: 22px; border-top: 1px solid var(--line); }

/* ============ 评论 ============ */
.comments { margin: 46px 0 80px; }
.comments h3 { font-size: 16px; margin: 0 0 20px; font-family: var(--serif); }
.cmt { display: flex; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.cmt:first-of-type { border-top: 0; }
.cmt .ava {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%;
  background: var(--bg-soft); display: grid; place-items: center;
  font-size: 13px; color: var(--muted); font-weight: 600; border: 1px solid var(--line);
}
.cmt .main { flex: 1; min-width: 0; }
.cmt .head { display: flex; gap: 8px; align-items: center; font-size: 13px; margin-bottom: 3px; flex-wrap: wrap; }
.cmt .head b { font-weight: 600; font-size: 13.5px; }
.cmt .head .when { color: var(--muted); font-size: 12px; }
.cmt .head .cmt-mail {
  font-size: 12px; color: var(--accent); text-decoration: none;
  border: 1px dashed var(--border, #e3e5e8); border-radius: 5px; padding: 0 6px;
}
.cmt .head .cmt-mail:hover { background: var(--accent-soft, #eef2ff); }
.cmt .text { font-size: 14.5px; line-height: 1.7; color: var(--fg-soft); white-space: pre-wrap; word-break: break-word; }
.cmt .acts { margin-top: 5px; display: flex; gap: 10px; font-size: 12px; color: var(--muted); }
.cmt .acts button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; font-size: 12px; }
.cmt .acts button:hover { color: var(--accent); }
.cmt .replies { margin-top: 6px; padding-left: 14px; border-left: 2px solid var(--line); }
.cmt .replies .cmt { border-top: 1px solid var(--line); }
.cmt .replies .cmt:first-child { border-top: 0; }
.badge-owner {
  font-size: 10.5px; padding: 1px 6px; border-radius: 5px;
  background: var(--accent); color: #fff; line-height: 1.6; font-weight: 600;
}
.cmt-form { display: grid; gap: 9px; margin-top: 22px; padding: 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.cmt-form .row { display: flex; gap: 9px; flex-wrap: wrap; }
.cmt-form .row input { flex: 1; min-width: 130px; }
.cmt-form textarea { min-height: 84px; resize: vertical; }
.cmt-form .foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* ============ 编辑器 ============ */
.editor-page { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.editor-top {
  display: flex; align-items: center; gap: 8px; padding: 9px 16px;
  border-bottom: 1px solid var(--line); background: var(--card); flex: 0 0 auto; flex-wrap: wrap;
}
.editor-top .title-input {
  flex: 1; min-width: 160px; border: 0; background: none; padding: 4px 2px;
  font-size: 18px; font-weight: 600; font-family: var(--serif); letter-spacing: -0.01em;
}
.editor-top .title-input::placeholder { color: var(--muted); opacity: .6; font-weight: 500; }
.editor-top .title-input:focus { box-shadow: none; border: 0; }
.editor-top #btn-save { padding: 6px 16px; }
.editor-body { flex: 1; display: flex; min-height: 0; }
.pane { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pane.left { border-right: 1px solid var(--line); }
#md-input {
  flex: 1; width: 100%; border: 0; border-radius: 0; resize: none; padding: 26px 32px;
  font-family: var(--mono); font-size: 14.5px; line-height: 1.85; background: var(--bg); outline: none;
  caret-color: var(--accent); tab-size: 2;
}
#md-input::placeholder { color: color-mix(in srgb, var(--muted) 62%, transparent); }
#md-input:focus { box-shadow: none; }
.preview { flex: 1; overflow-y: auto; padding: 26px 32px; }

/* 设置侧栏：靠左（DOM 顺序不变，用 order 把整列翻到最前） */
.editor-side {
  order: -1;
  flex: 0 0 292px;
  border-left: 0;
  border-right: 1px solid var(--line);
  background: var(--card);
  padding: 16px 14px 16px;
  overflow-y: auto; display: flex; flex-direction: column; gap: 12px;
  scrollbar-width: thin;
  overscroll-behavior: contain;
}
.editor-side input[type="text"], .editor-side textarea, .editor-side select {
  padding: 7px 10px; border-radius: 8px; font-size: 13px; background: var(--bg);
}
/* 侧栏内容不许被压扁：超长时整列滚动，而不是把站点设置卡片挤成半截 */
.editor-side > * { flex: 0 0 auto; }
.editor-side textarea { line-height: 1.6; }
.editor-side .field { gap: 6px; }
.editor-side .field label { font-size: 11.5px; letter-spacing: .01em; }
.editor-side .btn.sm { padding: 6px 10px; }

/* 分组小标题：细线拉到右边 */
.side-sec {
  display: flex; align-items: center; gap: 9px;
  margin: 2px 0 -3px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
}
.side-sec::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.side-sec + .field, .side-sec + .site-box { margin-top: 0; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 500; }

/* 站点设置：折叠卡片 */
.site-box {
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg);
  overflow: hidden; box-sizing: border-box;
}
.site-box > summary {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  font-size: 12.5px; font-weight: 500; color: var(--fg);
  cursor: pointer; list-style: none; user-select: none; transition: background .16s;
}
.site-box > summary::-webkit-details-marker { display: none; }
.site-box > summary:hover { background: var(--bg-soft); }
.site-box > summary .ico { width: 14px; height: 14px; flex: 0 0 auto; color: var(--muted); }
.site-box > summary .chev {
  width: 13px; height: 13px; margin-left: auto; flex: 0 0 auto;
  color: var(--muted); transition: transform .18s ease;
}
.site-box[open] > summary { background: var(--bg-soft); border-bottom: 1px solid var(--line); }
.site-box[open] > summary .chev { transform: rotate(90deg); }
.site-body { padding: 12px; display: flex; flex-direction: column; gap: 11px; }
.site-box textarea, .site-box input, .site-box select { width: 100%; box-sizing: border-box; }
.site-box textarea { resize: vertical; min-height: 62px; font: inherit; font-size: 13px; }
.side-hint, .site-hint { font-size: 11.5px; line-height: 1.5; color: var(--muted); opacity: .85; }
.side-save { width: 100%; justify-content: center; margin-top: 1px; }

/* 底部操作条 */
.side-foot {
  margin-top: auto; display: flex; gap: 8px; padding-top: 12px;
  border-top: 1px solid var(--line);
}
.side-foot .side-view { flex: 1; justify-content: center; }
/* 桌面不显示：抽屉开关与遮罩只在窄屏生效 */
.side-toggle, .side-mask { display: none; }
.switch { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; user-select: none; }
.switch input { width: auto; margin: 0; accent-color: var(--accent); }
.save-state { font-size: 12px; color: var(--muted); margin-left: auto; display: flex; align-items: center; gap: 6px; }
.save-state .pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.save-state.saving .pulse { background: var(--accent); animation: pulse 0.8s infinite; }
.save-state.error .pulse { background: var(--red); }
@keyframes pulse { 50% { opacity: 0.25; } }

.drop-hint {
  position: fixed; inset: 0; z-index: 200; display: none; place-items: center;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(3px);
  border: 2px dashed var(--accent); font-size: 17px; color: var(--accent); font-weight: 600;
}
.drop-hint.on { display: grid; }

.cat-list { display: flex; flex-direction: column; gap: 3px; }
.cat-item {
  padding: 8px 10px; border-radius: 8px; font-size: 13px; color: var(--fg-soft);
  border: 1px solid transparent; cursor: pointer; display: flex; justify-content: space-between; gap: 8px;
}
.cat-item:hover { background: var(--bg-soft); }
.cat-item.active { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.cat-item .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-item .flag { font-size: 10px; color: var(--muted); flex: 0 0 auto; }

/* ============ 友链 ============ */
.friend-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(258px, 1fr)); gap: 13px; margin-bottom: 60px; }
.friend-card {
  display: flex; gap: 12px; padding: 14px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--card); align-items: center; transition: 0.18s;
}
.friend-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.friend-card .fav { width: 38px; height: 38px; border-radius: 10px; object-fit: cover; flex: 0 0 38px; background: var(--bg-soft); }
.friend-card .info { min-width: 0; flex: 1; }
.friend-card .nm { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.friend-card .ds { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: 0 0 7px; }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 18%, transparent); }
.dot.off { background: var(--muted); opacity: 0.45; }

/* ============ 登录页 ============ */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-box { text-align: center; max-width: 340px; width: 100%; }
.login-box h1 { font-family: var(--serif); font-size: 26px; margin: 0 0 8px; }
.login-box p { color: var(--muted); font-size: 14px; margin: 0 0 26px; }
.gh-btn {
  display: inline-flex; align-items: center; gap: 9px; padding: 11px 22px;
  border-radius: 10px; background: var(--fg); color: var(--bg); font-size: 14px; font-weight: 500;
}
.gh-btn:hover { opacity: 0.88; color: var(--bg); }

/* ============ 响应式 ============ */
@media (max-width: 1080px) {
  .brand-desc { max-width: 180px; }
}
@media (max-width: 860px) {
  .brand-desc { display: none; }
  .editor-body { flex-direction: column; }
  .pane.left { border-right: 0; border-bottom: 1px solid var(--line); flex: 0 0 45%; }
  /* 侧栏改成抽屉，手机上也能改站点设置 */
  .editor-side {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 130;
    width: min(86vw, 330px); flex: 0 0 auto;
    transform: translateX(-101%);
    transition: transform .24s cubic-bezier(.4, 0, .2, 1);
    box-shadow: 28px 0 70px -34px rgba(0, 0, 0, .6);
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  .editor-side.open { transform: none; }
  .side-mask {
    display: block; position: fixed; inset: 0; z-index: 125;
    background: rgba(0, 0, 0, .36); opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  .side-mask.on { opacity: 1; pointer-events: auto; }
  .side-toggle { display: inline-flex; }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .hero { padding: 34px 0 22px; }
  .hero h1 { font-size: 27px; }
  .post-card .thumb { width: 74px; height: 60px; flex-basis: 74px; }
  .post-head h1 { font-size: 24px; }
  .post-body { font-size: 15.5px; }
  .wrap, .wrap-wide { padding: 0 16px; }
  header.site .inner { padding: 0 44px 0 14px; height: 52px; gap: 10px; position: relative; }
  .brand { font-size: 15px; gap: 7px; }
  .brand-avatar { width: 23px; height: 23px; }
  .brand-name { max-width: 30vw; }
  /* 窄屏导航单行横向滚动，风格按钮固定在右侧不随滚动 */
  nav.top {
    gap: 0; flex-wrap: nowrap; overflow-x: auto; min-width: 0;
    /* flex-end 在内容溢出时会让整排向左溢出、压到品牌名上，改用 flex-start */
    justify-content: flex-start; scrollbar-width: none;
    padding-right: 0;
    margin-left: auto;
  }
  nav.top::-webkit-scrollbar { display: none; }
  /* 右端渐隐，暗示还能横向滑；放在按钮左边，别盖住调到色板 */
  header.site .inner::after {
    content: '';
    position: absolute;
    right: 42px;
    top: 0;
    bottom: 0;
    width: 20px;
    pointer-events: none;
    background: linear-gradient(to right, transparent, var(--bg));
  }
  nav.top a, nav.top button { padding: 5px 6px; font-size: 12.5px; flex: 0 0 auto; }
  nav.top .theme-btn {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    width: 26px; height: 26px; padding: 0; margin: 0; z-index: 2;
  }
  nav.top .theme-btn svg { width: 15px; height: 15px; }
  .editor-top { padding: 8px 12px; gap: 8px; }
  #md-input, .preview { padding: 16px; }
}

/* ============ 归档 / 时间线 ============ */
.arch-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-bottom: 28px;
}
.seg {
  display: inline-flex; padding: 2px; gap: 2px;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 999px;
}
.seg button {
  border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 13px; line-height: 1;
  padding: 7px 15px; border-radius: 999px; cursor: pointer; transition: .15s;
}
.seg button:hover { color: var(--fg); }
.seg button.on { background: var(--card); color: var(--fg); box-shadow: var(--shadow); }

.year-filter { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.year-filter .tag { cursor: pointer; }
.tag.on { background: var(--accent-soft); color: var(--accent); }
.tag-n { margin-left: 5px; font-size: 10.5px; opacity: .6; }
.lnk { color: var(--accent); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--accent) 32%, transparent); }
.lnk:hover { border-bottom-color: var(--accent); }
.hero-sub b, #hero-sub b { color: var(--fg); font-weight: 600; }

/* 公共小 chip */
.chi {
  font-size: 11px; padding: 1px 6px; border-radius: 999px;
  background: var(--bg-soft); color: var(--muted); line-height: 1.6;
}
.chi.cat { background: var(--accent-soft); color: var(--accent); }
.tl-dim { color: var(--muted); font-size: 12px; }
.tl-dim + .tl-dim::before { content: '·'; margin-right: 6px; }

/* ---- 时间线 ---- */
.timeline { position: relative; padding-left: 20px; }
.timeline::before {
  content: ''; position: absolute; left: 4px; top: 10px; bottom: 10px;
  width: 1px; background: var(--line);
}
.tl-year { position: relative; }
.tl-yhead { display: flex; align-items: baseline; gap: 10px; margin: 30px 0 6px; }
.tl-year:first-child .tl-yhead { margin-top: 0; }
.tl-yhead b { font-family: var(--serif); font-size: 22px; font-weight: 600; letter-spacing: .01em; }
.tl-yhead::before {
  content: ''; position: absolute; left: -20px; top: 9px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 3px var(--bg);
}

.tl-month { margin-bottom: 6px; }
.tl-mlabel {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--muted); letter-spacing: .04em;
  margin: 12px 0 4px;
}
.tl-mlabel .tiny { opacity: .75; }

.tl-items { display: flex; flex-direction: column; }
.tl-item {
  position: relative; display: flex; gap: 12px; align-items: flex-start;
  padding: 7px 10px; margin: 0 -10px 1px; border-radius: 9px;
  text-decoration: none; color: inherit; transition: background .15s;
}
.tl-item::before {
  content: ''; position: absolute; left: -18px; top: 15px;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--muted); opacity: .4;
  transition: background .15s, transform .15s, opacity .15s;
}
.tl-item:hover { background: var(--bg-soft); }
.tl-item:hover::before { background: var(--accent); opacity: 1; transform: scale(1.4); }
.tl-day {
  flex: 0 0 40px; font-family: var(--mono);
  font-size: 11.5px; color: var(--muted); padding-top: 4px;
}
.tl-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.tl-title { font-size: 15px; font-weight: 500; color: var(--fg); line-height: 1.5; }
.tl-item:hover .tl-title { color: var(--accent); }
.tl-meta {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 12px; color: var(--muted);
}

/* ---- 紧凑归档 ---- */
.arch-year { margin-bottom: 30px; }
.arch-yhead {
  display: flex; align-items: baseline; gap: 10px;
  padding-bottom: 7px; margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.arch-yhead b { font-family: var(--serif); font-size: 19px; font-weight: 600; }
.arch-month { margin-bottom: 12px; }
.arch-mlabel { font-size: 12px; color: var(--muted); margin-bottom: 3px; letter-spacing: .04em; }
.arch-rows { display: flex; flex-direction: column; }
.arch-row {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 9px; margin: 0 -9px; border-radius: 8px;
  text-decoration: none; color: var(--fg-soft); transition: background .15s;
}
.arch-row:hover { background: var(--bg-soft); color: var(--fg); }
.arch-day { flex: 0 0 42px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.arch-title { flex: 1; min-width: 0; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arch-row:hover .arch-title { color: var(--accent); }
.arch-side { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }

@media (max-width: 560px) {
  .arch-bar { margin-bottom: 20px; }
  .arch-side .chi { display: none; }
  .tl-day, .arch-day { flex-basis: 36px; }
}

/* ============ 风格切换器 ============ */
body { transition: background-color .26s ease, color .26s ease; }

.theme-btn {
  display: grid; place-items: center;
  width: 30px; height: 30px; padding: 0;
  border: 0; border-radius: 8px; background: none;
  color: var(--muted); cursor: pointer; transition: .16s;
}
.theme-btn:hover, .theme-btn[aria-expanded="true"] { color: var(--fg); background: var(--bg-soft); }
.theme-btn svg { width: 16px; height: 16px; }

.theme-pop {
  position: fixed; z-index: 200; width: 274px; max-width: calc(100vw - 24px);
  padding: 13px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--card); box-shadow: 0 18px 48px -18px rgba(0, 0, 0, .38);
  opacity: 0; transform: translateY(-6px) scale(.98); pointer-events: none;
  transition: opacity .16s ease, transform .16s ease;
}
.theme-pop.on { opacity: 1; transform: none; pointer-events: auto; }
.tp-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--muted); letter-spacing: .04em; margin-bottom: 9px;
}
.tp-head b { font-size: 12.5px; font-weight: 600; color: var(--fg); letter-spacing: 0; }
.tp-close { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 0 2px; }
.tp-close:hover { color: var(--fg); }

.tp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.tp-item {
  display: flex; flex-direction: column; gap: 5px; padding: 7px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
  cursor: pointer; text-align: left; font: inherit; transition: .14s;
}
.tp-item:hover { border-color: var(--muted); }
.tp-item.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.tp-item.on .tp-name::after { content: '✓'; margin-left: 5px; color: var(--accent); font-size: 11px; }
.tp-sw {
  display: flex; height: 21px; border-radius: 6px; overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
}
.tp-sw i { flex: 1; }
.tp-name { font-size: 12.5px; font-weight: 600; color: var(--fg); line-height: 1.3; }
.tp-desc { font-size: 10.5px; color: var(--muted); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tp-modes { display: flex; gap: 3px; margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--line); }
.tp-modes button {
  flex: 1; padding: 6px 0; border: 1px solid transparent; border-radius: 8px;
  background: var(--bg-soft); color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; transition: .14s;
}
.tp-modes button:hover { color: var(--fg); }
.tp-modes button.on { background: var(--card); border-color: var(--line); color: var(--fg); box-shadow: var(--shadow); }

.tp-tip { font-size: 10.5px; color: var(--muted); margin-top: 8px; text-align: center; opacity: .8; }

@media (max-width: 640px) {
  .theme-pop { width: 260px; padding: 11px; }
}

/* ============ 站点头像设置 ============ */
.ava-row { display: flex; gap: 11px; align-items: center; }
.ava-drop {
  position: relative;
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1.5px dashed var(--line);
  background: var(--bg-soft);
  display: grid;
  place-items: center;
  cursor: pointer;
  overflow: hidden;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  transition: border-color .16s, background-color .16s, color .16s;
}
.ava-drop:hover { border-color: var(--muted); color: var(--fg); }
.ava-drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.ava-drop.busy { opacity: .5; pointer-events: none; }
.ava-drop img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ava-note { font-size: 11.5px; color: var(--muted); line-height: 1.55; }
.ava-note small { display: block; margin-top: 2px; opacity: .82; }
#site-avatar { width: 100%; min-width: 0; font-size: 13px; }
.ava-btns { display: flex; gap: 6px; }
.ava-btns .btn { flex: 1; justify-content: center; }
