/* ============================================================
   李宇哲的主页 · 设计系统 v2
   配色保留原版（暖米白 #FAF9F7 + 陶土橙 #B4532A）
   方向：编辑式个人站 —— Swiss 排版纪律（hairline 分隔 /
   tabular 数字 / 左对齐）+ 暖纸调色板
   对比度：正文 13.6:1 · 次要文字 5.3:1 · 占位 4.6:1（全部达标）
   ============================================================ */

/* ---------- Token ---------- */
:root {
  /* 色板（保留原配色，微调对比度） */
  --bg: #FAF9F7;            /* 暖米白纸感（原版） */
  --surface: #FFFFFF;       /* 卡片表面 */
  --fg: #2D2A26;            /* 暖墨色 */
  --muted: #6E675E;         /* 暖灰褐（原 #8A857D 对比度不足，加深） */
  --faint: #948C80;         /* 占位/极次要文字 */
  --accent: #B4532A;        /* 陶土橙（原版） */
  --accent-strong: #96411F; /* 深陶土，hover/正文链接 */
  --accent-soft: #F3E6DC;   /* 橙调浅底 */
  --line: #E8E4DD;          /* hairline 暖边框 */
  --line-strong: #D3CDC0;   /* 稍强边框（面板输入框） */
  --input-bg: #FBFAF7;
  --ok: #1A7F37;
  --err: #CF222E;
  --code-bg: #F1ECE3;

  /* 形状 */
  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 14px;

  /* 动效：强缓动曲线，统一出口 */
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-quick: cubic-bezier(0.4, 0, 0.2, 1);

  /* 字体 */
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --serif: Georgia, "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --mono: "SF Mono", Consolas, "Courier New", monospace;
  --serif: Georgia, "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --mono: "SF Mono", Consolas, "Courier New", monospace;

  /* 写作页 token（用户设计稿：sage 绿 + 金色；写作/编辑面板专用） */
  --paper: #FAF8F4;          /* 写作页纸感背景（用户稿） */
  --paper-raised: #FFFFFF;   /* 面板表面 */
  --ink: #2B2A28;            /* 写作页正文墨色 */
  --ink-soft: #6B6660;       /* 写作页次要文字 */
  --sage: #7A8B6F;           /* 鼠尾草绿（用户稿主色） */
  --sage-dark: #5E6E54;      /* 深 sage hover */
  --gold: #B8935F;           /* 金色点缀（用户稿） */

  /* 层级（语义化 z-index，不用 999） */
  --z-sticky: 100;
  --z-modal: 200;
  --z-toast: 300;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 阅读进度条（文章页顶部细线） */
.progress-bar {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #C9764E);
  z-index: var(--z-sticky);
  transition: width 0.1s linear;
}

/* ---------- 页头 ---------- */
.site-header {
  max-width: 780px;
  margin: 0 auto;
  padding: 56px 28px 18px;
  display: flex;
  align-items: baseline;
  gap: 14px;
  border-bottom: 1px solid var(--line);
}

.site-title {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--fg);
  text-decoration: none;
  transition: color 0.2s var(--ease);
}
.site-title:hover { color: var(--accent-strong); }

.site-subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  letter-spacing: 0.1em;
}

/* 首页页头右侧操作（融入 flex 行，不用绝对定位） */
.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: center;
}

.write-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border: 1px solid transparent;
  border-radius: 50%;
  text-decoration: none;
  transition: background 0.2s var(--ease), color 0.2s var(--ease),
    transform 0.15s var(--ease);
}
.write-btn:hover { background: var(--accent); color: #fff; }
.write-btn:active { transform: scale(0.94); }
.write-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(180, 83, 42, 0.3);
}

.admin-link {
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 4px 14px;
  transition: color 0.2s var(--ease), background 0.2s var(--ease),
    border-color 0.2s var(--ease);
}
.admin-link:hover {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}
.admin-link:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(180, 83, 42, 0.3);
}

main { max-width: 780px; margin: 0 auto; padding: 32px 28px 24px; }

/* ---------- 首页 ---------- */
.hero {
  padding: 8px 0 24px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}
.hero-title {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.015em;
  line-height: 1.25;
  margin-bottom: 10px;
  text-wrap: balance;
}
.hero p {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.75;
  max-width: 60ch;
}

/* 首页宽容器：卡片自适应屏幕（大屏 3 列 / 中屏 2 列 / 手机 1 列） */
.page-index .site-header,
.page-index main,
.page-index .site-footer {
  max-width: 1060px;
}

/* 文章列表：卡片式（用户指定），克制阴影 + 精致边框 */
.post-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 18px;
}

.post-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: 22px 24px;
  text-decoration: none;
  color: var(--fg);
  box-shadow: 0 1px 3px rgba(45, 42, 38, 0.04);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease),
    border-color 0.25s var(--ease);
}
.post-card:hover {
  transform: translateY(-3px);
  border-color: #D8CFC0;
  box-shadow: 0 10px 28px rgba(45, 42, 38, 0.09);
}
.post-card:active { transform: translateY(-1px); }
.post-card:hover h2 { color: var(--accent-strong); }

.post-card h2 {
  font-size: 1.22rem;
  font-weight: 700;
  letter-spacing: 0.005em;
  line-height: 1.45;
  transition: color 0.2s var(--ease);
  text-wrap: balance;
}

/* 置顶徽标 */
.pin-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border: 1px solid rgba(180, 83, 42, 0.3);
  border-radius: 4px;
  padding: 1px 6px;
  margin-right: 8px;
  vertical-align: 2px;
  letter-spacing: 0.08em;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 8px;
  color: var(--muted);
  font-size: 0.8rem;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.card-excerpt {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.65;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: auto;
}

/* 标签 */
.tag {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-radius: 4px;
  padding: 1px 8px;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  font-family: var(--sans);
  font-weight: 600;
}

/* 标签筛选条 */
.tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 4px 4px;
}
.filter-btn {
  padding: 4px 14px;
  font-size: 0.8rem;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s var(--ease);
}
.filter-btn:hover { color: var(--accent-strong); border-color: var(--accent); }
.filter-btn.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}
.filter-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(180, 83, 42, 0.3);
}

/* 文章计数 */
.post-count {
  color: var(--faint);
  font-size: 0.78rem;
  font-family: var(--mono);
  letter-spacing: 0.05em;
  margin: 18px 4px 0;
}

/* ---------- 文章页 ---------- */
.post h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin: 16px 0 14px;
  text-wrap: balance;
}

.post-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
  margin-bottom: 28px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

/* 目录（TOC） */
.toc {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-m) var(--radius-m) 0;
  padding: 16px 20px;
  margin: 24px 0 28px;
}
.toc-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent-strong);
  margin-bottom: 10px;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toc-title::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid var(--accent-strong);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.18s var(--ease);
}
.toc.collapsed .toc-title::before {
  transform: rotate(90deg);
}
.toc.collapsed ul { display: none; }
.toc ul { list-style: none; padding-left: 0; margin: 0; }
.toc li { margin: 6px 0; font-size: 0.9rem; }
.toc li.toc-h3 {
  padding-left: 18px;
  font-size: 0.84rem;
  margin: 4px 0;
}
.toc a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.18s var(--ease);
  border-left: 2px solid transparent;
  padding-left: 10px;
  margin-left: -12px;
}
.toc a:hover { color: var(--accent-strong); }
.toc a.active {
  color: var(--accent-strong);
  border-left-color: var(--accent);
  font-weight: 600;
}
@media (prefers-reduced-motion: reduce) {
  .toc-title::before { transition: none; }
  .toc a { transition: none; }
}
@media (max-width: 480px) {
  .toc { padding: 12px 14px; margin: 18px 0 22px; }
  .toc li { font-size: 0.85rem; }
  .toc li.toc-h3 { padding-left: 14px; }
}

.post-body {
  font-size: 1.03rem;
  line-height: 1.85;
  max-width: 68ch;
  text-wrap: pretty;
}

.post-body h2 {
  font-size: 1.32rem;
  font-weight: 700;
  margin: 36px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
  letter-spacing: -0.005em;
  scroll-margin-top: 24px;
}
.post-body h3 {
  font-size: 1.12rem;
  font-weight: 700;
  margin: 28px 0 10px;
  scroll-margin-top: 24px;
}
.post-body h4 {
  font-size: 1.02rem;
  font-weight: 700;
  margin: 22px 0 8px;
  scroll-margin-top: 24px;
}

.post-body p { margin: 14px 0; }

.post-body a {
  color: var(--accent-strong);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.18s var(--ease);
}
.post-body a:hover { border-bottom-color: var(--accent); }

.post-body ul, .post-body ol { margin: 14px 0; padding-left: 26px; }
.post-body li { margin: 7px 0; }
.post-body li::marker { color: var(--accent); }

.post-body blockquote {
  border-left: 3px solid var(--accent);
  background: var(--surface);
  padding: 12px 18px;
  border-radius: 0 var(--radius-m) var(--radius-m) 0;
  color: #5B534A;
  margin: 18px 0;
}
.post-body blockquote p { margin: 6px 0; }

.post-body code {
  background: var(--code-bg);
  border-radius: 5px;
  padding: 2px 7px;
  font-family: var(--mono);
  font-size: 0.86em;
}

.post-body pre {
  background: #2D2A26;
  color: #F0ECE4;
  border-radius: var(--radius-m);
  padding: 18px 20px;
  overflow-x: auto;
  margin: 18px 0;
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.65;
}
.post-body pre code { background: none; padding: 0; color: inherit; }

.post-body img {
  max-width: 100%;
  border-radius: var(--radius-m);
  margin: 16px 0;
}

.post-body hr { border: none; border-top: 1px solid var(--line); margin: 30px 0; }

.post-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
  font-size: 0.95rem;
}
.post-body th, .post-body td {
  border: 1px solid var(--line);
  padding: 8px 12px;
  text-align: left;
}
.post-body th { background: var(--surface); font-weight: 700; }
.post-body tr:nth-child(even) td { background: rgba(255, 255, 255, 0.5); }

/* 上一篇 / 下一篇 */
.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 44px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.post-nav a {
  display: block;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  text-decoration: none;
  color: var(--fg);
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease);
}
.post-nav a:hover { border-color: var(--accent); transform: translateY(-2px); }
.post-nav .nav-label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  font-family: var(--mono);
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}
.post-nav .nav-title {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.5;
}
.post-nav .nav-next { text-align: right; }

.post-footer {
  margin-top: 34px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.post-footer a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.18s var(--ease);
}
.post-footer a:hover { color: var(--accent-strong); }

.site-footer {
  max-width: 780px;
  margin: 0 auto;
  padding: 36px 28px 56px;
  color: var(--muted);
  font-size: 0.78rem;
  font-family: var(--mono);
  letter-spacing: 0.06em;
  text-align: center;
}

/* ---------- 阅读 / 编辑模式切换（右上角悬浮，Obsidian 式） ---------- */
.mode-switch {
  display: inline-flex;
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: var(--z-sticky);
  padding: 3px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(45, 42, 38, 0.08);
}
.mode-btn {
  padding: 3px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.18s var(--ease), background 0.18s var(--ease);
  font-family: inherit;
}
.mode-btn:hover { color: var(--fg); }
.mode-btn.active {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 1px 3px rgba(180, 83, 42, 0.35);
}
.mode-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(180, 83, 42, 0.25);
}

/* ---------- 视图切换过渡 ---------- */
.view-hide { display: none; }
.view-show { animation: viewIn 0.28s var(--ease); }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 编辑模式工具栏 ---------- */
.edit-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.edit-bar-title {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent-strong);
}
.btn-ghost {
  padding: 5px 14px;
  font-size: 0.82rem;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  cursor: pointer;
  transition: color 0.18s var(--ease), border-color 0.18s var(--ease);
  font-family: inherit;
}
.btn-ghost:hover { color: var(--fg); border-color: #D3CCBE; }
.btn-ghost:active { transform: scale(0.98); }
.btn-ghost:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(180, 83, 42, 0.25);
}

/* ---------- 在线编辑面板 ---------- */
.edit-panel { margin-top: 8px; }

/* 密码门：进入编辑前先验证（替代浏览器 prompt） */
.pwd-gate {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: 28px 32px;
  max-width: 420px;
  margin: 40px auto;
  text-align: center;
}
.pwd-gate h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.pwd-gate p {
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 18px;
}
.pwd-gate input {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.95rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--input-bg);
  color: var(--fg);
  font-family: inherit;
  margin-bottom: 12px;
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.pwd-gate input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(180, 83, 42, 0.15);
}
.pwd-gate .btn-save { width: 100%; }
.pwd-err {
  display: block;
  color: var(--err);
  font-size: 0.82rem;
  margin-bottom: 10px;
  min-height: 1.2em;
}

.edit-field { margin-bottom: 20px; }

.edit-field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
}

/* 文档式编辑：标题即文档标题 */
.title-field2 input {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.005em;
  padding: 10px 2px;
  border: none;
  border-bottom: 2px solid var(--line);
  border-radius: 0;
  background: transparent;
  caret-color: var(--accent);
  color: var(--fg);
  font-family: inherit;
  width: 100%;
  transition: border-color 0.18s var(--ease);
}
.title-field2 input:focus {
  outline: none;
  border-bottom-color: var(--accent);
  background: transparent;
  box-shadow: none;
}
.title-field2 input::placeholder {
  color: var(--faint);
  font-weight: 600;
}

/* 日期 / 标签：轻量属性行（Obsidian properties 式） */
.edit-row {
  display: flex;
  gap: 28px;
}
.edit-row .edit-field { flex: 1; }
.edit-row input {
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  padding: 6px 2px;
  font-size: 0.95rem;
  color: var(--muted);
  caret-color: var(--accent);
  width: 100%;
  font-family: inherit;
  transition: border-color 0.18s var(--ease), color 0.18s var(--ease);
}
.edit-row input:focus {
  outline: none;
  border-bottom-color: var(--accent);
  background: transparent;
  box-shadow: none;
  color: var(--fg);
}

.edit-field input {
  width: 100%;
  padding: 8px 2px;
  font-size: 1rem;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--fg);
  font-family: inherit;
  transition: border-color 0.18s var(--ease);
}
.edit-field input:hover { border-bottom-color: #C9C2B4; }
.edit-field input:focus {
  outline: none;
  background: transparent;
  border-bottom-color: var(--accent);
  box-shadow: none;
}
.edit-field input::placeholder { color: var(--faint); }

.edit-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* ---------- Markdown 格式工具条 ---------- */
.md-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 0 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.md-toolbar button {
  min-width: 32px;
  height: 28px;
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.02em;
  transition: color 0.15s var(--ease-quick), background 0.15s var(--ease-quick),
    border-color 0.15s var(--ease-quick);
}
.md-toolbar button:hover {
  color: var(--accent-strong);
  background: var(--accent-soft);
}
.md-toolbar button:active { transform: scale(0.96); }
.md-toolbar button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(180, 83, 42, 0.25);
}

/* ---------- 字数统计 ---------- */
.edit-stats {
  grid-column: 1 / -1;
  text-align: right;
  color: var(--faint);
  font-size: 0.76rem;
  font-family: var(--mono);
  letter-spacing: 0.04em;
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}

/* ---------- 草稿状态 ---------- */
.draft-status {
  font-size: 0.78rem;
  color: var(--faint);
  font-family: var(--mono);
  letter-spacing: 0.03em;
}

/* ---------- 标签快捷选择 ---------- */
.tag-suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.tag-chip {
  padding: 2px 10px;
  font-size: 0.74rem;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s var(--ease-quick);
}
.tag-chip:hover {
  background: var(--accent);
  color: #fff;
}
.tag-chip:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(180, 83, 42, 0.25);
}

.edit-cols textarea {
  width: 100%;
  padding: 12px 2px;
  font-size: 0.95rem;
  line-height: 1.8;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--fg);
  font-family: var(--mono);
  resize: vertical;
  min-height: 320px;
  transition: border-color 0.18s var(--ease);
}
.edit-cols textarea:hover { border-bottom: 1px solid #C9C2B4; }
.edit-cols textarea:focus {
  outline: none;
  background: transparent;
  border-bottom-color: var(--accent);
  box-shadow: none;
}
.edit-cols textarea::placeholder { color: var(--faint); }

.edit-preview {
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 14px 18px;
  font-size: 0.94rem;
  line-height: 1.75;
  overflow: auto;
  max-height: 480px;
  background: var(--input-bg);
  color: var(--fg);
}
.edit-preview h1, .edit-preview h2, .edit-preview h3 {
  margin: 12px 0 8px;
  text-wrap: balance;
}
.edit-preview p { margin: 10px 0; }
.edit-preview code {
  background: var(--code-bg);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.85em;
  font-family: var(--mono);
}
.edit-preview pre {
  background: #2D2A26;
  color: #F0ECE4;
  border-radius: var(--radius-m);
  padding: 14px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.85rem;
}
.edit-preview pre code { background: none; padding: 0; color: inherit; }
.edit-preview img { max-width: 100%; border-radius: var(--radius-m); }

/* 图片尺寸调整条（点击预览/阅读图片弹出，电脑滑块 + 手机可拖） */
.img-resize-bar {
  position: fixed;
  z-index: 999;
  display: none;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  box-shadow: 0 6px 24px -8px rgba(43, 42, 40, 0.25);
  padding: 10px 14px;
  font-size: 0.82rem;
  color: var(--muted);
}
.img-resize-bar.show { display: flex; }
.img-resize-bar .irb-label { font-weight: 600; color: var(--fg); white-space: nowrap; }
.img-resize-bar .irb-range {
  width: 180px;
  accent-color: var(--accent);
  cursor: pointer;
  min-height: 22px;
}
.img-resize-bar .irb-val {
  min-width: 48px;
  font-family: var(--mono, Consolas, monospace);
  font-size: 0.78rem;
  color: var(--accent-strong);
}
.img-resize-bar .irb-reset {
  padding: 4px 12px;
  font-size: 0.78rem;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.18s var(--ease);
}
.img-resize-bar .irb-reset:hover { color: var(--fg); border-color: var(--line-strong); }
.img-resize-bar .irb-reset:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(180, 83, 42, 0.25); }
@media (max-width: 480px) {
  .img-resize-bar { width: calc(100% - 24px); left: 12px !important; justify-content: center; }
  .img-resize-bar .irb-range { width: 130px; }
}
.edit-preview blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  color: var(--muted);
  margin: 10px 0;
}
.edit-preview ul, .edit-preview ol { padding-left: 22px; margin: 8px 0; }

.edit-actions {
  margin-top: 22px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.btn-save {
  padding: 10px 30px;
  font-size: 0.94rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-m);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.18s var(--ease), transform 0.12s var(--ease);
}
.btn-save:hover { background: var(--accent-strong); }
.btn-save:active { transform: scale(0.98); }
.btn-save:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(180, 83, 42, 0.3);
}
.btn-save:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-cancel {
  padding: 10px 22px;
  font-size: 0.9rem;
  color: var(--fg);
  background: #F0ECE5;
  border: 1px solid transparent;
  border-radius: var(--radius-m);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.18s var(--ease), transform 0.12s var(--ease);
}
.btn-cancel:hover { background: #E7E1D6; }
.btn-cancel:active { transform: scale(0.98); }
.btn-cancel:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(180, 83, 42, 0.25);
}

#edit-status {
  font-size: 0.86rem;
  color: var(--muted);
  margin-left: auto;
}
#edit-status.ok { color: var(--ok); font-weight: 600; }
#edit-status.err { color: var(--err); font-weight: 600; }

/* ---------- 写新文章页 ---------- */
.write-head {
  text-align: center;
  margin: 10px 0 28px;
}
.write-head h1 {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.3;
  text-wrap: balance;
}
.write-head p {
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 8px;
}

/* 居中"白纸"写作区 */
.write-sheet {
  max-width: 880px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 2px 8px rgba(45, 42, 38, 0.04), 0 16px 44px rgba(45, 42, 38, 0.07);
  padding: 36px 40px;
}
.write-title {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.35;
  padding: 4px 2px 10px;
  caret-color: var(--accent);
  color: var(--fg);
  font-family: inherit;
}
.write-title:focus { outline: none; }
.write-title::placeholder { color: var(--faint); }

.write-props {
  display: flex;
  gap: 26px;
  padding: 4px 2px 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}
.prop-input {
  border: none;
  background: transparent;
  font-size: 0.9rem;
  color: var(--muted);
  padding: 4px 0;
  caret-color: var(--accent);
  font-family: inherit;
}
.prop-input:focus { outline: none; color: var(--fg); }

.write-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.write-cols textarea {
  width: 100%;
  border: none;
  background: transparent;
  resize: vertical;
  min-height: 400px;
  font-size: 0.97rem;
  line-height: 1.85;
  font-family: var(--mono);
  color: var(--fg);
  caret-color: var(--accent);
  padding: 4px 2px;
}
.write-cols textarea:focus { outline: none; }
.write-cols textarea::placeholder { color: var(--faint); }

.write-actions {
  max-width: 880px;
  margin: 22px auto 0;
}

/* 新文章页的密码门复用 .pwd-gate，宽度稍大 */
.write-sheet + .pwd-gate { margin: -20px auto 0; }

@media (max-width: 600px) {
  .site-header { padding-top: 36px; padding-bottom: 14px; flex-wrap: wrap; }
  main { padding: 24px 20px; }
  .post h1 { font-size: 1.6rem; }
  .edit-cols { grid-template-columns: 1fr; }
  .edit-preview { max-height: 300px; }
  .header-actions { margin-left: 0; }
  .post-nav { grid-template-columns: 1fr; }
  .post-nav .nav-next { text-align: left; }
  .edit-row { flex-direction: column; gap: 0; }
  .write-sheet { padding: 26px 22px; }
  .write-cols { grid-template-columns: 1fr; }
  .write-props { flex-wrap: wrap; gap: 12px; }
  .md-toolbar { gap: 2px; }
  .md-toolbar button { padding: 0 8px; }
  .mode-switch { top: 10px; right: 10px; }
  .hero-title { font-size: 1.7rem; }
}

/* 无障碍：减弱动效 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
  .post-card:hover { transform: none; }
}

/* ============================================================
   写作/编辑面板 · v4（用户设计稿：sage 绿 + 金色 + 衬线标题）
   页面纸感背景 + 暖色光晕 · masthead 页头 · 面板式 · 工具条连体
   ============================================================ */

/* ---------- 写作页全局（仅写文章/编辑页 body 作用域） ---------- */
.write-page {
  background: var(--paper);
  background-image:
    radial-gradient(ellipse 900px 500px at 15% -5%, rgba(122, 139, 111, 0.07), transparent),
    radial-gradient(ellipse 700px 400px at 100% 20%, rgba(184, 147, 95, 0.06), transparent);
  color: var(--ink);
  font-family: "Noto Sans SC", var(--sans);
}

/* ---------- 写作页容器 ---------- */
.page {
  max-width: 620px;
  margin: 0 auto;
  padding: 72px 28px 100px;
}

/* ---------- Masthead ---------- */
.masthead { margin-bottom: 64px; }
.masthead .mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.mark-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--sage);
}
.mark-label {
  font-family: "Space Mono", var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.masthead h1.site-title {
  font-family: "Noto Serif SC", var(--serif);
  font-weight: 700;
  font-size: 42px;
  line-height: 1.2;
  margin: 0 0 10px;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-wrap: balance;
}
.site-tagline {
  font-size: 15px;
  color: var(--ink-soft);
  margin: 0;
  letter-spacing: 0.02em;
}
.site-tagline .sep { color: var(--line-strong); margin: 0 8px; }

hr.rule {
  border: none;
  border-top: 1px solid var(--line);
  margin: 40px 0;
}

/* ---------- 区块标题 ---------- */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
}
h2.section-title {
  font-family: "Noto Serif SC", var(--serif);
  font-weight: 700;
  font-size: 22px;
  margin: 0;
  color: var(--ink);
  text-wrap: balance;
}
.section-sub {
  font-size: 13.5px;
  color: var(--ink-soft);
  margin: 4px 0 26px;
}

/* ---------- 面板（纸上纸） ---------- */
.panel {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 26px 26px 24px;
  box-shadow: 0 1px 2px rgba(43, 42, 40, 0.04), 0 8px 24px -18px rgba(43, 42, 40, 0.16);
}
.panel + .panel { margin-top: 20px; }

.field-label {
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.03em;
  margin: 0 0 8px;
  display: block;
}

/* ---------- 表单控件（面板内） ---------- */
.panel input[type="password"],
.panel input[type="text"],
.panel input[type="date"],
.panel textarea {
  width: 100%;
  font-family: "Noto Sans SC", var(--sans);
  font-size: 14.5px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 11px 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.panel input::placeholder, .panel textarea::placeholder { color: #B4AEA2; }
.panel input:focus, .panel textarea:focus {
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(122, 139, 111, 0.15);
  background: var(--paper-raised);
}

/* ---------- 密码行（横排） ---------- */
.auth-row {
  display: flex;
  gap: 10px;
}
.auth-row input { flex: 1; }
.pwd-err {
  display: block;
  color: var(--err);
  font-size: 0.82rem;
  margin-top: 8px;
  min-height: 1.2em;
}

/* ---------- 按钮 ---------- */
.panel button {
  font-family: "Noto Sans SC", var(--sans);
  cursor: pointer;
  border: none;
  border-radius: 7px;
}
.btn-primary {
  background: var(--sage);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  padding: 11px 20px;
  white-space: nowrap;
  transition: background 0.15s ease, transform 0.1s ease;
}
.btn-primary:hover { background: var(--sage-dark); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(122, 139, 111, 0.25);
}
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  font-size: 14px;
  padding: 11px 18px;
  border: 1px solid var(--line-strong) !important;
  transition: background 0.15s ease, color 0.15s ease;
}
.btn-ghost:hover { background: var(--paper); color: var(--ink); }
.btn-ghost:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(122, 139, 111, 0.2);
}

/* ---------- 编辑器面板 ---------- */
.editor-panel { margin-top: 20px; }

.editor-topline {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}
.title-input {
  font-family: "Noto Serif SC", var(--serif);
  font-size: 19px;
  font-weight: 600;
  padding: 13px 15px !important;
}

.meta-row {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}
.meta-row > div { flex: 1; position: relative; }
.meta-row input[type="date"] {
  font-family: "Space Mono", var(--mono);
  font-size: 13.5px;
  color: var(--ink-soft);
}

/* 标签胶囊（当前标签） */
.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(122, 139, 111, 0.12);
  color: var(--sage-dark);
  font-size: 12.5px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid rgba(122, 139, 111, 0.25);
  margin-bottom: 16px;
}
.tag-pill::before { content: "#"; opacity: 0.6; }
.tag-pill.hidden { display: none; }

/* 标签建议（已用标签快捷填入） */
.tag-suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -6px 0 14px;
}
.tag-chip {
  padding: 3px 12px;
  font-size: 0.76rem;
  color: var(--sage-dark);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  cursor: pointer;
  font-family: "Noto Sans SC", var(--sans);
  transition: all 0.15s ease;
}
.tag-chip:hover {
  background: rgba(122, 139, 111, 0.12);
  border-color: var(--sage);
}

/* ---------- 工具条 + 正文连体（签名元素） ---------- */
.toolbar {
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 6px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  margin-bottom: 0;
  flex-wrap: wrap;
  position: relative;
  z-index: 2;
}
.tb-btn {
  background: transparent;
  color: var(--ink);
  min-width: 38px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  font-size: 14px;
  transition: background 0.12s ease;
  padding: 0 10px;
}
.tb-btn:hover { background: rgba(122, 139, 111, 0.14); }
.tb-btn:active { transform: scale(0.96); }
.tb-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(122, 139, 111, 0.25);
}
.tb-btn.tb-h2 { font-family: "Noto Serif SC", var(--serif); font-weight: 700; font-size: 15px; }
.tb-btn.tb-b { font-weight: 700; }
.tb-btn.tb-i { font-style: italic; font-family: "Noto Serif SC", var(--serif); }
.tb-btn.tb-code { font-family: "Space Mono", var(--mono); font-size: 12px; }
.tb-divider {
  width: 1px;
  background: var(--line-strong);
  margin: 4px 5px;
}

.editor-textarea {
  border-top: none;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-color: var(--line) !important;
  min-height: 220px;
  resize: vertical;
  font-size: 14.5px;
  line-height: 1.75;
  padding: 18px 16px;
  margin-top: -1px;
  position: relative;
  z-index: 1;
  font-family: "Noto Sans SC", var(--sans) !important;
}

/* 预览区（功能保留，置于编辑器下方） */
.preview-wrap {
  margin-top: 16px;
}
.preview-label {
  font-size: 11px;
  font-family: "Space Mono", var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 8px;
}
.preview-wrap .edit-preview {
  border-radius: 7px;
  max-height: 340px;
  background: var(--paper-raised);
}

/* 字数统计 */
.edit-stats {
  text-align: right;
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-family: "Space Mono", var(--mono);
  letter-spacing: 0.04em;
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}

/* ---------- 操作行 ---------- */
.editor-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}
#edit-status {
  font-size: 0.86rem;
  color: var(--ink-soft);
  margin-left: auto;
}
#edit-status.ok { color: var(--ok); font-weight: 600; }
#edit-status.err { color: var(--err); font-weight: 600; }
.draft-status {
  font-size: 0.78rem;
  color: var(--ink-soft);
  font-family: "Space Mono", var(--mono);
  letter-spacing: 0.03em;
}

/* ---------- 页脚 ---------- */
.foot-note {
  margin-top: 56px;
  font-size: 12.5px;
  color: #B4AEA2;
  text-align: center;
  letter-spacing: 0.03em;
}

@media (max-width: 480px) {
  .page { padding: 48px 18px 70px; }
  .masthead h1.site-title { font-size: 32px; }
  .meta-row { flex-direction: column; gap: 12px; }
  .panel { padding: 20px; }
  .auth-row { flex-direction: column; }
  .editor-actions { flex-direction: column; align-items: stretch; }
  .editor-actions .btn-primary, .editor-actions .btn-ghost { width: 100%; }
  #edit-status { margin-left: 0; }
}
