/* ==========================================================================
   云间随笔 —— 样式表
   主题：CSS 变量 + 系统偏好自动跟随 + 手动覆盖
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-soft: #f7f8fa;
  --bg-elev: #ffffff;
  --border: #e6e8ec;
  --border-strong: #d3d7de;
  --text: #1a1d23;
  --text-soft: #565c68;
  --text-mute: #8a91a0;
  --brand: #f6821f;
  --brand-soft: rgba(246, 130, 31, 0.1);
  --brand-contrast: #ffffff;
  --link: #1f6feb;
  --code-bg: #f4f6f9;
  --code-border: #e4e7ec;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --wrap: 1120px;
  --wrap-narrow: 760px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, "Liberation Mono",
    "Courier New", monospace;
}

/* 深色主题：跟随系统 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1115;
    --bg-soft: #14171d;
    --bg-elev: #181c23;
    --border: #262b34;
    --border-strong: #333a45;
    --text: #e8eaee;
    --text-soft: #a9b0bd;
    --text-mute: #767e8c;
    --brand: #ff9d4d;
    --brand-soft: rgba(255, 157, 77, 0.14);
    --brand-contrast: #1a1200;
    --link: #6cb6ff;
    --code-bg: #14171d;
    --code-border: #262b34;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.45);
  }
}

/* 深色主题：手动强制 */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1115;
  --bg-soft: #14171d;
  --bg-elev: #181c23;
  --border: #262b34;
  --border-strong: #333a45;
  --text: #e8eaee;
  --text-soft: #a9b0bd;
  --text-mute: #767e8c;
  --brand: #ff9d4d;
  --brand-soft: rgba(255, 157, 77, 0.14);
  --brand-contrast: #1a1200;
  --link: #6cb6ff;
  --code-bg: #14171d;
  --code-border: #262b34;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.45);
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 88px;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* 长单词 / 长 URL 不撑破布局 */
.prose, .card-summary, .card-title, .post-title, .archive-list a { overflow-wrap: break-word; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
.wrap-narrow { max-width: var(--wrap-narrow); margin: 0 auto; padding: 0 24px; }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--brand);
  color: var(--brand-contrast);
  padding: 10px 16px;
  z-index: 200;
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

/* ------------------------------- 顶栏 ------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-weight: 700;
  font-size: 1.0625rem;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}
.brand:hover { text-decoration: none; color: var(--brand); }
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand);
  transition: transform 0.2s ease;
}
.brand:hover .brand-mark { transform: translateY(-1px) rotate(-4deg); }

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-wrap: wrap;
}
.site-nav a {
  color: var(--text-soft);
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 500;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.site-nav a:hover {
  color: var(--text);
  background: var(--bg-soft);
  text-decoration: none;
}
.site-nav a.active { color: var(--brand); background: var(--brand-soft); }

.header-actions { display: flex; align-items: center; gap: 6px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  padding: 0;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.icon-btn:hover {
  background: var(--bg-soft);
  color: var(--text);
  border-color: var(--border);
}

/* 主题按钮图标。
   注意：不能在媒体查询之外写 :root[data-theme="auto"] .i-sun 这类规则——
   它与媒体查询内的规则优先级相同(0-5-0)，一旦位置靠后就会把
   媒体查询里的 display:block 压掉。必须在每个媒体查询里成对声明。 */
.i-sun, .i-moon { display: block; }

/* 显式 light：始终显示太阳 */
:root[data-theme="light"] .i-sun { display: block; }
:root[data-theme="light"] .i-moon { display: none; }

/* 显式 dark：始终显示月亮 */
:root[data-theme="dark"] .i-sun { display: none; }
:root[data-theme="dark"] .i-moon { display: block; }

/* 系统浅色：auto 与未设置都显示太阳 */
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] .i-sun,
  :root:not([data-theme]) .i-sun { display: block; }
  :root[data-theme="auto"] .i-moon,
  :root:not([data-theme]) .i-moon { display: none; }
}

/* 系统深色：auto 与未设置都显示月亮 */
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] .i-sun,
  :root:not([data-theme]) .i-sun { display: none; }
  :root[data-theme="auto"] .i-moon,
  :root:not([data-theme]) .i-moon { display: block; }
}

/* ---------------------- 工具栏导航项（写文章）---------------------- */

.tool-nav-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  margin-right: 4px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--text-soft);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}
.tool-nav-item:hover { color: var(--brand); border-color: var(--brand); }
.tool-nav-item[aria-expanded="true"] {
  color: var(--brand);
  border-color: var(--brand);
  background: var(--brand-soft);
}

/* ---------------------------- 编辑面板 ---------------------------- */

.editor-panel {
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
  padding: 18px 0 22px;
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  animation: slideDown 0.18s ease;
}

.ed-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.ed-head-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.ed-head-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.ed-mode {
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-soft);
  white-space: nowrap;
}
.ed-mode-edit { background: var(--brand-soft); color: var(--brand); }

.ed-status { font-size: 0.8125rem; color: var(--text-mute); }
.ed-status.ed-ok { color: #2ea043; }

.ed-loader {
  font-family: inherit;
  font-size: 0.8125rem;
  padding: 6px 10px;
  max-width: 200px;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.ed-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1.2fr 1.6fr;
  gap: 12px;
  margin-bottom: 12px;
}
.ed-cell { display: flex; flex-direction: column; gap: 5px; min-width: 0; }

.ed-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.ed-hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  margin-left: 6px;
  color: var(--text-mute);
  opacity: 0.75;
}

.ed-input {
  font-family: inherit;
  font-size: 0.9375rem;
  padding: 8px 11px;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  min-width: 0;
}
.ed-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.ed-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--text-soft);
  margin-bottom: 14px;
  cursor: pointer;
}
.ed-check input { accent-color: var(--brand); width: 15px; height: 15px; cursor: pointer; }

.ed-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.ed-pane {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-soft);
  overflow: hidden;
  min-width: 0;
}
.ed-pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-mute);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.ed-count { font-weight: 400; text-transform: none; letter-spacing: 0; }

.ed-body {
  flex: 1;
  min-height: 320px;
  padding: 14px;
  border: 0;
  outline: none;
  resize: vertical;
  background: transparent;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.75;
  tab-size: 2;
}
.ed-body::placeholder { color: var(--text-mute); opacity: 0.7; }

.ed-preview {
  flex: 1;
  min-height: 320px;
  max-height: 560px;
  overflow-y: auto;
  padding: 14px 16px;
  font-size: 0.9375rem;
  line-height: 1.8;
}
.ed-preview > *:first-child { margin-top: 0; }
.ed-preview h1, .ed-preview h2, .ed-preview h3 { margin: 1.2em 0 0.5em; line-height: 1.35; }
.ed-preview h1 { font-size: 1.35rem; }
.ed-preview h2 { font-size: 1.15rem; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
.ed-preview h3 { font-size: 1rem; }
.ed-preview p { margin: 0 0 0.9em; }
.ed-preview ul, .ed-preview ol { margin: 0 0 0.9em; padding-left: 1.4em; }
.ed-preview blockquote {
  margin: 0.9em 0;
  padding: 2px 14px;
  border-left: 3px solid var(--brand);
  background: var(--brand-soft);
  color: var(--text-soft);
}
.ed-preview blockquote p:last-child { margin-bottom: 0; }
.ed-preview img { max-width: 100%; border-radius: var(--radius-sm); }
.ed-preview table { border-collapse: collapse; width: 100%; font-size: 0.875rem; }
.ed-preview th, .ed-preview td { padding: 6px 10px; border: 1px solid var(--border); text-align: left; }
.ed-preview th { background: var(--bg); }
.ed-preview hr { border: 0; border-top: 1px solid var(--border); margin: 1.5em 0; }
.ed-preview blockquote { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.ed-empty { color: var(--text-mute); font-size: 0.875rem; }

.ed-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.ed-sep { width: 1px; height: 22px; background: var(--border-strong); }

.ed-btn {
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 8px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, filter 0.15s ease;
}
.ed-btn:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.ed-btn:disabled { opacity: 0.75; cursor: default; }
.ed-btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-contrast);
  font-weight: 600;
}
.ed-btn-primary:hover:not(:disabled) { filter: brightness(1.08); color: var(--brand-contrast); }
.ed-btn-sm { padding: 4px 10px; font-size: 0.8125rem; }

.ed-details {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
}
.ed-details > summary {
  padding: 10px 14px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-soft);
  cursor: pointer;
  border-radius: var(--radius);
}
.ed-details[open] > summary { border-bottom: 1px solid var(--border); }
.ed-details-body { padding: 14px; }

.ed-note { margin: 0 0 10px; font-size: 0.875rem; color: var(--text-soft); line-height: 1.7; }
.ed-note code {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}
.ed-warn { color: #b76b01; }
.ed-warn code { border-color: #b76b01; }

.ed-cmdbox {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  overflow-x: auto;
}
.ed-cmdbox code {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text);
  white-space: nowrap;
}

.ed-output {
  width: 100%;
  min-height: 150px;
  max-height: 300px;
  margin-top: 6px;
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.7;
  color: var(--text-soft);
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-sm);
  resize: vertical;
  outline: none;
}

/* ------------------------------ 搜索 ------------------------------- */

.search-panel {
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
  padding: 16px 0 20px;
  animation: slideDown 0.18s ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
#search-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#search-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.search-results { margin-top: 10px; max-height: 52vh; overflow-y: auto; }
.search-results a {
  display: block;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text);
  border: 1px solid transparent;
}
.search-results a:hover, .search-results a.active {
  background: var(--bg-soft);
  border-color: var(--border);
  text-decoration: none;
}
.search-results .sr-title { font-weight: 600; }
.search-results .sr-meta { font-size: 0.8125rem; color: var(--text-mute); }
.search-results .sr-sum {
  font-size: 0.875rem;
  color: var(--text-soft);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.search-results mark { background: var(--brand-soft); color: var(--brand); padding: 0 2px; border-radius: 3px; }
.search-empty { padding: 14px; color: var(--text-mute); font-size: 0.9375rem; }

/* ------------------------------ Hero ------------------------------- */

.hero {
  padding: 72px 24px 48px;
  text-align: center;
}
.hero-compact { padding: 52px 24px 32px; }
.hero-title {
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin: 0 0 16px;
  font-weight: 800;
  background: linear-gradient(120deg, var(--text) 20%, var(--brand) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero-desc {
  font-size: clamp(1rem, 2vw, 1.125rem);
  color: var(--text-soft);
  margin: 0 auto;
  max-width: 620px;
}
.hero-stats {
  margin-top: 20px;
  font-size: 0.875rem;
  color: var(--text-mute);
}

/* ----------------------------- 文章卡片 ---------------------------- */

.post-list {
  display: grid;
  gap: 16px;
  padding-bottom: 40px;
}
@media (min-width: 900px) {
  .post-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
}

.post-card {
  position: relative;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.post-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.post-card .card-link { position: absolute; inset: 0; z-index: 1; border-radius: var(--radius); }
.post-card .card-title,
.post-card .card-tags { position: relative; z-index: 2; }
.post-card .card-title a { color: var(--text); }
.post-card .card-title a:hover { color: var(--brand); text-decoration: none; }

.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--text-mute);
  margin-bottom: 10px;
}
.card-meta .dot { opacity: 0.5; }
.card-title {
  font-size: 1.25rem;
  line-height: 1.4;
  margin: 0 0 10px;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.card-summary {
  margin: 0 0 14px;
  color: var(--text-soft);
  font-size: 0.9375rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 0.75rem;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 500;
}
.tag:hover { text-decoration: none; filter: brightness(0.95); }

/* ------------------------------ 分页 ------------------------------- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 8px 24px 72px;
}
.page-btn {
  padding: 9px 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 500;
  background: var(--bg-elev);
  transition: border-color 0.15s ease, color 0.15s ease;
}
.page-btn:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.page-btn.disabled { opacity: 0.4; pointer-events: none; }
.page-info { font-size: 0.875rem; color: var(--text-mute); font-variant-numeric: tabular-nums; }

/* ------------------------------ 文章页 ----------------------------- */

.post { padding-top: 56px; padding-bottom: 64px; }
.post-header { margin-bottom: 36px; }
.post-title {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  line-height: 1.25;
  letter-spacing: -0.025em;
  margin: 0 0 18px;
  font-weight: 800;
}
.post-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--text-mute);
}
.post-meta .dot { opacity: 0.5; }
.post-meta .tag { font-size: 0.75rem; }

/* 目录 */
.toc {
  padding: 16px 20px;
  margin-bottom: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
}
.toc-title {
  margin: 0 0 10px;
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-mute);
}
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 0; }
.toc a {
  display: block;
  padding: 3px 0;
  color: var(--text-soft);
  font-size: 0.9375rem;
}
.toc a:hover { color: var(--brand); text-decoration: none; }
.toc-l3 { padding-left: 16px; }
.toc-l3 a { font-size: 0.875rem; color: var(--text-mute); }

/* ------------------------------ 正文排版 --------------------------- */

.prose { font-size: 1.0625rem; line-height: 1.85; }
.prose > *:first-child { margin-top: 0; }

.prose h2 {
  font-size: 1.5rem;
  margin: 2.4em 0 0.8em;
  padding-bottom: 0.4em;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.02em;
  font-weight: 700;
}
.prose h3 { font-size: 1.25rem; margin: 2em 0 0.7em; letter-spacing: -0.015em; font-weight: 700; }
.prose h4 { font-size: 1.0625rem; margin: 1.6em 0 0.6em; font-weight: 700; color: var(--text-soft); }
.prose p { margin: 0 0 1.3em; }
.prose strong { font-weight: 700; color: var(--text); }
.prose em { font-style: italic; }
.prose del { color: var(--text-mute); }

.prose a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--link) 35%, transparent);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.15s ease;
}
.prose a:hover { text-decoration-color: var(--link); }

.prose ul, .prose ol { margin: 0 0 1.3em; padding-left: 1.5em; }
.prose li { margin: 0.4em 0; }
.prose li::marker { color: var(--brand); }
.prose .task-item { list-style: none; margin-left: -1.3em; display: flex; gap: 8px; align-items: flex-start; }
.prose .task-item input { margin-top: 0.5em; accent-color: var(--brand); }
.prose .task-done { color: var(--text-mute); text-decoration: line-through; }

.prose blockquote {
  margin: 1.6em 0;
  padding: 4px 20px;
  border-left: 3px solid var(--brand);
  background: var(--brand-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-soft);
}
.prose blockquote p:last-child { margin-bottom: 0; }

.prose hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2.5em 0;
}

.prose img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin: 1.6em 0;
  display: block;
}

/* 行内代码 */
.prose code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  padding: 0.15em 0.4em;
  border-radius: 5px;
  word-break: break-word;
}

/* 代码块 */
.code-block {
  position: relative;
  margin: 1.6em 0;
  border: 1px solid var(--code-border);
  border-radius: var(--radius);
  background: var(--code-bg);
  overflow: hidden;
}
.code-lang {
  position: absolute;
  top: 10px;
  right: 52px;
  font-size: 0.6875rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-mute);
  pointer-events: none;
}
.code-block pre {
  margin: 0;
  padding: 18px 20px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.7;
  background: transparent;
  -webkit-overflow-scrolling: touch;
}
.code-block code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
  color: var(--text);
  white-space: pre;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--code-border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--text-mute);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.code-block:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { color: var(--brand); border-color: var(--brand); }
.copy-btn.copied { color: #2ea043; border-color: #2ea043; opacity: 1; }

/* 语法高亮 */
.tok-com { color: var(--text-mute); font-style: italic; }
.tok-str { color: #0a7d47; }
.tok-kw { color: #a626a4; font-weight: 600; }
.tok-num { color: #b76b01; }
.tok-fn { color: #1f6feb; }
.tok-tag { color: #c2410c; }
.tok-attr { color: #1f6feb; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tok-str { color: #7ee787; }
  :root:not([data-theme="light"]) .tok-kw { color: #ff7b72; }
  :root:not([data-theme="light"]) .tok-num { color: #ffab70; }
  :root:not([data-theme="light"]) .tok-fn { color: #79c0ff; }
  :root:not([data-theme="light"]) .tok-tag { color: #ffa657; }
  :root:not([data-theme="light"]) .tok-attr { color: #79c0ff; }
}
:root[data-theme="dark"] .tok-str { color: #7ee787; }
:root[data-theme="dark"] .tok-kw { color: #ff7b72; }
:root[data-theme="dark"] .tok-num { color: #ffab70; }
:root[data-theme="dark"] .tok-fn { color: #79c0ff; }
:root[data-theme="dark"] .tok-tag { color: #ffa657; }
:root[data-theme="dark"] .tok-attr { color: #79c0ff; }

/* 表格 */
.table-wrap {
  overflow-x: auto;
  margin: 1.6em 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.prose table { border-collapse: collapse; width: 100%; font-size: 0.9375rem; }
.prose th, .prose td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.prose th { background: var(--bg-soft); font-weight: 700; white-space: nowrap; }
.prose tbody tr:last-child td { border-bottom: 0; }
.prose tbody tr:hover { background: var(--bg-soft); }

/* 文章底部 */
.post-footer { margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--border); }
.back-link { font-size: 0.9375rem; color: var(--text-soft); }
.back-link:hover { color: var(--brand); }

.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 32px;
}
.post-nav-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.post-nav-item:hover { border-color: var(--brand); text-decoration: none; transform: translateY(-2px); }
.post-nav-item.next { text-align: right; }
.post-nav-item.empty { border: 0; background: none; }
.pn-label { font-size: 0.75rem; color: var(--text-mute); }
.pn-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --------------------------- 归档 / 标签 --------------------------- */

.page-head { padding: 56px 24px 32px; }
.page-head h1 {
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  margin: 0 0 8px;
  letter-spacing: -0.025em;
  font-weight: 800;
}
.page-sub { color: var(--text-mute); margin: 0; font-size: 0.9375rem; }
.page-sub a { color: var(--brand); }

.archive-year { margin-bottom: 40px; }
.archive-year-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: 1.375rem;
  margin: 0 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}
.count {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-mute);
  background: var(--bg-soft);
  padding: 2px 9px;
  border-radius: 999px;
}
.archive-list { list-style: none; margin: 0; padding: 0; }
.archive-list li {
  display: flex;
  gap: 16px;
  align-items: baseline;
  padding: 9px 0;
  border-bottom: 1px dashed var(--border);
}
.archive-list li:last-child { border-bottom: 0; }
.archive-list time {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-mute);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.archive-list a { color: var(--text); font-size: 0.9375rem; }
.archive-list a:hover { color: var(--brand); }
.tag-group { margin-bottom: 36px; }

/* ------------------------------ 404 -------------------------------- */

.notfound { text-align: center; padding: 96px 24px 120px; }
.nf-code {
  font-size: clamp(4rem, 16vw, 8rem);
  font-weight: 800;
  line-height: 1;
  margin: 0 0 8px;
  color: var(--brand);
  opacity: 0.25;
  letter-spacing: -0.04em;
}
.notfound h1 { font-size: 1.5rem; margin: 0 0 12px; }
.notfound p { color: var(--text-soft); }
.btn {
  display: inline-block;
  margin-top: 12px;
  padding: 11px 24px;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: var(--brand-contrast);
  font-weight: 600;
  font-size: 0.9375rem;
}
.btn:hover { text-decoration: none; filter: brightness(1.08); }

/* ------------------------------ 页脚 ------------------------------- */

.site-footer {
  margin-top: 40px;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  padding: 44px 0 28px;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  justify-content: space-between;
  padding-bottom: 28px;
}
.footer-title { margin: 0 0 6px; font-weight: 700; font-size: 1rem; }
.footer-desc { margin: 0; color: var(--text-mute); font-size: 0.875rem; max-width: 420px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; }
.footer-links a { color: var(--text-soft); font-size: 0.875rem; }
.footer-links a:hover { color: var(--brand); }
.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--text-mute);
}
.footer-bottom a { color: var(--text-mute); }
.footer-built { margin-left: auto; }

.empty-state { color: var(--text-mute); padding: 24px 0 64px; }
.empty-state code {
  font-family: var(--font-mono);
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  padding: 0.1em 0.35em;
  border-radius: 5px;
  font-size: 0.875em;
}

/* --------------------------- 响应式 -------------------------------- */

@media (max-width: 1080px) {
  .ed-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
  .ed-split { grid-template-columns: 1fr; }
  .ed-body, .ed-preview { min-height: 240px; max-height: 420px; }
}

@media (max-width: 720px) {
  /* 「写文章」收成图标，只留一支笔，避免顶栏被挤爆 */
  .tool-nav-item { padding: 0; width: 32px; justify-content: center; margin-right: 2px; }
  .tool-nav-text { display: none; }
  .ed-grid { grid-template-columns: 1fr; }
  .ed-head-right { margin-left: 0; width: 100%; flex-wrap: wrap; }
  .ed-loader { flex: 1; max-width: none; }
  .ed-actions { gap: 8px; }
  .ed-btn { padding: 8px 13px; font-size: 0.8125rem; }
  .ed-sep { display: none; }
  .ed-body, .ed-preview { min-height: 200px; }
}

@media (max-width: 720px) {
  .wrap, .wrap-narrow { padding: 0 18px; }
  .header-inner { height: 58px; gap: 8px; }
  .brand-text { display: none; }
  .brand-mark { width: 30px; height: 30px; border-radius: 9px; }
  .site-nav { flex-wrap: nowrap; gap: 0; }
  .site-nav a { padding: 7px 9px; font-size: 0.875rem; white-space: nowrap; }
  .header-actions { gap: 2px; }
  .icon-btn { width: 32px; height: 32px; }
  .hero { padding: 48px 18px 32px; }
  .hero-compact { padding: 36px 18px 24px; }
  .post { padding-top: 36px; padding-bottom: 48px; }
  .post-nav { grid-template-columns: 1fr; }
  .post-nav-item.next { text-align: left; }
  .post-nav-item.empty { display: none; }
  .page-head { padding: 36px 18px 24px; }
  .archive-list li { flex-direction: column; gap: 2px; }
  .pagination { padding-bottom: 56px; }
  .footer-built { margin-left: 0; width: 100%; }
  .post-list { gap: 14px; }
  .post-card { padding: 20px; }
}

/* 超窄屏：进一步压缩导航，保证不溢出 */
@media (max-width: 420px) {
  .wrap, .wrap-narrow { padding: 0 14px; }
  .header-inner { gap: 6px; }
  .site-nav a { padding: 6px 7px; font-size: 0.8125rem; }
  .icon-btn { width: 30px; height: 30px; }
  .hero { padding: 40px 14px 28px; }
  .hero-title { font-size: 1.75rem; }
}

/* 打印 */
@media print {
  .site-header, .site-footer, .post-nav, .toc, .copy-btn, .pagination { display: none; }
  body { font-size: 12pt; color: #000; background: #fff; }
  .prose a { color: #000; text-decoration: underline; }
  .prose a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.85em; }
}
