/* ============================================================
   RengeTTT's BLOG · 设计系统 v2
   设计语言：极光背景层 / 玻璃拟态卡片 / 大字号渐变标题 /
             编号式文章卡片 / 欢迎界面
   约定（历史教训固化）：
   - 所有状态切换由 JS + 定时器兜底，动画只做装饰
   - 首帧前由内联脚本预置主题 / 演示模式 / 欢迎页状态
   - 装饰层与覆盖层都在内容层之外，不参与布局
   ============================================================ */

/* ---------------- 设计令牌 ---------------- */

:root {
  --bg: #f6f5f1;
  --fg: #191c1f;
  --muted: #686f78;
  --card: rgba(255, 255, 255, 0.72);
  --border: rgba(25, 28, 31, 0.10);
  --border-weak: rgba(25, 28, 31, 0.06);
  --accent: #0c7e62;
  --accent-2: #6d5ef0;
  --accent-weak: rgba(14, 143, 111, 0.10);
  --code-bg: #edece7;
  --sphere-bg: #eef0ea;
  --glass: rgba(255, 255, 255, 0.66);
  --aurora-o: 0.30;
  --header-bg: rgba(246, 245, 241, 0.72);
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #0a0c0f;
  --fg: #e6e8ea;
  --muted: #8b929b;
  --card: rgba(22, 26, 31, 0.72);
  --border: rgba(230, 235, 240, 0.10);
  --border-weak: rgba(230, 235, 240, 0.06);
  --accent: #4cc2a0;
  --accent-2: #8b7cf6;
  --accent-weak: rgba(76, 194, 160, 0.12);
  --code-bg: #171a1f;
  --sphere-bg: #12151a;
  --glass: rgba(16, 19, 24, 0.62);
  --aurora-o: 0.50;
  --header-bg: rgba(10, 12, 15, 0.68);
  color-scheme: dark;
}

/* 强调色底的近黑前景：白字在暗色 accent 上只有 2.20:1、亮色 4.06:1；
   加 html 前缀提升优先级，压过 .chip.active / .admin-btn-primary 等原规则 */
html .chip.active,
html .admin-btn-primary,
html .admin-btn.active,
html .avatar-fallback { color: #06120e; }

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --bg: #0a0c0f;
    --fg: #e6e8ea;
    --muted: #8b929b;
    --card: rgba(22, 26, 31, 0.72);
    --border: rgba(230, 235, 240, 0.10);
    --border-weak: rgba(230, 235, 240, 0.06);
    --accent: #4cc2a0;
    --accent-2: #8b7cf6;
    --accent-weak: rgba(76, 194, 160, 0.12);
    --code-bg: #171a1f;
    --sphere-bg: #12151a;
    --glass: rgba(16, 19, 24, 0.62);
    --aurora-o: 0.50;
    --header-bg: rgba(10, 12, 15, 0.68);
    color-scheme: dark;
  }
}

/* ---------------- 基础 ---------------- */

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg); /* html 层先于 body 具备正确底色，避免导航间隙白闪 */
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.7;
  font-size: 16px;
  min-height: 100vh;
  overflow-x: hidden;
}

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

::selection { background: var(--accent-weak); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 8px;
  border: 2px solid var(--bg);
}

.wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 20px;
}

main, .site-footer { position: relative; z-index: 1; }

/* ---------------- 极光背景层（最底层装饰） ---------------- */

.aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.aurora i {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: var(--aurora-o);
  will-change: transform;
}

.aurora .a1 {
  width: 560px; height: 560px;
  background: radial-gradient(circle, rgba(76, 194, 160, 0.55), transparent 68%);
  top: -160px; left: -140px;
  animation: aurora-drift 26s ease-in-out infinite alternate;
}

.aurora .a2 {
  width: 620px; height: 620px;
  background: radial-gradient(circle, rgba(139, 124, 246, 0.40), transparent 68%);
  bottom: -220px; right: -160px;
  animation: aurora-drift 32s ease-in-out infinite alternate-reverse;
}

.aurora .a3 {
  width: 380px; height: 380px;
  background: radial-gradient(circle, rgba(76, 160, 194, 0.30), transparent 70%);
  top: 34%; left: 52%;
  animation: aurora-drift 22s ease-in-out infinite alternate;
}

@keyframes aurora-drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(60px, 40px) scale(1.15); }
}

/* 欢迎界面待挂载期间隐藏正文（2.6s 兜底自动显示，防脚本异常白屏） */
html.welcome-pending main,
html.welcome-pending .site-header,
html.welcome-pending .site-footer,
html.welcome-pending .side-deco,
html.welcome-pending .demo-banner,
html.welcome-pending #scroll-rail {
  visibility: hidden;
}

/* ---------------- 欢迎界面 ---------------- */

.welcome {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #07090c;
  color: #e8eaec;
  overflow: hidden;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.welcome.leaving {
  opacity: 0;
  transform: scale(1.06);
  pointer-events: none;
}

.wl-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

.wl-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 0 24px;
  max-width: 860px;
}

.wl-eyebrow {
  font-size: 12px;
  letter-spacing: 6px;
  text-transform: uppercase;
  color: rgba(232, 234, 236, 0.5);
  animation: wl-rise 0.7s 0.1s both;
}

.wl-title {
  margin: 18px 0 10px;
  font-size: clamp(46px, 9vw, 96px);
  font-weight: 800;
  line-height: 1.2;
  padding-bottom: 0.1em; /* 同 hero-title：给下伸部留出绘制空间 */
  letter-spacing: 2px;
  color: #e8eaec;
  text-shadow: 0 0 60px rgba(76, 194, 160, 0.35);
}

.wl-title .wl-ch {
  display: inline-block;
  animation: wl-ch-in 0.55s cubic-bezier(0.22, 0.9, 0.3, 1) both;
  animation-delay: calc(0.25s + var(--i) * 0.05s);
}

@keyframes wl-ch-in {
  from { opacity: 0; transform: translateY(26px) rotate(4deg); }
  to   { opacity: 1; transform: none; }
}

.wl-sub {
  color: rgba(232, 234, 236, 0.62);
  font-size: 15px;
  letter-spacing: 1px;
  animation: wl-rise 0.7s 0.75s both;
}

.wl-enter {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 42px;
  padding: 14px 38px;
  border: 1px solid rgba(76, 194, 160, 0.55);
  border-radius: 999px;
  background: rgba(76, 194, 160, 0.10);
  color: #e8eaec;
  font-size: 15px;
  letter-spacing: 4px;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.25s ease, background 0.25s ease, transform 0.25s ease,
    box-shadow 0.25s ease;
  animation: wl-rise 0.7s 0.95s both;
}

.wl-enter::after {
  content: "";
  position: absolute;
  top: 0; left: -80%;
  width: 50%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.16), transparent);
  transform: skewX(-18deg);
  transition: left 0.55s ease;
}

.wl-enter:hover {
  border-color: rgba(76, 194, 160, 0.95);
  background: rgba(76, 194, 160, 0.20);
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(76, 194, 160, 0.25);
}

.wl-enter:hover::after { left: 130%; }

.wl-enter .wl-arrow { transition: transform 0.25s ease; }
.wl-enter:hover .wl-arrow { transform: translateX(5px); }

.wl-hint {
  margin-top: 22px;
  font-size: 12px;
  color: rgba(232, 234, 236, 0.35);
  letter-spacing: 1px;
  animation: wl-rise 0.7s 1.15s both;
}

.wl-footer {
  position: absolute;
  bottom: 26px;
  left: 0; right: 0;
  text-align: center;
  font-size: 11px;
  letter-spacing: 3px;
  color: rgba(232, 234, 236, 0.28);
  animation: wl-rise 0.7s 1.25s both;
}

@keyframes wl-rise {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}

/* ---------------- 演示模式横幅 ----------------
   高度过渡驱动：首帧前由内联脚本恢复（零位移），
   运行时检测到降级则平滑展开；后端恢复后自动收起 */

.demo-banner {
  display: none;
  overflow: hidden;
  max-height: 0;
  padding: 0 16px;
  border-bottom: 0 solid rgba(240, 223, 178, 0.9);
  background: linear-gradient(90deg, rgba(240, 223, 178, 0.16), rgba(240, 223, 178, 0.30), rgba(240, 223, 178, 0.16));
  color: #8a6116;
  text-align: center;
  font-size: 13px;
  line-height: 20px;
  position: relative;
  z-index: 30;
  transition: max-height 0.25s ease, padding 0.25s ease, border-bottom-width 0.25s ease;
}

html[data-demo="1"] .demo-banner {
  display: block;
  max-height: 96px;
  padding-top: 7px;
  padding-bottom: 7px;
  border-bottom-width: 1px;
}

html[data-theme="dark"] .demo-banner,
html:not([data-theme="light"]) .demo-banner {
  background: linear-gradient(90deg, rgba(58, 49, 21, 0.5), rgba(77, 66, 32, 0.6), rgba(58, 49, 21, 0.5));
  color: #e5c06a;
  border-bottom-color: rgba(77, 66, 32, 0.8);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .demo-banner {
    background: linear-gradient(90deg, rgba(58, 49, 21, 0.5), rgba(77, 66, 32, 0.6), rgba(58, 49, 21, 0.5));
    color: #e5c06a;
    border-bottom-color: rgba(77, 66, 32, 0.8);
  }
}

/* ---------------- 顶部导航（粘性玻璃） ---------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--border-weak);
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 62px;
}

.logo {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--fg);
}

.logo:hover { color: var(--accent); }

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.site-nav a {
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 14.5px;
  transition: color 0.2s ease, background 0.2s ease;
}

.site-nav a:hover { color: var(--fg); background: var(--accent-weak); }

.site-nav a.active {
  color: var(--accent);
  font-weight: 600;
  background: var(--accent-weak);
}

#theme-toggle {
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 999px;
  width: 34px;
  height: 34px;
  margin-left: 8px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

#theme-toggle:hover { border-color: var(--accent); transform: rotate(15deg); }

/* ---------------- 布局 ---------------- */

main { padding-bottom: 20px; }

.site-footer {
  border-top: 1px solid var(--border-weak);
  padding: 30px 0 36px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 2;
}

/* ---------------- 首页 Hero（大字号渐变标题） ---------------- */

.hero { padding: 54px 0 14px; text-align: center; }

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--muted);
}

.hero-eyebrow .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}

.hero-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  flex-wrap: wrap;
  margin: 22px 0 6px;
}

.hero-row .avatar-wrap { margin-bottom: 0; }

.hero-title {
  font-size: clamp(44px, 7.5vw, 84px);
  font-weight: 800;
  line-height: 1.22;        /* 行高 >= 字形实际高度：防止下伸部被裁 */
  padding-bottom: 0.1em;    /* 扩展渐变绘制区域（background-clip:text 只绘制盒子内字形） */
  letter-spacing: 1px;
  color: var(--fg);
  background: linear-gradient(105deg, var(--fg) 18%, var(--accent) 55%, var(--accent-2) 88%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-sub {
  color: var(--muted);
  margin-top: 12px;
  font-size: 15.5px;
  letter-spacing: 0.5px;
}

/* ---------------- GitHub 头像 ----------------
   容器固定尺寸：加载前后布局零位移；失败时首字母占位 */

.avatar-wrap {
  position: relative;
  display: inline-block;
  width: 84px;
  height: 84px;
  border-radius: 50%;
}

.avatar-fallback {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent); /* 旧浏览器兜底 */
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #7fb8a8));
  color: #fff;
  font-size: 32px;
  font-weight: 600;
}

.avatar-img {
  position: relative;
  z-index: 1; /* 盖在占位层上：加载成功即显示真实头像 */
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--card);
  box-shadow: 0 0 0 1px var(--border), 0 0 24px rgba(76, 194, 160, 0.18);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.avatar-img.loaded { opacity: 1; }

.avatar-wrap:hover .avatar-img.loaded {
  transform: scale(1.05) rotate(3deg);
  box-shadow: 0 0 0 2px var(--accent), 0 10px 28px rgba(76, 194, 160, 0.28);
}

.avatar-lg { width: 96px; height: 96px; }
.avatar-lg .avatar-fallback { font-size: 36px; }

/* ---------------- 交互粒子球图层 ---------------- */

.sphere-wrap {
  margin: 14px 0 8px;
}

.particle-stage {
  display: block;
  width: 100%;
  height: 320px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--sphere-bg);
  cursor: crosshair;
  touch-action: manipulation;
}

.sphere-hint {
  margin-top: 8px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.5px;
}

/* ---------------- 小节标签 ---------------- */

.section-label {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 26px 0 16px;
  font-size: 12px;
  letter-spacing: 3.5px;
  text-transform: uppercase;
  color: var(--muted);
}

.section-label::before {
  content: "";
  width: 22px;
  height: 1px;
  background: var(--accent);
}

.section-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ---------------- 筛选工具栏 ---------------- */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 4px 0 18px;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

/* 标签 / 分类两行 chip（首页工具栏；搜索框已随后端无 keyword 参数一并移除） */
.chips-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.chip-label {
  align-self: center;
  font-size: 12px;
  color: var(--muted);
  opacity: 0.75;
  margin-right: 2px;
}

.chip {
  display: inline-block;
  padding: 4px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  background: var(--card);
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.chip:hover { color: var(--accent); border-color: var(--accent); }

.chip.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.chip span { opacity: 0.65; font-size: 12px; }

/* ---------------- 文章卡片（编号式玻璃卡） ---------------- */

.post-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 0 0 30px;
  transition: opacity 0.18s ease;
}

.post-list.refreshing { opacity: 0.35; pointer-events: none; }

.post-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px 26px;
  overflow: hidden;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.post-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 40%, rgba(255, 255, 255, 0.035));
  pointer-events: none;
}

.post-card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.14);
}

.pc-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}

.pc-num {
  font-size: 26px;
  font-weight: 800;
  color: var(--muted);
  opacity: 0.4;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
}

.pc-cat {
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border));
  border-radius: 999px;
  padding: 2px 12px;
}

.post-card h2, .pc-title {
  font-size: 19px;
  line-height: 1.45;
}

.post-card h2 a, .pc-title a { color: var(--fg); }
.post-card h2 a:hover, .pc-title a:hover { color: var(--accent); }

.post-summary {
  color: var(--muted);
  font-size: 14.5px;
  margin-top: 8px;
}

.pc-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.tag-row { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }

.tag {
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-weak);
  padding: 2px 11px;
  border-radius: 999px;
}

.tag:hover { filter: brightness(1.12); }

/* ---------------- 骨架屏 ---------------- */

.skeleton-card, .skeleton-line {
  background: linear-gradient(90deg, var(--code-bg) 25%, var(--border) 37%, var(--code-bg) 63%);
  background-size: 400% 100%;
  animation: skeleton-wave 1.4s ease infinite;
}

.skeleton-card {
  height: 132px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
}

.skeleton-line {
  height: 16px;
  margin: 16px 0;
  border-radius: 8px;
}

.skeleton-line.title { height: 28px; width: 62%; margin-top: 4px; }

@keyframes skeleton-wave {
  from { background-position: 100% 0; }
  to   { background-position: 0 0; }
}

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

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 40px;
}

.pager-note { font-size: 13px; color: var(--muted); }

.pager-btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  padding: 8px 20px;
  border-radius: 999px;
  font-size: 14px;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.pager-btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

.pager-btn.disabled { opacity: 0.35; pointer-events: none; }

/* 分页按钮实际用的是 disabled 属性（而非 .disabled class），补上禁用态样式 */
.pager-btn:disabled { opacity: 0.35; cursor: default; pointer-events: none; }

/* ---------------- 文章详情 ---------------- */

.post-page { padding-top: 30px; }

.back-link { font-size: 14px; margin-bottom: 22px; display: inline-block; }

.post-head h1 {
  font-size: clamp(24px, 4vw, 32px);
  line-height: 1.4;
}

.post-head .post-meta { margin: 14px 0 4px; }

/* 封面图（可选，后端 Post.cover 有值时才由 page-post.js 显示） */
.post-cover {
  display: block;
  width: 100%;
  max-height: 380px;
  object-fit: cover;
  border-radius: 18px;
  border: 1px solid var(--border);
  margin-top: 22px;
}

/* hidden 属性优先级高于上面的 display:block，需显式覆盖 */
.post-cover[hidden] { display: none; }

.post-body {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px 36px;
  margin-top: 22px;
}

/* ---- 文章内锚点：吸顶偏移 + 标题悬停锚链 ----
   78px = 吸顶导航 62px + 呼吸，与 js/main.js 的 HEAD_OFFSET 保持一致 */
:target,
.post-body h1, .post-body h2, .post-body h3,
.post-body h4, .post-body h5, .post-body h6,
.post-body [id] { scroll-margin-top: 78px; }

.post-body h1, .post-body h2,
.post-body h3, .post-body h4 { position: relative; }

.h-anchor {
  margin-left: 8px;
  font-size: 0.7em;
  font-weight: 400;
  color: var(--muted);
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.post-body h1:hover .h-anchor,
.post-body h2:hover .h-anchor,
.post-body h3:hover .h-anchor,
.post-body h4:hover .h-anchor,
.h-anchor:focus { opacity: 1; }

.h-anchor:hover { color: var(--accent); text-decoration: none; }

.h-anchor[data-copied="1"] { opacity: 1; color: var(--accent); }
.h-anchor[data-copied="1"]::after { content: " 已复制"; font-size: 12px; }

/* 触屏没有 hover：锚链常驻半透明，保证可点 */
@media (hover: none) { .h-anchor { opacity: 0.55; } }

.post-meta {
  color: var(--muted);
  font-size: 13px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: center;
}

.post-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin: 28px 0 6px;
}

.like-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  border-radius: 999px;
  padding: 9px 24px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.like-btn:hover:not(:disabled) { border-color: #e0566b; color: #e0566b; transform: scale(1.04); }

.like-btn.liked { border-color: #e0566b; color: #e0566b; background: rgba(224, 86, 107, 0.08); }

.like-btn:disabled { cursor: default; opacity: 0.8; }

.view-note { color: var(--muted); font-size: 13px; }

.post-neighbor {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin: 26px 0 44px;
  font-size: 14px;
}

.post-neighbor a {
  color: var(--fg);
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 14px;
  padding: 12px 18px;
  flex: 1;
  min-width: 0;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.post-neighbor a:hover { border-color: var(--accent); transform: translateY(-2px); }

.post-neighbor a.next { text-align: right; }

.post-neighbor .nb-label { color: var(--muted); font-size: 12px; display: block; }

.post-neighbor .nb-title {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* ---------------- Markdown 正文 ---------------- */

.md { font-size: 15.5px; line-height: 1.9; }
.md > * + * { margin-top: 1em; }

.md h2 { font-size: 21px; margin-top: 1.8em; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.md h3 { font-size: 18px; margin-top: 1.6em; }
.md h4 { font-size: 16px; margin-top: 1.5em; }

.md ul, .md ol { padding-left: 1.6em; }
.md li + li { margin-top: 0.3em; }

.md blockquote {
  border-left: 4px solid var(--accent);
  background: var(--accent-weak);
  padding: 10px 16px;
  border-radius: 0 10px 10px 0;
  color: var(--muted);
}

.md code {
  font-family: "Cascadia Code", Consolas, "JetBrains Mono", Menlo, monospace;
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 5px;
  overflow-wrap: anywhere;   /* 长标识符/URL 不再撑破正文 */
}

.md pre {
  background: #16191e;
  color: #dbe2f0;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 16px 18px;
  overflow-x: auto;
  line-height: 1.6;
}

.md pre code {
  background: transparent;
  padding: 0;
  font-size: 13.5px;
  color: inherit;
  overflow-wrap: normal;   /* 代码块长行走横向滚动，不折行（行内 code 仍允许断行） */
  white-space: pre;
  tab-size: 4;
}

/* 语法高亮：.md pre 的背景在亮/暗两套主题里都是深色，所以只需一套 token 配色。
   取值均按 #16191e 背景核算过对比度（注释/标点 ≥ 4.5:1） */
.tok-c { color: #8b98a5; font-style: italic; }   /* 注释 */
.tok-s { color: #a8d98a; }                        /* 字符串 */
.tok-k { color: #ff9d76; }                        /* 关键字 */
.tok-t { color: #7fd3f7; }                        /* 类型 / 类名 */
.tok-f { color: #d7c2ff; }                        /* 函数 / 方法 */
.tok-n { color: #f0c674; }                        /* 数字 / 颜色 */
.tok-a { color: #9fb4ff; }                        /* 注解 / 属性 / JSON key */
.tok-p { color: #a9b3c1; }                        /* 运算符 / 标点 */

.md hr { border: none; border-top: 1px dashed var(--border); margin: 1.8em 0; }

.md img { max-width: 100%; height: auto; border-radius: 12px; }

/* GFM 表格：marked 会产出 table，但此前既无样式也无横向滚动容器 */
.md table {
  display: block;            /* 让表格本身成为可横向滚动的容器 */
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 14px;
}
.md th, .md td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; }
.md th { background: var(--accent-weak); font-weight: 600; }

/* ---------------- 归档 ---------------- */

.archives-year { margin: 30px 0; }

.archives-year h2 {
  font-size: 20px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.archives-year h2 .count { color: var(--muted); font-size: 13px; font-weight: 400; }

.archive-list { list-style: none; margin-top: 12px; }

.archive-list li {
  display: flex;
  gap: 16px;
  padding: 10px 4px;
  border-bottom: 1px dashed var(--border);
  font-size: 15px;
}

.archive-list .date {
  color: var(--muted);
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}

.archive-list a { color: var(--fg); }
.archive-list a:hover { color: var(--accent); }

/* ---------------- 关于 / 空状态 / 错误页 ---------------- */

.about-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 30px 34px;
  margin: 30px 0 46px;
}

.about-avatar-block { text-align: center; margin-bottom: 20px; }

.about-handle { margin-top: 10px; font-size: 14px; }

.about-handle .github-handle { margin-left: 8px; }

.about-card h2 { font-size: 19px; margin: 1.6em 0 0.6em; }
.about-card h2:first-of-type { margin-top: 0.4em; }
.about-card p, .about-card li { color: var(--muted); font-size: 15px; }
.about-card ul { padding-left: 1.5em; }
.about-card strong { color: var(--fg); }

.empty-state {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 30px 34px;
  margin: 10px 0 30px;
  text-align: center;
  color: var(--muted);
}

.empty-state .empty-title { font-size: 17px; color: var(--fg); margin-bottom: 6px; }

.error-page { text-align: center; padding: 90px 0; }
.error-page h1 { font-size: 64px; color: var(--accent); }
.error-page p { color: var(--muted); margin: 12px 0 26px; }

/* ---------------- 无刷新换页过渡（双层堆叠淡入） ---------------- */

.page-stage { display: grid; }

.page-stage > main { grid-area: 1 / 1; }

main {
  transition: opacity 0.24s ease, transform 0.24s ease;
}

main.page-fade-in {
  opacity: 0;
  transform: translateY(14px);
}

@media (prefers-reduced-motion: reduce) {
  main { transition: none; }
  main.page-fade-in { opacity: 1; transform: none; }
}

/* ---------------- 右侧便捷滑条（替代原生滚动条） ----------------
   桌面：隐藏原生滚动条，由本滑条接管（拖动 / 点击轨道 / ↑↓ / 键盘）
   触屏与窄屏：隐藏本滑条，继续用原生手势 */
@media (hover: hover) and (min-width: 901px) {
  html { scrollbar-width: none; }                /* Firefox */
  ::-webkit-scrollbar { width: 0; height: 0; }   /* WebKit / Blink */
}

#scroll-rail {
  position: fixed;
  /* 贴近正文右缘：内容列 max-width 780px 居中 → 右缘在 50% + 390px；
     滑条贴其外侧 10px，视口不够宽时兜底不越出屏幕（52px ≈ 滑条宽 + 边距） */
  left: min(calc(50% + 390px + 10px), calc(100vw - 52px));
  right: auto;
  top: 50%;
  transform: translateY(-50%);
  z-index: 30;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  user-select: none;
}

#scroll-rail.on { display: flex; }

.sr-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--card);
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: color .18s ease, border-color .18s ease, opacity .18s ease;
}

.sr-btn:hover { color: var(--accent); border-color: var(--accent); }

#scroll-rail.at-top .sr-top,
#scroll-rail.at-bottom .sr-bottom { opacity: .3; pointer-events: none; }

.sr-track {
  position: relative;
  width: 12px;
  height: min(56vh, 520px);
  border-radius: 999px;
  background: var(--border);
  cursor: pointer;
  outline: none;
  transition: width .18s ease;
}

#scroll-rail:hover .sr-track,
.sr-track:focus-visible { width: 16px; }

.sr-track:focus-visible { box-shadow: 0 0 0 2px var(--accent); }

.sr-thumb {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  min-height: 44px;
  border-radius: 999px;
  background: var(--accent);
  opacity: .88;
}

#scroll-rail:hover .sr-thumb,
#scroll-rail.dragging .sr-thumb { opacity: 1; }

.sr-pct {
  position: absolute;
  right: 22px;
  top: 2px;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}

#scroll-rail:hover .sr-pct { opacity: 1; }

@media (max-width: 900px), (hover: none) {
  #scroll-rail { display: none !important; }
}

/* ---------------- 左右两侧装饰 ---------------- */

#side-decor { display: contents; }

.side-deco {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  z-index: 5;
  pointer-events: none;
  user-select: none;
}

.side-deco-left  { left: 34px; }
.side-deco-right { right: 34px; }

.sd-line {
  width: 1px;
  height: 88px;
  background: linear-gradient(to bottom, var(--border), var(--muted), var(--border));
  opacity: 0.55;
}

.sd-line-soft { opacity: 0.3; height: 56px; }

.sd-text {
  writing-mode: vertical-rl;
  font-size: 11px;
  letter-spacing: 7px;
  color: var(--muted);
  opacity: 0.6;
}

.sd-ring {
  width: 9px;
  height: 9px;
  border: 1.5px solid var(--accent);
  border-radius: 50%;
  opacity: 0.5;
}

.sd-ring-soft { opacity: 0.3; width: 7px; height: 7px; }

.sd-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.45;
}

.sd-spark {
  color: var(--accent);
  font-size: 14px;
  opacity: 0.55;
  animation: sd-float 4s ease-in-out infinite;
}

@keyframes sd-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-5px); }
}

@media (max-width: 1080px) {
  .side-deco { display: none; }
}

/* ---------------- 进入动画（欢迎页点击进入后 / 首次展现） ----------------
   body.entering 由 JS 定时移除（1.1s）—— 动画只是装饰，
   即使渲染帧被冻结，定时器到点后元素也会立即完整显示 */

body.entering .site-header { animation: ent-down 0.55s cubic-bezier(0.22, 0.8, 0.3, 1) both; }

body.entering main > * { animation: ent-up 0.55s cubic-bezier(0.22, 0.8, 0.3, 1) both; }
body.entering main > *:nth-child(1) { animation-delay: 0.10s; }
body.entering main > *:nth-child(2) { animation-delay: 0.18s; }
body.entering main > *:nth-child(3) { animation-delay: 0.26s; }
body.entering main > *:nth-child(4) { animation-delay: 0.34s; }
body.entering main > *:nth-child(5) { animation-delay: 0.42s; }
body.entering main > *:nth-child(n+6) { animation-delay: 0.50s; }

body.entering .site-footer { animation: ent-fade 0.7s 0.45s both; }

@keyframes ent-up   { from { opacity: 0; transform: translateY(20px); } }
@keyframes ent-down { from { opacity: 0; transform: translateY(-16px); } }
@keyframes ent-fade { from { opacity: 0; } }

/* ---------------- 管理控制台（/admin.html） ---------------- */

[hidden] { display: none !important; }

.admin-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 30px;
  margin: 40px 0 40px;
}

.admin-card h1 { font-size: 22px; margin-bottom: 6px; }
.admin-form-title { font-size: 18px; margin-bottom: 14px; }

.admin-card label {
  display: block;
  margin: 14px 0 5px;
  font-size: 13px;
  color: var(--muted);
}

.admin-card input[type="text"],
.admin-card input[type="password"],
.admin-card textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  outline: none;
  transition: border-color 0.2s ease;
}

.admin-card input:focus, .admin-card textarea:focus { border-color: var(--accent); }

.admin-card textarea {
  font-family: "Cascadia Code", Consolas, Menlo, monospace;
  font-size: 13.5px;
  line-height: 1.65;
  resize: vertical;
}

.admin-check {
  display: flex !important;
  align-items: center;
  gap: 8px;
  margin: 16px 0 4px !important;
  font-size: 14px !important;
  color: var(--fg) !important;
}

.admin-actions { display: flex; gap: 10px; margin-top: 18px; }

.admin-btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  border-radius: 999px;
  padding: 8px 20px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.admin-btn:hover { border-color: var(--accent); color: var(--accent); }

.admin-btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.admin-btn-primary:hover {
  background: color-mix(in srgb, var(--accent) 85%, #fff);
  color: #fff;
}

.admin-btn-danger:hover { border-color: #e0566b; color: #e0566b; }

/* 标签页按钮的选中态（文章管理 / 站点设置） */
.admin-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.admin-error { color: #e0566b; font-size: 13px; margin: 10px 0; }
.admin-ok { color: var(--accent); font-size: 13px; margin: 10px 0; }

.admin-note { color: var(--muted); font-size: 12.5px; margin-top: 16px; }

.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 40px 0 20px;
}

.admin-head h1 { font-size: 24px; }

.admin-head-ops { display: flex; gap: 10px; align-items: center; }

.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 4px;
  border-bottom: 1px dashed var(--border);
}

.admin-row-main { min-width: 0; }

.row-meta {
  display: block;
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 3px;
}

.pub-yes { color: var(--accent); font-weight: 600; }
.pub-no { color: #d08770; font-weight: 600; }

.row-ops { display: flex; gap: 8px; flex-shrink: 0; }

.row-ops .admin-btn { padding: 5px 14px; font-size: 13px; }

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

@media (max-width: 1080px) {
  .side-deco { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .aurora i { animation: none; }
  .sd-spark { animation: none; }
  .skeleton-card, .skeleton-line { animation: none; }
  .welcome, .wl-ch, .wl-eyebrow, .wl-sub, .wl-enter, .wl-hint, .wl-footer { animation: none; }
  body.entering .site-header,
  body.entering main > *,
  body.entering .site-footer { animation: none; }
  main { transition: none; }
  main.page-fade-in { opacity: 1; transform: none; }
}

@media (max-width: 640px) {
  .hero { padding-top: 34px; }
  .hero-row { gap: 18px; }
  .hero-title { font-size: 40px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .post-card { padding: 18px; }
  .pc-num { font-size: 20px; }
  .post-body, .about-card { padding: 20px; }
  .post-neighbor { flex-direction: column; }
  .post-neighbor a.next { text-align: left; }
  .particle-stage { height: 240px; }
}
