/* ==========================================================================
   个人博客样式表
   设计原则：克制。留白、层次、可读性优先；不用渐变、不用花哨阴影、不堆动画。
   参考风格：Hexo NexT 一类的技术博客（简洁的两栏布局 + 卡片列表）。
   ========================================================================== */

/* ---------- 变量层：浅色（默认） ---------- */
:root {
  /* 字体 */
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  --font-mono: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* 颜色 */
  --bg: #ffffff;
  --bg-elevated: #f7f7f8;
  --bg-hover: #f0f0f2;
  --text: #24292f;
  --text-muted: #6e7781;
  --text-faint: #8b949e;
  --border: #e5e7eb;
  --accent: #2563eb;
  --accent-soft: #eff4ff;
  --code-bg: #f6f8fa;
  --danger: #cf222e;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06);

  /* shiki 双主题渲染用的变量名，由 shiki 在行内 style 里写入实际取值，
     这里只是给 .shiki 规则做兜底占位，真正的颜色来自内联 style。 */
  --shiki-light: #24292e;
  --shiki-light-bg: #f6f8fa;
  --shiki-dark: #c9d1d9;
  --shiki-dark-bg: #0d1117;

  /* 布局尺寸 */
  --content-max: 46em;
  --page-max: 1100px;
  --radius: 6px;
}

/* ---------- 变量层：暗色覆盖 ---------- */
[data-theme="dark"] {
  --bg: #0f1115;
  --bg-elevated: #171a21;
  --bg-hover: #1e222b;
  --text: #dfe3e8;
  --text-muted: #9199a3;
  --text-faint: #7c8792;
  --border: #2a2e37;
  --accent: #6ea8ff;
  --accent-soft: #1a2740;
  --code-bg: #161b22;
  --danger: #f85149;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  transition: background-color 0.15s ease, color 0.15s ease;
}

img { max-width: 100%; }

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

ul, ol { padding-left: 1.4em; }

/* 中文没有斜体传统：全站禁用 em 的斜体，改用强调色 + 加粗代替 */
em {
  font-style: normal;
  font-weight: 600;
  color: var(--text);
}

strong { font-weight: 700; }

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}

/* 无障碍：可见的键盘焦点描边 */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ==========================================================================
   顶栏
   ========================================================================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
.brand:hover { text-decoration: none; color: var(--accent); }

.nav {
  display: flex;
  gap: 18px;
  flex: 1;
}

.nav a {
  color: var(--text-muted);
  font-size: 0.95rem;
  white-space: nowrap;
}
.nav a:hover { color: var(--text); text-decoration: none; }

.search-form input {
  width: 140px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}
.search-form input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg);
}

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--bg-hover); }

/* light 下暗示"切到暗色"，显示月亮；dark 下显示太阳，暗示"切回浅色" */
.icon-moon { display: none; }
.icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon,
:root:not([data-theme]) .theme-toggle .icon-moon { display: inline; }
[data-theme="dark"] .theme-toggle .icon-sun { display: inline; }

/* ==========================================================================
   页面骨架：container / grid 布局
   ========================================================================== */
.container {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 32px 20px 60px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 40px;
  align-items: start;
}

.container-wide {
  grid-template-columns: minmax(0, 1fr);
}
.container-wide .main { max-width: none; }

.main { min-width: 0; }

/* ==========================================================================
   侧栏 widget
   ========================================================================== */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
  /* 跟随滚动：长文往下翻时右栏不该滑走留下大片空白，
     分类/标签/归档这些跳转入口要一直够得着。
     内容比视口高时给它自己一条滚动条，否则底部会看不到。 */
  position: sticky;
  top: 76px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
/* 侧栏自身的滚动条弱化，不要喧宾夺主 */
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
.sidebar::-webkit-scrollbar-track { background: transparent; }

.widget {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.widget-title {
  margin: 0 0 12px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.widget-profile {
  text-align: center;
}

.avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--bg);
  box-shadow: var(--shadow);
}

.profile-name {
  margin: 12px 0 4px;
  font-size: 1.05rem;
}

.profile-desc {
  margin: 0 0 14px;
  font-size: 0.85rem;
  color: var(--text-muted);
}


.cat-list, .archive-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cat-list ul.cat-list {
  margin-top: 8px;
  margin-left: 4px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
  gap: 6px;
}
.cat-list ul.cat-list .cat-row { font-size: 0.85rem; }
/* 分类项恢复块级，子分类才会落在下一行；行内容交给 .cat-row */
.cat-list li { display: block; }
.cat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.9rem;
  min-width: 0;
}
.cat-row > a {
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cat-row:hover > a { color: var(--accent); }

.archive-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.9rem;
}
.archive-list a {
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.archive-list a:hover { color: var(--accent); text-decoration: none; }
.cat-row > a:hover { text-decoration: none; }

.count {
  color: var(--text-muted);
  font-size: 0.8rem;
  flex-shrink: 0;
}

/* 标签云 */
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: baseline;
}
.tag-size-1 { font-size: 0.8rem; }
.tag-size-2 { font-size: 0.95rem; }
.tag-size-3 { font-size: 1.05rem; }
.tag-size-4 { font-size: 1.18rem; }
.tag-size-5 { font-size: 1.3rem; }

/* ==========================================================================
   卡片列表（首页）
   ========================================================================== */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--text-faint);
}

.card-cover img {
  display: block;
  width: 100%;
  height: 220px;
  object-fit: cover;
}

.card-body {
  padding: 18px 20px;
}

.card-title {
  margin: 0 0 8px;
  font-size: 1.2rem;
  line-height: 1.4;
}
.card-title a { color: var(--text); }
.card-title a:hover { color: var(--accent); text-decoration: none; }

.pin-badge {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 7px;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border-radius: 3px;
  vertical-align: middle;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.card-meta a { color: var(--text-muted); }
.card-meta a:hover { color: var(--accent); }

.card-category::before { content: '📁 '; }
.views { color: var(--text-muted); }

.card-summary {
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.7;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.card-tags .tag {
  font-size: 0.8rem;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 9px;
  border-radius: 999px;
}
.card-tags .tag:hover { text-decoration: none; opacity: 0.85; }
.card-tags:empty { display: none; }

/* ==========================================================================
   紧凑行列表（分类/标签/归档/搜索结果页共用）
   ========================================================================== */
.row-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--border);
}

.row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}
.row time {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.row-title {
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-title:hover { color: var(--accent); text-decoration: none; }
.row-views {
  color: var(--text-faint);
  font-size: 0.82rem;
  flex-shrink: 0;
}

/* ==========================================================================
   分页
   ========================================================================== */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-top: 32px;
  font-size: 0.9rem;
}
.pager-prev, .pager-next {
  color: var(--text);
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.pager-prev:hover, .pager-next:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}
.pager-status { color: var(--text-muted); }

/* ==========================================================================
   通用页头
   ========================================================================== */
.page-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.page-header h1 {
  margin: 0 0 6px;
  font-size: 1.6rem;
}
.page-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

/* ==========================================================================
   分类网格页
   ========================================================================== */
.cat-grid ul
.tags-page .tag-cloud {
  padding: 8px 0;
}
.tags-page 
/* ==========================================================================
   归档页
   ========================================================================== */
.archive-group .row-list { border-top: none; }
.archive-group .row time {
  width: 4.5em;
  flex-shrink: 0;
}

/* ==========================================================================
   文章页
   ========================================================================== */
.post { max-width: var(--content-max); margin: 0 auto; }
.container-wide .post { margin: 0; }

.post-header {
  margin-bottom: 28px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.post-title {
  margin: 0 0 12px;
  font-size: 1.8rem;
  line-height: 1.4;
}
.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  font-size: 0.88rem;
  color: var(--text-muted);
}
.post-meta a { color: var(--text-muted); }
.post-meta a:hover { color: var(--accent); }

.post-footer {
  margin-top: 36px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.post-footer .card-tags .tag {
  padding: 3px 11px;
}

/* ---------- 正文排版：中文优化 ---------- */
.post-content {
  font-size: 17px;
  line-height: 1.8;
  color: var(--text);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.post-content > * + * { margin-top: 1.2em; }

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
  margin-top: 1.8em;
  margin-bottom: 0.6em;
  position: relative;          /* 供 ::before / ::after 装饰定位 */
  line-height: 1.45;
  font-weight: 700;
  scroll-margin-top: 90px;
  /* 中文标题里的英文与数字排版更紧凑些 */
  font-feature-settings: "tnum";
}
/* ---------- 标题层级：靠形态而非仅靠字号拉开差别 ----------
   h2 章节：通栏细线 + 左端一小截强调色，像书里的章隔断
   h3 小节：左侧短竖条，文字随之内缩，形成从属关系
   h4 段落级：降到次要色、字重收一档，只做轻微区分
   一级标题正文里通常没有（会被当作文章标题抽走），保留兜底样式。 */

.post-content h1 {
  font-size: 1.6em;
  margin-top: 1.2em;
  letter-spacing: -0.01em;
}

.post-content h2 {
  font-size: 1.38em;
  margin-top: 2.6em;
  margin-bottom: 0.9em;
  padding-bottom: 0.42em;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.01em;
}
/* 细线左端压一小截强调色，比通栏一条线更有指向性 */
.post-content h2::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 2.2em;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.post-content h3 {
  font-size: 1.15em;
  margin-top: 2em;
  margin-bottom: 0.7em;
  padding-left: 14px;
}
.post-content h3::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.22em;
  bottom: 0.22em;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0.6;
}

.post-content h4 {
  font-size: 1.02em;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 1.7em;
  margin-bottom: 0.5em;
}

.post-content h5,
.post-content h6 {
  font-size: 0.96em;
  font-weight: 600;
  color: var(--text-faint);
  margin-top: 1.5em;
}

/* 标题紧挨着的第一段收紧，让标题与其内容成为一组 */
.post-content :is(h2, h3, h4) + p,
.post-content :is(h2, h3, h4) + ul,
.post-content :is(h2, h3, h4) + ol,
.post-content :is(h2, h3, h4) + blockquote { margin-top: 0.6em; }

/* 正文开头的标题不要顶出一大片空白 */
.post-content > :is(h1, h2, h3, h4):first-child { margin-top: 0; }

/* ---------- 悬停锚点 ---------- */
.post-content .heading-anchor {
  margin-left: 0.4em;
  color: var(--text-faint);
  font-weight: 400;
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
}
.post-content :is(h1, h2, h3, h4, h5, h6):hover .heading-anchor { opacity: 1; }
.post-content .heading-anchor:hover { color: var(--accent); text-decoration: none; }
.post-content .heading-anchor:focus-visible { opacity: 1; }

/* 触屏没有 hover，长期显示一个淡符号即可，不然永远点不到 */
@media (hover: none) {
  .post-content .heading-anchor { opacity: 0.35; }
}

/* ---------- 窄屏：整体收一档，避免标题占满整行 ---------- */
@media (max-width: 600px) {
  .post-content h1 { font-size: 1.4em; }
  .post-content h2 { font-size: 1.24em; margin-top: 2.1em; }
  .post-content h3 { font-size: 1.08em; margin-top: 1.7em; padding-left: 11px; }
  .post-content h4 { font-size: 1em; }
}

.post-content p { margin: 1.2em 0; }
.post-content ul, .post-content ol { margin: 1.2em 0; padding-left: 1.6em; }
.post-content li + li { margin-top: 0.4em; }
.post-content li > p { margin: 0.5em 0; }

.post-content blockquote {
  margin: 1.2em 0;
  padding: 4px 18px;
  border-left: 3px solid var(--accent);
  background: var(--bg-elevated);
  color: var(--text-muted);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.post-content blockquote > *:first-child { margin-top: 0; }
.post-content blockquote > *:last-child { margin-bottom: 0; }

.post-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.2em auto;
  border-radius: var(--radius);
  cursor: zoom-in;
}

.post-content hr { margin: 2em 0; }

/* 行内代码 */
.post-content :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  color: var(--text);
}

/* 代码块容器：给复制按钮定位，允许横向滚动而不撑破布局 */
.post-content pre {
  position: relative;
  margin: 1.2em 0;
  padding: 16px 18px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.88em;
  line-height: 1.6;
  border: 1px solid var(--border);
}
.post-content pre code {
  font-family: var(--font-mono);
  background: none;
  padding: 0;
  border-radius: 0;
}

/* shiki 双主题接线：关键，靠 CSS 变量在两套内联颜色间切换 */
.shiki, .shiki span {
  color: var(--shiki-light);
  background-color: var(--shiki-light-bg);
}
[data-theme="dark"] .shiki, [data-theme="dark"] .shiki span {
  color: var(--shiki-dark);
  background-color: var(--shiki-dark-bg);
}
.post-content pre.shiki {
  background-color: var(--shiki-light-bg);
}
[data-theme="dark"] .post-content pre.shiki {
  background-color: var(--shiki-dark-bg);
}

/* 代码复制按钮：默认透明，悬浮代码块时才显现 */
.code-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-family: var(--font-sans);
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.post-content pre:hover .code-copy,
.code-copy:focus-visible {
  opacity: 1;
}
.code-copy:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* mermaid 图表容器 */
.post-content pre.mermaid,
.mermaid {
  background: var(--bg);
  border: 1px solid var(--border);
  text-align: center;
  overflow-x: auto;
  padding: 16px;
}
.mermaid svg { max-width: 100%; height: auto; }
.mermaid-error {
  color: var(--danger);
  background: var(--bg-elevated);
  border: 1px dashed var(--danger);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 0.85rem;
  font-family: var(--font-mono);
  white-space: pre-wrap;
}

/* 表格：包裹容器横向滚动，避免撑破布局 */
.table-wrapper {
  overflow-x: auto;
  margin: 1.2em 0;
}
.post-content table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.92em;
}
.post-content th, .post-content td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}
.post-content th {
  background: var(--bg-elevated);
  font-weight: 700;
}
.post-content tr:nth-child(even) td {
  background: var(--bg-elevated);
}

/* KaTeX 公式：长公式横向滚动而不撑破布局 */
.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0;
}

/* 脚注 */
.post-content .footnotes {
  margin-top: 2.4em;
  padding-top: 1em;
  border-top: 1px solid var(--border);
  font-size: 0.85em;
  color: var(--text-muted);
}
.post-content .footnotes-list { padding-left: 1.4em; }


/* ==========================================================================
   搜索页
   ========================================================================== */
.search-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.search-item {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.search-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}
.search-title:hover { color: var(--accent); text-decoration: none; }
.search-snippet {
  margin: 6px 0;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.7;
}
.search-snippet mark {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 2px;
  padding: 0 1px;
}

/* ==========================================================================
   空状态 / 404
   ========================================================================== */
.empty {
  color: var(--text-faint);
  font-size: 0.92rem;
  padding: 24px 0;
  text-align: center;
}
li.empty { border: none; padding: 24px 4px; }

.notfound {
  max-width: var(--content-max);
  margin: 80px auto;
  text-align: center;
}
.notfound h1 {
  font-size: 4rem;
  margin: 0;
  color: var(--text-faint);
}
.notfound p {
  color: var(--text-muted);
  margin: 10px 0;
}

/* ==========================================================================
   图片放大弹窗（由脚本在点击 .post-content img 时创建/移除）
   ========================================================================== */
.image-dialog {
  /* 重置 UA 默认的 margin:auto / width:fit-content / border:solid，
     否则 fixed+inset:0 只会让浏览器把「贴合内容大小的盒子」居中显示，
     变成一个围着图片的小方框，而不是撑满视口的遮罩。 */
  margin: 0;
  border: none;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  position: fixed;
  inset: 0;
  z-index: 100;
  padding: 40px;
  overflow: hidden;
  flex-direction: column;        /* 上到下：图片区 / 工具栏 / 说明 */
  background: transparent;       /* 变暗交给 ::backdrop，自身保持透明 */
  cursor: zoom-out;              /* 点空白处即关闭 */
}

/* display 必须只在打开时生效。
   UA 样式表里有 dialog:not([open]) { display: none }，但**作者样式的优先级
   高于 UA 样式**——在上面无条件写 display:flex 会把它顶掉，弹窗关闭后图片和
   工具栏仍然留在屏幕上，表现就是「ESC 和点背景都关不掉」。 */
.image-dialog[open] { display: flex; }
.image-dialog:not([open]) { display: none; }

/* showModal() 打开时浏览器绘制的独立遮罩层 */
.image-dialog::backdrop {
  background: rgba(15, 17, 21, 0.85);
}


/* ==========================================================================
   页脚
   ========================================================================== */
.footer {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 30px 20px 50px;
  text-align: center;
  color: var(--text-faint);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}
.footer p { margin: 6px 0; }
.footer-links a {
  color: var(--text-muted);
  margin: 0 4px;
}
.footer-links a:hover { color: var(--accent); }

/* ==========================================================================
   响应式
   ========================================================================== */
@media (max-width: 900px) {
  .container {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar {
    order: 2;
    /* 已下沉到正文下方，不再吸顶 */
    position: static;
    max-height: none;
    overflow: visible;
  }
  .main {
    order: 1;
  }
  .toc {
    position: static;
    max-height: none;
  }
  .card-cover img { height: 180px; }
}

@media (max-width: 600px) {
  .topbar-inner {
    gap: 14px;
    padding: 12px 16px;
  }
  .nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 14px;
    flex: none;
    max-width: 40vw;
  }
  .nav::-webkit-scrollbar { display: none; }
  .search-form { display: none; }
  .container {
    padding: 20px 16px 40px;
    gap: 24px;
  }
  .post-title { font-size: 1.4rem; }
  .post-content { font-size: 16px; }

  /* 窄屏下 TOC 默认收起：直接隐藏整块，而非折叠成矮盒子仍占位。
     纯 CSS 无法响应点击展开，若要"收起但可展开"需要 JS 配合（见任务报告）；
     这里选择更简单克制的方案——窄屏读长文时目录本就少用，直接不占首屏空间。 */
  .toc {
    display: none;
  }

    }

/* 打印时隐藏与内容无关的元素 */
@media print {
  .topbar, .sidebar, .footer, .pager, .code-copy, .theme-toggle { display: none; }
  .container { grid-template-columns: 1fr; }
}

/* ==========================================================================
   HTML 资料内嵌（iframe）
   独立 HTML 资料自带整套设计，用 iframe 做样式隔离，避免两边 CSS 互相污染。
   ========================================================================== */
.embed-frame {
  margin: 24px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-elevated);
}
.embed-frame iframe {
  display: block;
  width: 100%;
  /* 初始高度给一个够用的值，加载后由 app.js 按真实内容高度校正 */
  height: 80vh;
  border: 0;
}
/* 内嵌页正文不受 46em 宽度限制——原页面有自己的排版 */
.post-embed .embed-frame { max-width: none; }
.raw-link {
  margin-left: auto;
  font-size: 0.85rem;
  white-space: nowrap;
}
@media (max-width: 600px) {
  .embed-frame iframe { height: 70vh; }
  .raw-link { margin-left: 0; }
}

/* ==========================================================================
   左栏文章目录（树形 · 可折叠 · 跟随阅读位置）
   md 文章页专用：左栏放目录，中间正文，右栏保持站点导航不变。
   ========================================================================== */

/* 有左栏时切换为三栏。页宽也相应放宽，否则正文会被挤得太窄。 */
.container-toc {
  max-width: 1400px;
  grid-template-columns: 240px minmax(0, 1fr) 280px;
}

.left-aside {
  min-width: 0;
  position: sticky;
  top: 76px;                        /* 顶栏高度 + 一点呼吸 */
  max-height: calc(100vh - 96px);
  display: flex;
  flex-direction: column;
}

.toc-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 12px;
  font-size: 0.86rem;
  overflow-y: auto;
  overscroll-behavior: contain;     /* 目录滚到底不要带着整页一起滚 */
}

.toc-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.toc-panel-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
}
.toc-expand-all {
  border: none;
  background: none;
  padding: 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
}
.toc-expand-all:hover { color: var(--accent); }

.toc-tree, .toc-children {
  list-style: none;
  margin: 0;
  padding: 0;
}
/* 折叠动画走 grid-template-rows（比 max-height 更贴合真实高度）。
   注意它只压缩第一行，所以必须套在只有一个子元素的 .toc-sub 上，
   直接加在 ul 上会导致除第一个 li 之外的条目照常显示。 */
.toc-sub {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.18s ease;
}
.toc-sub > .toc-children { overflow: hidden; }
.toc-node.is-open > .toc-sub { grid-template-rows: 1fr; }

.toc-row {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  border-radius: 4px;
  padding: 3px 4px;
}
.toc-row:hover { background: var(--bg-hover); }

.toc-toggle {
  flex-shrink: 0;
  width: 16px;
  height: 20px;
  border: none;
  background: none;
  padding: 0;
  color: var(--text-faint);
  cursor: pointer;
  line-height: 20px;
  font-size: 0.7rem;
}
.toc-toggle span {
  display: inline-block;
  transition: transform 0.18s ease;
}
.toc-node.is-open > .toc-row .toc-toggle span { transform: rotate(90deg); }
.toc-toggle:hover { color: var(--text); }

/* 叶子节点没有折叠按钮，用一个小圆点占位保持左边缘对齐 */
.toc-bullet {
  flex-shrink: 0;
  width: 16px;
  height: 20px;
  position: relative;
}
.toc-bullet::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 9px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-faint);
}

.toc-link {
  color: var(--text-muted);
  line-height: 1.5;
  min-width: 0;
  word-break: break-word;
}
.toc-link:hover { color: var(--text); text-decoration: none; }

/* 层级缩进：靠子层容器整体左移，而不是给每个节点单独设 padding */
.toc-children .toc-row { padding-left: 14px; }
.toc-children .toc-children .toc-row { padding-left: 26px; }

/* 层级字号递减，形成"详略"的视觉层次 */
.toc-l2 > .toc-row > .toc-link { font-size: 0.86rem; }
.toc-l3 > .toc-row > .toc-link { font-size: 0.82rem; }
.toc-l4 > .toc-row > .toc-link { font-size: 0.78rem; color: var(--text-faint); }

/* 当前正在读的那一节 */
.toc-node.is-current > .toc-row {
  background: var(--accent-soft);
}
.toc-node.is-current > .toc-row > .toc-link {
  color: var(--accent);
  font-weight: 600;
}
/* 当前节点所在的祖先链：加一条竖线，指明"读到哪一块了" */
.toc-node.is-active-branch > .toc-row > .toc-link {
  color: var(--text);
  font-weight: 600;
}
.toc-node.is-active-branch > .toc-sub > .toc-children {
  border-left: 2px solid var(--accent);
  margin-left: 11px;
}
.toc-node.is-active-branch > .toc-sub .toc-row { padding-left: 4px; }
.toc-node.is-active-branch > .toc-sub .toc-sub .toc-row { padding-left: 16px; }

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

/* 放不下三栏时，右栏先下沉，左栏目录保留（读长文时目录比站点导航更常用） */
@media (max-width: 1180px) {
  .container-toc {
    max-width: var(--page-max);
    grid-template-columns: 220px minmax(0, 1fr);
  }
  .container-toc .sidebar {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    /* 横向铺在正文下方，吸顶失去意义 */
    position: static;
    max-height: none;
    overflow: visible;
  }
}

/* 窄屏：单栏。目录移到正文上方，并默认折叠成一条，点标题展开。
   否则在手机上要先划过一大段目录才看得到正文。 */
@media (max-width: 900px) {
  .container-toc { grid-template-columns: minmax(0, 1fr); }
  .container-toc .sidebar {
    grid-column: auto;
    position: static;
    max-height: none;
    overflow: visible;
  }
  .left-aside {
    position: static;
    max-height: none;
    order: -1;                       /* 排到正文前面 */
  }
  .toc-panel { max-height: 50vh; }
  .toc-panel-head { cursor: pointer; margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
  .toc-panel:not(.is-collapsed) .toc-panel-head {
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
  }
  .toc-panel.is-collapsed .toc-tree { display: none; }
  /* 折叠指示箭头，只在窄屏出现 */
  .toc-panel-title::after {
    content: "▾";
    display: inline-block;
    margin-left: 6px;
    font-size: 0.75em;
    color: var(--text-faint);
    transition: transform 0.18s ease;
  }
  .toc-panel.is-collapsed .toc-panel-title::after { transform: rotate(-90deg); }
}

/* 锚点跳转：让目标标题避开吸顶导航。
   这里刻意**不加** scroll-behavior: smooth —— 实测在部分环境（如自动化浏览器）
   它会让 window.scrollTo 整个失效、点目录完全不跳。跳转能用远比跳转有动画重要，
   所以宁可要瞬间定位。同理 JS 里也不传 behavior:'smooth'。 */
.post-content h2,
.post-content h3,
.post-content h4 {
  scroll-margin-top: 80px;
}

/* ==========================================================================
   回到顶部
   ========================================================================== */
.back-to-top {
  position: fixed;
  right: 28px;
  /* 给 iPhone 底部安全区留位，否则会被小白条压住 */
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: pointer;
  box-shadow: var(--shadow);
  /* 默认不可见也不可点，滚动到一定距离后由 JS 加 .is-visible */
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease,
              visibility 0.2s, background-color 0.15s ease, color 0.15s ease;
}
.back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: none;
}
.back-to-top:hover {
  background: var(--bg-hover);
  color: var(--accent);
  border-color: var(--accent);
}
.back-to-top:active { transform: translateY(1px); }

/* 移动端：挪到更顺手的位置，并放大到手指够得着的尺寸 */
@media (max-width: 600px) {
  .back-to-top {
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    width: 44px;      /* 44px 是触摸目标的下限 */
    height: 44px;
  }
}

/* 系统设置了减少动画时，不做位移过渡 */
@media (prefers-reduced-motion: reduce) {
  .back-to-top { transition: opacity 0.2s ease, visibility 0.2s; transform: none; }
  .back-to-top.is-visible { transform: none; }
}

/* 打印时不需要这个按钮 */
@media print {
  .back-to-top { display: none; }
}

/* ==========================================================================
   分类页：树形 + 下挂文章索引
   ========================================================================== */
.cat-tree, .cat-posts {
  list-style: none;
  margin: 0;
  padding: 0;
}
.cat-node { margin-bottom: 28px; }

.cat-node-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.cat-node-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  position: relative;
  padding-left: 14px;
}
/* 分类名前一小段强调色，和正文 h3 的处理呼应 */
.cat-node-name::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.22em;
  bottom: 0.22em;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
}
.cat-node-name:hover { color: var(--accent); text-decoration: none; }
.cat-node-count {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.cat-posts { margin: 10px 0 0; }
.cat-post {
  padding: 8px 0 8px 14px;
  border-left: 1px solid var(--border);
  margin-left: 1px;
}
.cat-post:hover { border-left-color: var(--accent); }
.cat-post-title {
  color: var(--text);
  font-weight: 500;
}
.cat-post-title:hover { color: var(--accent); text-decoration: none; }
.cat-post-meta {
  display: flex;
  gap: 10px;
  margin-top: 2px;
  font-size: 0.82rem;
  color: var(--text-muted);
  min-width: 0;
}
.cat-post-meta time { flex-shrink: 0; }
.cat-post-summary {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 子分类整体缩进，形成层级 */
.cat-subtree {
  margin: 16px 0 0 16px;
  padding-left: 16px;
  border-left: 2px solid var(--border);
}
.cat-subtree .cat-node { margin-bottom: 18px; }
.cat-subtree .cat-node-name { font-size: 1.02rem; }

/* ==========================================================================
   标签页：彩色区块
   颜色由每块行内的 --tag-hue 驱动，饱和度与明度在这里按主题统一定，
   保证深浅色下都不刺眼、也不糊。
   ========================================================================== */
.tag-blocks {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.tag-block {
  --tag-color: hsl(var(--tag-hue) 62% 42%);
  --tag-bg: hsl(var(--tag-hue) 70% 96%);
  --tag-border: hsl(var(--tag-hue) 55% 86%);
  display: flex;
  flex-direction: column;
  padding: 14px 16px;
  border: 1px solid var(--tag-border);
  border-radius: var(--radius);
  background: var(--tag-bg);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
[data-theme="dark"] .tag-block {
  --tag-color: hsl(var(--tag-hue) 65% 72%);
  --tag-bg: hsl(var(--tag-hue) 32% 14%);
  --tag-border: hsl(var(--tag-hue) 28% 26%);
}
.tag-block:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.tag-block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--tag-border);
}
.tag-block-head:hover { text-decoration: none; }
.tag-block-name {
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--tag-color);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tag-block-count {
  flex-shrink: 0;
  font-size: 0.76rem;
  color: var(--tag-color);
  opacity: 0.75;
}

.tag-block-posts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.tag-block-posts a {
  color: var(--text);
  font-size: 0.86rem;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tag-block-posts a:hover { color: var(--tag-color); text-decoration: none; }

.tag-block-more {
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--tag-color);
  align-self: flex-start;
}

/* ==========================================================================
   归档页：按年分组的时间线，最新在最上
   ========================================================================== */
.archive-timeline { margin-top: 8px; }

.archive-year { margin-bottom: 36px; }
.archive-year-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 18px;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.archive-year-num { color: var(--text); }
.archive-year-count {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-muted);
}

.archive-nodes {
  list-style: none;
  margin: 0;
  padding: 0 0 0 8px;
  /* 贯穿全年的时间轴 */
  border-left: 2px solid var(--border);
}

.archive-node {
  position: relative;
  padding: 0 0 22px 22px;
}
/* 线上的节点圆点 */
.archive-node::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
}
.archive-node:last-child { padding-bottom: 4px; }

.archive-month {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  font-weight: 600;
  color: var(--text);
}
.archive-month:hover { color: var(--accent); text-decoration: none; }
.archive-month-count {
  font-size: 0.74rem;
  font-weight: 400;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 7px;
}

.archive-posts {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}
.archive-posts li {
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 4px 0;
  min-width: 0;
}
.archive-posts time {
  flex-shrink: 0;
  font-size: 0.8rem;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.archive-posts a {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.archive-posts a:hover { color: var(--accent); text-decoration: none; }

/* ---------- 窄屏 ---------- */
@media (max-width: 600px) {
  .tag-blocks { grid-template-columns: 1fr; }
  .cat-post-summary { display: none; }   /* 手机上摘要挤成一条，不如不显示 */
  .archive-year-head { font-size: 1.28rem; }
  .archive-node { padding-left: 18px; }
  .archive-posts li { flex-direction: column; gap: 2px; }
}

/* ==========================================================================
   侧栏统计：三项都可点，给足点击反馈
   ========================================================================== */
.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  gap: 4px;
}
.profile-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 2px;
  border-radius: var(--radius);
  color: var(--text);
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.profile-stat:hover {
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
  transform: translateY(-1px);
}
.profile-stat:hover .profile-stat-label { color: var(--accent); }
.profile-stat:active { transform: none; }
.profile-stat-num {
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.profile-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: color 0.15s ease;
}

/* ==========================================================================
   侧栏标签小块：与标签页同一套色相，字号仍按热度分级
   ========================================================================== */
.tag-chip {
  --chip-color: hsl(var(--tag-hue) 60% 38%);
  --chip-bg: hsl(var(--tag-hue) 72% 95%);
  --chip-border: hsl(var(--tag-hue) 52% 87%);
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 3px 9px;
  border: 1px solid var(--chip-border);
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--chip-color);
  line-height: 1.4;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}
[data-theme="dark"] .tag-chip {
  --chip-color: hsl(var(--tag-hue) 65% 74%);
  --chip-bg: hsl(var(--tag-hue) 30% 16%);
  --chip-border: hsl(var(--tag-hue) 26% 28%);
}
.tag-chip:hover {
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
  filter: brightness(1.04);
}
.tag-chip-count {
  font-size: 0.72em;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

/* 热度分级：热门标签的块更大一些 */
.tag-chip.tag-size-1 { font-size: 0.76rem; }
.tag-chip.tag-size-2 { font-size: 0.82rem; }
.tag-chip.tag-size-3 { font-size: 0.88rem; }
.tag-chip.tag-size-4 { font-size: 0.94rem; }
.tag-chip.tag-size-5 { font-size: 1rem; }

/* 侧栏里的标签云排得紧凑些 */
.sidebar .tag-cloud { gap: 6px; }

/* 分类与归档列表也补上 hover 反馈，与统计项保持一致 */
.cat-list li:hover > a,
.archive-list li:hover > a { color: var(--accent); }

/* ==========================================================================
   侧栏个人信息块：整体可点回首页 + 悬停动效
   ========================================================================== */
.profile-link {
  display: block;
  color: inherit;
  border-radius: var(--radius);
  padding: 4px 0 2px;
  transition: transform 0.18s ease;
}
.profile-link:hover { text-decoration: none; }

/* 头像：放大一点并浮起，圆环换成强调色 */
.avatar {
  transition: transform 0.22s cubic-bezier(0.34, 1.3, 0.64, 1),
              box-shadow 0.22s ease, border-color 0.22s ease;
}
.profile-link:hover .avatar {
  transform: scale(1.07);
  border-color: var(--accent-soft);
  box-shadow: 0 4px 14px rgba(16, 24, 40, 0.14);
}
[data-theme="dark"] .profile-link:hover .avatar {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

/* 名字跟着变强调色，简介稍微提亮，整体像"一块"在响应 */
.profile-name { transition: color 0.18s ease; }
.profile-desc { transition: color 0.18s ease; }
.profile-link:hover .profile-name { color: var(--accent); }
.profile-link:hover .profile-desc { color: var(--text); }

.profile-link:active .avatar { transform: scale(1.02); }

/* 键盘聚焦时同样给出反馈，不能只照顾鼠标 */
.profile-link:focus-visible .avatar {
  transform: scale(1.07);
  border-color: var(--accent);
}

/* 系统要求减少动画时，只保留颜色变化，不做缩放 */
@media (prefers-reduced-motion: reduce) {
  .avatar, .profile-link { transition: none; }
  .profile-link:hover .avatar,
  .profile-link:focus-visible .avatar,
  .profile-link:active .avatar { transform: none; }
}

/* ==========================================================================
   首页照片条（横向轮播）
   用原生横向滚动容器：惯性、触摸滑动、键盘都由浏览器负责，
   脚本只管左右按钮与自动播放。
   ========================================================================== */
.photo-strip { margin-bottom: 28px; }

.strip-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}
.strip-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
}
.strip-more {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.strip-more:hover { color: var(--accent); text-decoration: none; }

.strip-viewport { position: relative; }

.strip-track {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-behavior: auto;          /* 平滑滚动由脚本按需处理，见 app.js 的说明 */
  /* 不做 scroll-snap：轮播是逐帧匀速推进的，吸附会每帧把它往回拽，反而更顿 */
  scrollbar-width: none;          /* 滚动条藏起来，靠按钮和滑动操作 */
  padding-bottom: 2px;
}
.strip-track::-webkit-scrollbar { display: none; }

.strip-item {
  flex: 0 0 auto;
}
.strip-item a {
  display: block;
  position: relative;
  width: 210px;
  height: 140px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}
.strip-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}
.strip-item a:hover img { transform: scale(1.05); }
.strip-item a:hover { text-decoration: none; }

/* 描述压在图片底部，渐变保证任何底色上都读得清 */
.strip-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 16px 10px 7px;
  font-size: 0.78rem;
  color: #fff;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.62), transparent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.strip-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  opacity: 0.92;
}
.strip-nav:hover { color: var(--accent); border-color: var(--accent); opacity: 1; }
.strip-prev { left: -8px; }
.strip-next { right: -8px; }
.strip-nav[hidden] { display: none; }

/* ==========================================================================
   相册页
   ========================================================================== */
.gallery-group { margin-bottom: 34px; }
.gallery-group-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 14px;
  font-size: 1.12rem;
  font-weight: 700;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.gallery-group-count {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-muted);
}

.gallery-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.gallery-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-elevated);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.gallery-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.gallery-item img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}
.gallery-caption {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  font-size: 0.8rem;
  min-width: 0;
}
.gallery-desc {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gallery-date {
  flex-shrink: 0;
  color: var(--text-faint);
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 600px) {
  .strip-item a { width: 160px; height: 108px; }
  .strip-nav { display: none; }        /* 手机上直接滑，不需要按钮 */
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
}

/* ==========================================================================
   看图器：缩放 / 旋转 / 拖动
   ========================================================================== */
/* .image-dialog 自身的样式统一在上面「图片放大弹窗」一节，不在这里重复定义 */

.lightbox-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  /* 这块空白也是"灰色背景"，点它同样关闭（见 app.js） */
  cursor: zoom-out;
}
.lightbox-stage img {
  max-width: 92%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  cursor: default;
  /* transform 由脚本设置；这里只定过渡与变换原点 */
  transform-origin: center center;
  transition: transform 0.16s ease-out;
  user-select: none;
  -webkit-user-drag: none;
}
.lightbox-stage.is-pannable img { cursor: grab; }
.lightbox-stage.is-dragging img {
  cursor: grabbing;
  transition: none;              /* 拖动时要跟手，不能有过渡 */
}

.lightbox-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  background: rgba(20, 22, 28, 0.72);
  backdrop-filter: blur(6px);
}
.lightbox-bar button {
  min-width: 34px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: #e8ecf3;
  font-size: 0.92rem;
  font-family: inherit;
  cursor: pointer;
  line-height: 1;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.lightbox-bar button:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.32);
}
.lightbox-zoom {
  min-width: 52px;
  text-align: center;
  color: #b9c2d0;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}
.lightbox-sep {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.18);
  margin: 0 4px;
}

.lightbox-caption {
  flex-shrink: 0;
  margin: 0;
  padding: 0 16px 12px;
  text-align: center;
  color: #cfd6e0;
  font-size: 0.86rem;
  background: rgba(20, 22, 28, 0.72);
}
.lightbox-caption[hidden] { display: none; }

@media (max-width: 600px) {
  .lightbox-bar { gap: 4px; padding: 8px 6px calc(8px + env(safe-area-inset-bottom, 0px)); }
  .lightbox-bar button { min-width: 30px; height: 30px; padding: 0 7px; font-size: 0.85rem; }
  .lightbox-zoom { min-width: 44px; font-size: 0.74rem; }
}

/* 系统要求减少动画时，缩放旋转直接到位，不做过渡 */
@media (prefers-reduced-motion: reduce) {
  .lightbox-stage img { transition: none; }
}
