/* ==========================================================================
   仪仪上学日记 — 全局样式
   参考图风格：深蓝插画背景 + 毛玻璃卡片 + 圆角暖黄按钮
   多端兼容：PC / 平板 / 手机（<=1080 / <=820 / <=520 三档断点）
   ========================================================================== */

:root {
  /* 浅色主题：文字用深藏青（取自背景图暗部），主色用背景的淡蓝 */
  --text: #26304a;
  --text-dim: rgba(38, 48, 74, .74);
  --text-mute: rgba(58, 72, 102, .54);
  --accent: #5a9be6;
  --accent-deep: #3a7ccd;
  --accent-pale: #e9f2fe;
  --accent-tag: #dceafb;
  --line: #e6ecf6;
  --glass: rgba(255, 255, 255, .80);        /* 半透明卡片：背景透出来（配 backdrop-filter 成磨砂玻璃） */
  --stroke: rgba(38, 48, 74, .10);   /* 浅色卡片上白描边等于没有，改成很淡的灰边 */
  --stroke-soft: rgba(38, 48, 74, .10);


  /* 绿色变量已随「已阅绿点」一起移除：已阅不再有任何标记 */
  --danger: #ff6b81;
  --notice: #e0483f;              /* 公告提醒色（红） */
  --notice-pale: #fdeceb;
  --notice-line: rgba(224, 72, 63, .42);
  --radius-lg: 22px;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 18px 42px rgba(56, 84, 136, .36), 0 4px 11px rgba(56, 84, 136, .17);
  --shadow-sm: 0 10px 26px rgba(56, 84, 136, .28);
  --blur: saturate(160%) blur(18px);
  --maxw: 1200px;
  /* 操作行图片按钮的统一尺寸（表情 / 全部 / 编辑 / 删除 / 阅读 全部一致） */
  --btn-size: 96px;
  --ease: cubic-bezier(.22, .68, .28, 1);
}

* { box-sizing: border-box; }

/* 加载/切换期间浏览器画的就是这个底色，避免白屏闪一下 */
html { height: 100%; background-color: #eef3fb; }
body { height: 100%; }

/* ---------- 页面切换过渡 ---------- */
/* 说明：不做整屏幕布 —— 背景大图是常驻的，切换时只有内容渐隐渐现，
   和参考站一致（幕布会把背景也盖住，观感反而更"闪"）。 */
/* 内容渐隐渐现（背景与顶栏之外的区域） */
.page-fade { opacity: 0; }
/* 兜底强制显示时不要过渡（配合 head 里的 1.2s 定时器） */
html.no-fade .page-fade, html.no-fade.is-ready .page-fade { opacity: 1; transition: none; }
html.is-ready .page-fade { opacity: 1; transition: opacity .3s var(--ease) .04s; }
html.is-leaving .page-fade { opacity: 0; transition: opacity .16s ease; }

@media (prefers-reduced-motion: reduce) {
  .page-fade, html.is-ready .page-fade, html.is-leaving .page-fade { opacity: 1; transition: none; }
}

body {
  margin: 0;
  color: var(--text);
  font-family: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Noto Sans SC",
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

/* 图片兜底：任何图片都不会撑破容器 */
img { max-width: 100%; }
img, svg { vertical-align: middle; }

/* ---------- 背景层（固定，避免 iOS 的 background-attachment 问题） ---------- */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: -2;
  background-color: #eef3fb;
  background-image: url("../assets/bg.avif");
  background-size: cover;
  /* 新背景是 2.33:1 的宽图，竖屏手机会裁掉两侧：
     62% 这个位置正好把人物（画面右侧偏中）留在中间 */
  background-position: 62% 30%;
  background-repeat: no-repeat;
}
.bg-layer::after {
  content: "";
  position: absolute;
  inset: 0;
  /* 蒙版：只留很淡的一层白纱，背景图保持看得清 */
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .26), rgba(247, 250, 255, .10) 38%, rgba(255, 255, 255, .30)),
    radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, .14) 0%, rgba(255, 255, 255, 0) 62%);
}

/* ---------- 通用玻璃 ---------- */
.glass {
  background: var(--glass);
  border: 1px solid var(--stroke);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

/* ---------- 按钮 ---------- */
.btn-primary,
.btn-ghost {
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: transform .18s var(--ease), background .2s, box-shadow .2s, color .2s, border-color .2s;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.btn-primary {
  padding: 13px 30px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent-deep), var(--accent) 55%, #7fb8ff);
  box-shadow: 0 10px 26px rgba(90, 155, 230, .36);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(90, 155, 230, .48); background: linear-gradient(135deg, var(--accent-deep), #4f93e4 55%, #8ec7ff); }
.btn-primary:active { transform: translateY(0) scale(.98); box-shadow: 0 6px 16px rgba(90, 155, 230, .34); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; transform: none; box-shadow: none; }

/* 图片按钮：无边框，图片本身就是按钮（阅读 / 已阅、表情包、全部日记、编辑、删除） */
.btn-img {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 16px;
  -webkit-tap-highlight-color: transparent;
  transition: transform .18s var(--ease), opacity .2s, filter .2s;
}
.btn-img img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 6px 13px rgba(4, 12, 26, .48));
  transition: filter .2s;
}
.btn-img:hover { transform: translateY(-3px) scale(1.06); }
.btn-img:hover img { filter: drop-shadow(0 10px 18px rgba(4, 12, 26, .6)); }
.btn-img:active { transform: scale(.95); }
/* 作者本人不能点：整颗按钮变淡（图片本身就是状态显示） */
.btn-img:disabled {
  cursor: not-allowed;
  opacity: .45;
  filter: grayscale(.4);
}
.btn-img:disabled:hover { transform: none; }
/* .btn-img 设了 display，必须显式处理 hidden（否则「删除」对非作者也会显示） */
.btn-img[hidden] { display: none !important; }

.btn-ghost {
  padding: 12px 24px;
  font-weight: 600;
  color: var(--accent-deep);
  background: #fff;
  border-color: rgba(90, 155, 230, .34);
  box-shadow: 0 4px 12px rgba(86, 108, 156, .10);
  /* 白底不需要毛玻璃了 */

}
.btn-ghost:hover { background: var(--accent-pale); border-color: rgba(90, 155, 230, .55); color: var(--accent-deep); transform: translateY(-2px); box-shadow: 0 8px 18px rgba(86, 108, 156, .16); }
.btn-ghost:active { transform: scale(.98); }

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid #9fd8ff;
  outline-offset: 2px;
}

/* ==========================================================================
   顶栏：透明悬浮 + 圆形图标按钮
   （导航项已按要求全部删除，只保留：站点名 · 日记入口 · 搜索框 · 账号 · 退出）
   ========================================================================== */
.topbar {
  position: sticky;
  top: 16px;
  z-index: 40;
  width: min(var(--maxw), 94vw);
  margin: 16px auto 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  background: none;
  border: 0;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
/* 顶栏背后：84px 高的轻微模糊 + 18% 渐隐，底部柔和过渡（透明感保留） */
.topbar::before {
  content: "";
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 100vw;
  height: 84px;
  z-index: -1;
  pointer-events: none;
  background: rgba(3, 8, 20, .18);
  -webkit-backdrop-filter: blur(8px) saturate(140%);
  backdrop-filter: blur(8px) saturate(140%);
  -webkit-mask-image: linear-gradient(180deg, #000 52%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 52%, transparent 100%);
}

/* 站名：白色圆角小牌 + 粉蓝渐变字 */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;                       /* 图标与文字更贴边 */
  padding: 2px 13px 2px 2px;   /* 与右侧圆钮同高 42px，logo 顶满左端半圆 */
  border-radius: 999px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 6px 18px rgba(3, 10, 24, .30);
  text-decoration: none;
  flex: 0 0 auto;
  transition: transform .18s var(--ease), box-shadow .2s;
}
.brand:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(3, 10, 24, .38); }
.brand img { width: 38px; height: 38px; display: block; border-radius: 50%; }
.brand span {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: .01em;
  /* 渐变跟网站主色一致：深蓝 → 淡蓝 → 浅蓝 */
  background: linear-gradient(100deg, var(--accent-deep), var(--accent) 52%, #8ec7ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
}

.toolbar {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

/* 圆形图标按钮（日记 / 退出） */
.icon-btn {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  color: #2b3a55;
  background: rgba(255, 255, 255, .93);
  box-shadow: 0 6px 16px rgba(3, 10, 24, .30);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform .18s var(--ease), box-shadow .2s, background .2s;
}
.icon-btn:hover { transform: translateY(-2px); background: #fff; box-shadow: 0 10px 22px rgba(86, 108, 156, .28); }
.icon-btn:active { transform: scale(.95); }
.icon-btn svg { width: 20px; height: 20px; }

/* 当前账号：粉色圆形头像 */
.avatar-btn {
  position: relative;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  overflow: hidden;
  font-size: 15px;
  font-weight: 800;
  color: #3b1030;
  background: linear-gradient(135deg, #ffd2e6, #ff9ec4);
  box-shadow: 0 6px 16px rgba(3, 10, 24, .30);
}
/* 账号头像图（圆形裁切，盖住下面的字母） */
.avatar-btn .avatar-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}
.avatar-btn .avatar-img[hidden] { display: none; }
/* 白色描边画在头像之上（inset shadow 会被图片盖住） */
.avatar-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .92);
  pointer-events: none;
  z-index: 2;
}

/* 只给屏幕阅读器看的文字 */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* 搜索框：白色胶囊 */
.searchbox {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 150px;
  flex: 0 1 230px;
  height: 42px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .95);
  border: 0;
  box-shadow: 0 6px 16px rgba(3, 10, 24, .30);
  transition: box-shadow .2s, background .2s;
}
.searchbox:focus-within {
  background: #fff;
  box-shadow: 0 0 0 3px rgba(90, 155, 230, .5), 0 8px 20px rgba(86, 108, 156, .28);
}
.searchbox .search-ico { width: 17px; height: 17px; flex: 0 0 auto; color: #5b8cff; }
.searchbox input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  color: #22314d;
  font: inherit;
  font-size: 16px;   /* 固定 16px：手机端低于 16px 时 iOS 聚焦会自动放大整页 */
  padding: 2px 0;
}

.searchbox input::placeholder { color: rgba(52, 72, 105, .5); }
.searchbox input:focus { outline: none; }

/* 搜索结果下拉面板 */
.search-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(430px, 88vw);
  max-height: min(58vh, 420px);
  overflow-y: auto;
  padding: 8px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .97);
  border: 1px solid var(--line);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: var(--shadow);
  -webkit-overflow-scrolling: touch;
}
.search-panel[hidden] { display: none; }
.sp-head { padding: 6px 10px 8px; font-size: 12.5px; color: var(--text-mute); }
.sp-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.sp-item:hover, .sp-item:focus-visible { background: rgba(90, 155, 230, .12); }
.sp-item .sp-title { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.sp-item .sp-meta { font-size: 12.5px; color: var(--text-mute); margin-top: 2px; }
.sp-item .sp-snippet { font-size: 13.5px; color: var(--text-dim); margin-top: 4px; }
.sp-empty { padding: 16px 12px; color: var(--text-dim); font-size: 14px; text-align: center; }
.sp-all {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke-soft);
  background: rgba(38, 48, 74, .05);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.sp-all:hover { background: rgba(38, 48, 74, .09); }

/* ==========================================================================
   登录页
   ========================================================================== */
.page--auth { display: grid; place-items: center; min-height: 100%; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); }
.auth-wrap { width: 100%; max-width: 430px; }
.auth-card {
  padding: 30px 28px;
  border-radius: var(--radius-lg);
  animation: rise .5s var(--ease) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.98); } }
.brand-lg { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.brand-lg img { width: 56px; height: 56px; border-radius: 18px; box-shadow: 0 8px 20px rgba(255, 111, 168, .4); }
.brand-lg h1 { margin: 0; font-size: 22px; letter-spacing: .02em; }
.brand-lg p { margin: 2px 0 0; font-size: 13px; color: var(--text-mute); }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.field .input-wrap {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 14px;
  border-radius: 14px;
  background: rgba(38, 48, 74, .04);
  border: 1px solid var(--line);
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.field .input-wrap:focus-within {
  border-color: rgba(90, 155, 230, .65);
  box-shadow: 0 0 0 3px rgba(90, 155, 230, .18);
  background: rgba(38, 48, 74, .06);
}
.field input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 16px; /* 防止 iOS 聚焦缩放 */
}
.field input:focus { outline: none; }
.field input::placeholder { color: var(--text-mute); }
.eye {
  border: 0; cursor: pointer; font-size: 16px; line-height: 1;
  background: transparent; color: var(--text-dim); padding: 2px 4px; border-radius: 8px;
}
.eye:hover { color: var(--text); }

.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-dim); margin: 4px 0 6px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: #7fd4ff; }

.auth-error {
  min-height: 22px;
  margin: 4px 0 8px;
  font-size: 13.5px;
  color: #ffc2cd;
}
.auth-card.shake { animation: shake .4s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-9px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}
.btn-block { width: 100%; padding: 14px; font-size: 16.5px; }
.auth-tip { margin: 16px 0 0; font-size: 12.5px; color: var(--text-mute); text-align: center; line-height: 1.7; }

/* ==========================================================================
   首页：中间展示最新一篇日记
   ========================================================================== */
.home-main {
  min-height: calc(100vh - 140px);
  min-height: calc(100dvh - 140px);   /* 手机地址栏收缩时不跳动 */
  display: grid;
  place-items: center;
  padding: 34px 16px calc(52px + env(safe-area-inset-bottom));
}
.latest-card {
  position: relative;
  width: min(760px, 100%);
  padding: 30px 32px 28px;
  border-radius: var(--radius-lg);
  animation: rise .6s var(--ease) both;
}

/* 图片按钮换图时的弹跳动画 */
.btn-img img.pop { animation: img-pop .5s var(--ease); }
@keyframes img-pop {
  0% { transform: scale(.7) rotate(-8deg); opacity: .3; }
  60% { transform: scale(1.1) rotate(4deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  letter-spacing: .12em;
  color: var(--accent-deep);
  background: var(--accent-pale);
  font-weight: 700;
}
.latest-title {
  margin: 0 0 8px;
  font-size: clamp(24px, 3.4vw, 34px);
  line-height: 1.3;
  letter-spacing: .02em;
  word-break: break-word;
}
.latest-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 13.5px; color: var(--text-mute); margin-bottom: 16px; }
.latest-meta .dot { opacity: .5; }
.latest-body {
  color: var(--text-dim);
  font-size: 16px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 34vh;
  overflow: hidden;
  position: relative;
  -webkit-mask-image: linear-gradient(180deg, #000 72%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 72%, transparent 100%);
}
.latest-body mark { background: rgba(255, 215, 94, .55); color: #55400a; border-radius: 4px; padding: 0 2px; }
.latest-actions {
  display: flex;
  align-items: center;
  gap: calc(var(--btn-size) * 0.26);   /* 图片按钮的透明边距已被负 margin 抹掉，这就是看得见的间距 */
  margin-top: 24px;
  flex-wrap: wrap;
}
/* 操作行所有图片按钮统一大小（表情 / 全部 / 编辑 / 删除 / 阅读 都一样大）。
   注意 --pad：每张按钮图自带的透明边距不一样（表情左右各 22%、日记本 25%、
   编辑删除 12%、阅读 3%），所以同样的 gap 看起来间距并不一致。
   这里用负 margin 把透明边距抹掉，让 flex 的 gap 直接等于「看得见的间距」。 */
.latest-actions .btn-img,
.viewer-actions .btn-img,
.latest-actions .btn-read-img,
.viewer-actions .btn-read-img {
  width: var(--btn-size);
  height: var(--btn-size);
  margin-left: calc(var(--btn-size) * var(--pad, 0) * -1);
  margin-right: calc(var(--btn-size) * var(--pad, 0) * -1);
}
#emojiBtn { --pad: .2225; }                       /* 女孩插画 */
#allBtn, .btn-new { --pad: .249; }                /* 日记本 */
#editBtn { --pad: .1737; }                        /* 编辑（插画，左右各 17.4% 透明） */
#delBtn { --pad: .2037; }                         /* 删除（插画，左右各 20.4% 透明） */
.btn-read-img { --pad: .0285; }                   /* 四张阅读图 */
/* 提示文字在左，按钮整体靠右 */
.latest-actions .sticker-wrap { margin-left: auto; }
.read-hint { font-size: 12.5px; color: var(--text-mute); }

/* 空状态 */
.empty-state { text-align: center; padding: 18px 6px 6px; }
.empty-state h2 { margin: 6px 0 8px; font-size: 22px; }
.empty-state p { color: var(--text-dim); margin: 0 0 20px; }
.empty-state .emoji { font-size: 42px; }

/* ==========================================================================
   日记页
   ========================================================================== */
.diary-main {
  width: min(var(--maxw), 94vw);
  margin: 34px auto 0;
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
/* 左栏不再 sticky：sticky 会在滚动时钉在顶栏下方，导致和右侧面板的顶边错开；
   现在两栏一起滚，顶边始终对齐（列表自身仍可在卡片内滚动）。 */
/* 不再限制侧栏总高：列表固定 4 篇，时钟与日历顺势排在它下面 */
.diary-aside { padding: 16px; border-radius: var(--radius-lg); position: static; display: flex; flex-direction: column; }
.aside-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
/* 侧栏「写日记」按钮：同样用日记本图片，比操作行小一号，跟着 --btn-size 一起缩放 */
.aside-head .btn-img { width: calc(var(--btn-size) * .72); height: calc(var(--btn-size) * .72); flex: 0 0 auto; }
.aside-head h2 { margin: 0; font-size: 17px; }
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.chip {
  border: 1px solid transparent;
  background: var(--accent-pale);
  color: var(--accent-deep);
  font: inherit;
  font-size: 13px;
  padding: 6px 13px;
  border-radius: 999px;
  cursor: pointer;
}
.chip:hover { background: var(--accent-tag); color: var(--accent-deep); }
.chip.is-active { background: linear-gradient(135deg, var(--accent), #7fb8ff); color: #fff; font-weight: 700; border-color: transparent; box-shadow: 0 4px 12px rgba(90, 155, 230, .32); }
.aside-count { margin: 0 0 8px; font-size: 12.5px; color: var(--text-mute); }

/* 一屏正好露出 4 篇（每篇约 61px + 8px 间距），更多就在卡片内滚动 */
.entry-list { list-style: none; margin: 0; padding: 0 4px 0 0; overflow-y: auto; -webkit-overflow-scrolling: touch; max-height: 278px; }
.entry-item {
  width: 100%;
  text-align: left;
  font: inherit;
  color: var(--text);
  cursor: pointer;
  display: block;
  padding: 11px 12px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  transition: background .18s, border-color .18s, transform .18s var(--ease);
}
.entry-item:hover { background: var(--accent-pale); transform: translateX(2px); }
.entry-item.is-active { background: var(--accent-pale); border-color: rgba(90, 155, 230, .38); }
/* 选中行左侧的主色竖条 */
.entry-item.is-active::before { content: ''; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 2px; background: var(--accent); }
.entry-item { position: relative; }
.entry-item .ei-top { display: flex; align-items: center; gap: 8px; }
.entry-item .ei-title { font-weight: 700; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 auto; }
.entry-item .ei-date { font-size: 12px; color: var(--text-mute); margin-top: 3px; }
.entry-item .ei-snippet { font-size: 13px; color: var(--text-dim); margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.state-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: var(--accent); box-shadow: 0 0 0 3px rgba(90, 155, 230, .18); }
/* 已阅不再显示小点（.state-dot.is-read 已移除）：干净的行＝已读 */

.entry-panel { position: relative; padding: 30px 32px 26px; border-radius: var(--radius-lg); min-height: 60vh; }

.viewer-head { border-bottom: 1px dashed var(--stroke-soft); padding: 0 0 14px; margin-bottom: 18px; }
.viewer-head h2 { margin: 0 0 8px; font-size: clamp(21px, 2.6vw, 27px); word-break: break-word; }
.viewer-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--text-mute); }
.viewer-body { color: var(--text-dim); font-size: 16.5px; white-space: pre-wrap; word-break: break-word; min-height: 120px; }
.viewer-body mark { background: rgba(255, 215, 94, .55); color: #55400a; border-radius: 4px; padding: 0 2px; }
.viewer-actions { display: flex; gap: calc(var(--btn-size) * 0.26); flex-wrap: wrap; align-items: center; margin-top: 28px; padding-top: 18px; border-top: 1px dashed var(--stroke-soft); }
.viewer-actions .sticker-wrap { margin-left: auto; }

.editor { display: flex; flex-direction: column; gap: 12px; }
.editor[hidden], .viewer[hidden], .empty[hidden] { display: none; }
.editor input[type="text"] {
  font: inherit; font-size: 20px; font-weight: 700; color: var(--text);
  padding: 12px 14px; border-radius: 14px;
  background: rgba(38, 48, 74, .04);
  border: 1px solid var(--line);
}
.editor textarea {
  font: inherit; font-size: 16px; line-height: 1.8; color: var(--text);
  min-height: 42vh; resize: vertical;
  padding: 14px; border-radius: 14px;
  background: rgba(38, 48, 74, .04);
  border: 1px solid var(--line);
}
.editor input:focus, .editor textarea:focus { outline: none; border-color: rgba(90, 155, 230, .65); box-shadow: 0 0 0 3px rgba(90, 155, 230, .16); }
.editor input::placeholder, .editor textarea::placeholder { color: var(--text-mute); }
.editor-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.editor-tip { font-size: 12.5px; color: var(--text-mute); }

.empty { text-align: center; padding: 40px 10px; }
.empty .emoji { font-size: 44px; }
.empty h2 { margin: 8px 0 6px; font-size: 20px; }
.empty p { color: var(--text-dim); margin: 0 0 18px; }

/* ==========================================================================
   表情包评论
   ========================================================================== */
/* 表情包按钮是个图片按钮，这里只管它弹出的选择面板 */
.btn-img[aria-expanded="true"] { transform: translateY(-3px) scale(1.06); }

/* 选择面板：锚定在按钮上方弹出。
   注意：这里不能用 inline-block —— 行盒会在按钮下方留出基线间隙，
   导致表情按钮比同一行的其它按钮高约 2~4px，看起来没对齐。 */
.sticker-wrap { position: relative; display: inline-flex; align-items: center; line-height: 0; }
.sticker-panel {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 0;
  z-index: 60;
  width: min(352px, 82vw);
  max-height: min(320px, 52vh);
  overflow-y: auto;
  padding: 12px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .97);
  border: 1px solid var(--line);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: var(--shadow);
  -webkit-overflow-scrolling: touch;
  animation: rise .18s var(--ease) both;
}
.sticker-panel[hidden] { display: none; }
.sticker-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 12.5px;
  color: var(--text-dim);
}
.sticker-note { color: var(--text-mute); font-size: 12px; }
.sticker-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.sticker-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px 2px 7px;
  font: inherit;
  font-size: 12px;
  color: var(--text-dim);
  background: rgba(38, 48, 74, .04);
  border: 1px solid transparent;
  border-radius: 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .16s var(--ease), background .18s, border-color .18s;
}
.sticker-item:hover,
.sticker-item:focus-visible {
  background: rgba(90, 155, 230, .12);
  border-color: rgba(90, 155, 230, .45);
  transform: translateY(-2px);
}
.sticker-item img {
  width: 68px;
  height: 68px;
  display: block;
  object-fit: contain;
  /* 透明表情图：不铺白底，用轮廓投影代替矩形阴影 */
  background: none;
  filter: drop-shadow(0 4px 8px rgba(86, 108, 156, .26));
}
.sticker-name { line-height: 1; white-space: nowrap; }

/* 评论列表 */
.comments { margin-top: 22px; padding-top: 14px; border-top: 1px dashed var(--stroke-soft); }
.comments-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--text-dim);
}
.comments-hint { font-size: 12px; color: var(--text-mute); }
/* 列表滚动条：细一点，颜色跟着主题 */
.entry-list { scrollbar-width: thin; scrollbar-color: var(--accent-tag) transparent; }
.entry-list::-webkit-scrollbar { width: 6px; }
.entry-list::-webkit-scrollbar-thumb { background: var(--accent-tag); border-radius: 3px; }
.entry-list::-webkit-scrollbar-track { background: transparent; }

/* ---------- 左栏：北京时间时钟 + 日历 ---------- */
.side-card {
  margin-top: 14px;
  padding: 14px 14px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.side-card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--text);
}
.side-card h3 i {
  width: 4px;
  height: 15px;
  border-radius: 2px;
  background: var(--accent);
}

/* 数字时钟 */
.side-clock { text-align: center; }
.side-clock h3 { justify-content: flex-start; }
.clock-time {
  margin: 6px 0 2px;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: .02em;
  color: var(--accent-deep);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* 日历 */
.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}
.cal-nav {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  color: var(--text-dim);
  background: var(--accent-pale);
}
.cal-nav:hover { background: var(--accent-tag); color: var(--accent-deep); }
.cal-week,
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-week span {
  text-align: center;
  font-size: 12px;
  color: var(--text-mute);
  padding-bottom: 4px;
}
.cal-grid span {
  display: grid;
  place-items: center;
  height: 26px;
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.cal-grid span.is-today {
  color: #fff;
  font-weight: 800;
  background: var(--accent);
  box-shadow: 0 3px 10px rgba(90, 155, 230, .38);
}
.cal-grid span.is-empty { visibility: hidden; }

/* 窄屏：两张卡并排，省高度 */
@media (max-width: 900px) {
  .side-clock, .side-calendar { flex: 1 1 220px; }
}

/* ---------- 点图看大图 ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;                       /* 高于内容与表情面板，低于提示 toast(90) */
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(14, 22, 38, .74);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  cursor: zoom-out;
  overscroll-behavior: contain;
  animation: lb-in .18s var(--ease) both;
}
.lightbox[hidden] { display: none; }
.lightbox .lb-img {
  max-width: min(96vw, 1280px);
  max-height: 86vh;
  width: auto;
  height: auto;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(8, 16, 32, .5);
  animation: lb-zoom .2s var(--ease) both;
}
.lightbox .lb-close {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  color: #26304a;
  font-size: 22px;
  line-height: 1;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 6px 18px rgba(8, 16, 32, .32);
}
.lightbox .lb-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(14px, env(safe-area-inset-bottom));
  text-align: center;
  font-size: 12.5px;
  color: rgba(255, 255, 255, .78);
  pointer-events: none;
}
@keyframes lb-in { from { opacity: 0; } }
@keyframes lb-zoom { from { transform: scale(.94); opacity: .6; } }

/* 打开大图时锁住页面滚动 */
body.is-zoom { overflow: hidden; }


/* ---------- 备份与恢复面板 ---------- */
.backup-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 60;
  width: min(320px, 86vw);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-radius: 16px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, .95);
  box-shadow: var(--shadow);
  backdrop-filter: var(--blur);
}
.backup-panel[hidden] { display: none; }
.backup-panel .backup-stat { font-size: 13px; line-height: 1.7; color: var(--text-dim); }
.backup-panel .btn-ghost { width: 100%; }
.backup-panel .backup-tip { margin: 0; font-size: 12px; line-height: 1.6; color: var(--text-mute); }
.icon-btn.is-active { color: var(--accent-deep); background: var(--accent-pale); }

/* ---------- 公告：红色提醒 ---------- */
/* 「发布公告」按钮：红字红边，和普通次级按钮区分开 */
#noticeBtn {
  color: var(--notice);
  border-color: var(--notice-line);
  box-shadow: 0 4px 12px rgba(224, 72, 63, .14);
}
#noticeBtn:hover {
  color: var(--notice);
  background: var(--notice-pale);
  border-color: var(--notice);
  box-shadow: 0 8px 18px rgba(224, 72, 63, .20);
}

/* 「公告」标签：红字；选中时红底白字 */
.chip[data-filter="notice"] {
  color: var(--notice);
  background: var(--notice-pale);
  border-color: var(--notice-line);
}
.chip[data-filter="notice"]:hover {
  background: #fbdcd9;
  border-color: var(--notice);
}
.chip[data-filter="notice"].is-active {
  color: #fff;
  background: linear-gradient(135deg, #c93b33, var(--notice));
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(224, 72, 63, .34);
}
/* ---------- 公告（列表里的标记） ---------- */
.ei-tag.is-notice {
  color: #fff;
  background: linear-gradient(135deg, #c93b33, var(--notice));
  letter-spacing: .04em;
}
.entry-item.is-notice .ei-title { font-weight: 700; }

/* ---------- 日记配图（图文混排） ---------- */
.entry-img {
  display: block;
  cursor: zoom-in;          /* 提示可以点开看大图 */
  /* 正文里的配图不铺满整行：最宽 420px（手机上自动收成 100%），居中摆放 */
  width: auto;
  max-width: min(100%, 420px);
  max-height: 46vh;
  height: auto;
  margin: 14px auto;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow-sm);
}

/* 窄屏再收一档，避免配图把正文挤没 */
@media (max-width: 520px) {
  .entry-img { max-width: 100%; max-height: 40vh; }
}

/* 编辑器里的图片缩略图（插进去的图一眼能看到） */
.editor-thumbs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.editor-thumbs:empty { display: none; }
.editor-thumbs li {
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.editor-thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.editor-thumbs .thumb-no {
  position: absolute;
  left: 4px;
  bottom: 4px;
  padding: 0 6px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: rgba(38, 48, 74, .62);
}
.editor-thumbs button {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  color: #fff;
  font-size: 14px;
  line-height: 1;
  background: rgba(38, 48, 74, .55);
}
.editor-thumbs button:hover { background: var(--danger); }

/* ---------- 表情评论（头像 + 名称 + 时间在上，表情在下） ---------- */
.comment {
  position: relative;
  padding: 12px 14px 14px;
  border-radius: 16px;
  background: linear-gradient(135deg, #eef4ff 0%, #f6f1ff 55%, #eaf3ff 100%);
  border: 1px solid rgba(255, 255, 255, .9);
  box-shadow: 0 6px 16px rgba(86, 108, 156, .12);
  animation: sticker-in .3s var(--ease) both;
}
.comment.is-mine {
  background: linear-gradient(135deg, #e6f1ff 0%, #eef0ff 55%, #e3f0ff 100%);
  border-color: rgba(90, 155, 230, .35);
}
.comment-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 9px;
}
.comment-avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 50%;
  object-fit: cover;
  background: var(--accent-tag);
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-deep);
  box-shadow: 0 0 0 2px #fff;
}
.comment-meta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
  min-width: 0;
  line-height: 1.35;
}
.comment-meta b { font-size: 13px; color: var(--ink-strong, var(--text)); }
.comment-meta i { font-style: normal; font-size: 12px; color: var(--text-mute); }
/* 表情包缩进到头像右侧（34px 头像 + 9px 间距），不再和头像左边缘齐平 */
.comment-body { display: flex; align-items: center; gap: 10px; padding-left: 43px; }
.comment-del {
  margin-left: auto;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  color: var(--text-mute);
  background: rgba(38, 48, 74, .07);
  font-size: 15px;
  line-height: 1;
  display: none;
}
.comment-del:hover { background: var(--danger); color: #fff; }
.comment-empty {
  padding: 4px 2px;
  font-size: 12.5px;
  color: var(--text-mute);
}
.comment-list { display: flex; flex-direction: column; gap: 12px; }

.comment-sticker {
  width: 84px;
  height: 84px;
  display: block;
  object-fit: contain;
  /* 表情图本身是透明 PNG/GIF，不要给白底，也不要矩形阴影（会露出一个方框） */
  background: none;
  filter: drop-shadow(0 5px 10px rgba(86, 108, 156, .28));
}
.comment.is-mine:hover .comment-del,
.comment.is-mine:focus-within .comment-del { display: block; }
@media (hover: none) {
  .comment.is-mine .comment-del { display: block; }
}

/* ---------- 轻提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(26px + env(safe-area-inset-bottom));
  transform: translate(-50%, 18px);
  z-index: 90;
  padding: 11px 22px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #7fb8ff);
  box-shadow: 0 10px 26px rgba(90, 155, 230, .38);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s var(--ease);
  max-width: 86vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.warn { background: linear-gradient(135deg, #ffe1a8, #ffc46b); }

/* ---------- 列表行里的小标签（谁写的） ---------- */
.ei-tag {
  flex: 0 0 auto;
  padding: 1px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.6;
  color: var(--accent-deep);
  background: var(--accent-tag);
}
.entry-item.is-active .ei-tag { color: #fff; background: var(--accent); }

/* ---------- meta 行的小图标（日历 / 字数 / 作者） ---------- */
.meta-i { display: inline-flex; align-items: center; gap: 5px; }
.meta-i svg { width: 13px; height: 13px; flex: 0 0 auto; opacity: .72; }

/* ==========================================================================
   响应式：平板 / 手机
   ========================================================================== */
@media (max-width: 1080px) {
  .diary-main { grid-template-columns: 300px minmax(0, 1fr); }
  .searchbox { flex-basis: 240px; }
}

@media (max-width: 900px) {
  .diary-main { grid-template-columns: minmax(0, 1fr); }
  .diary-aside { position: static; max-height: none; }
  .entry-list { max-height: 46vh; }
}

@media (max-width: 820px) {
  /* 手机：第一行 站名 + 日记 + 账号 + 退出，第二行 搜索框铺满 */
  .topbar {
    flex-wrap: wrap;
    gap: 10px;
    top: 12px;
    margin-top: 12px;
  }
  .topbar::before { top: -8px; height: 116px; }
  .toolbar { display: contents; }
  .brand { order: 1; padding: 2px 11px 2px 2px; }
  .brand img { width: 34px; height: 34px; }
  .brand span { font-size: 17px; }
  .icon-diary { order: 2; }
  .avatar-btn { order: 3; margin-left: auto; }
  #logoutBtn { order: 4; }
  #backupBtn { order: 5; }
  .searchbox { order: 6; flex: 1 1 100%; min-width: 0; }
  /* 窄屏上面板改成固定定位、左右留边，避免被右边裁掉 */
  .backup-panel {
    position: fixed;
    left: 12px;
    right: 12px;
    top: 132px;
    width: auto;
    max-height: 68vh;
    overflow-y: auto;
  }
  .icon-btn, .avatar-btn { width: 38px; height: 38px; }
  .searchbox { height: 38px; }
  .icon-btn svg { width: 18px; height: 18px; }
  .home-main { padding-top: 24px; }
  .latest-card { padding: 26px 22px 22px; }
  .latest-body { max-height: 30vh; }
  .read-hint { width: 100%; }
  .entry-panel { padding: 26px 20px 22px; }
  /* 图片按钮统一缩小 */
  :root { --btn-size: 84px; }
}

@media (max-width: 520px) {
  body { font-size: 15.5px; }
  .search-panel { width: min(92vw, 430px); right: -6px; }
  .auth-card { padding: 24px 20px; }
  .latest-title { font-size: 22px; }
  /* 窄屏：图片按钮统一更小，表情面板铺满一行 */
  :root { --btn-size: 68px; }
  .latest-actions .sticker-wrap, .viewer-actions .sticker-wrap { margin-left: auto; }
  .sticker-panel { left: auto; right: 0; width: min(92vw, 352px); max-height: 46vh; }
  .sticker-item img { width: 58px; height: 58px; }
  .comment-sticker { width: 44px; height: 44px; }
  .comment { padding: 5px 10px 5px 5px; }
  .entry-list { max-height: 40vh; }
  .editor textarea { min-height: 34vh; }
  .toast { font-size: 13.5px; padding: 10px 18px; }
}

@media (max-width: 380px) {
  .brand { padding: 2px 9px 2px 2px; }
  .brand img { width: 30px; height: 30px; }
  .brand span { font-size: 15.5px; }
  .icon-btn, .avatar-btn { width: 34px; height: 34px; }
  .searchbox { height: 34px; }
  .icon-btn svg { width: 16px; height: 16px; }
  .latest-card { padding: 22px 16px 18px; }
  :root { --btn-size: 62px; }
}

/* 横屏手机：减少垂直占位 */
@media (max-height: 460px) and (orientation: landscape) {
  .home-main { min-height: auto; padding-top: 20px; }
  .latest-body { max-height: 40vh; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* 打印日记 */
/* ==========================================================================
   飘落的蝴蝶结 + 底部堆积
   - .autumn-layer 固定在视口上（position: fixed），所以堆积始终在"当前看到的
     那一屏"的底部，不会跑到文档最底下；
   - z-index: 30 → 在内容之上飘落（顶栏 40、表情面板 60、提示 90 仍在它上面）；
   - pointer-events: none → 完全不影响点击、选择和滚动。
   ========================================================================== */
.autumn-layer {
  position: fixed;
  inset: 0;
  --vh100: 100vh;           /* 兼容旧浏览器；支持 dvh 时下面会覆盖 */
  --land: 34px;             /* 落地线：叶子停在这个高度（离底），也就是堆积区 */
  z-index: 30;              /* 内容之上飘落；顶栏 40 / 表情面板 60 / 提示 90 仍压着它 */
  overflow: hidden;
  pointer-events: none;     /* 不挡住任何点击与滚动 */
  -webkit-user-select: none;
  user-select: none;
}

/* 一片正在飘落的蝴蝶结：外层负责下落，内层负责左右摇摆 */
.autumn-leaf {
  position: absolute;
  top: 0;
  left: var(--x, 50%);
  width: var(--s, 22px);
  height: var(--s, 22px);
  color: var(--c, #e07a3c);
  opacity: var(--o, .85);
  /* 只落一次：终点停在底部堆积区，落地后由 JS 换成躺在地上的叶子 */
  animation: leaf-fall var(--d, 15s) linear var(--delay, 0s) 1 both;
  will-change: transform;
}

.autumn-leaf > span {
  display: block;
  width: 100%;
  height: 100%;
  animation: leaf-sway var(--sway, 3.4s) ease-in-out infinite alternate;
}

.autumn-leaf .leaf-img,
.autumn-rest .leaf-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

/* 蝴蝶结本身偏浅，稍微提饱和 & 按 --hue 做色相偏移，浅底上更清楚；
   堆积里的略微压暗一点，避免和下落的混在一起 */
.autumn-leaf .leaf-img { filter: saturate(1.18) hue-rotate(var(--hue, 0deg)); }
.autumn-rest .leaf-img { filter: saturate(1.08) brightness(.96) hue-rotate(var(--hue, 0deg)); }

@keyframes leaf-fall {
  from { transform: translate3d(0, -12vh, 0); }
  /* 停在堆积区（离底约 --land），不再滑出屏幕 */
  to   { transform: translate3d(var(--drift, 40px), calc(var(--vh100) - var(--land, 50px)), 0) rotate(var(--spin, 420deg)); }
}

@keyframes leaf-sway {
  from { transform: translateX(calc(var(--sway-x, 16px) * -1)) rotate(-28deg); }
  to   { transform: translateX(var(--sway-x, 16px)) rotate(24deg); }
}

/* 底部堆积：高度很浅（最多 78px），落下的蝴蝶结或躺或叠 */
.autumn-pile {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--pile-h, 78px);
}

/* 落地瞬间：原地淡出（新生成的地面叶子在同一位置接上，看起来就是落在地上） */
.autumn-leaf.is-landed {
  animation: none;
  transition: opacity .45s linear;
  opacity: 0;
}

/* 堆满之后落下的叶子：直接淡掉，不再往上堆 */
.autumn-leaf.is-faded { transition: opacity .6s linear; opacity: 0; }

.autumn-rest {
  position: absolute;
  bottom: var(--b, 0);
  left: var(--x, 50%);
  width: var(--s, 20px);
  height: var(--s, 20px);
  color: var(--c, #d9702f);
  opacity: var(--o, .92);
  transform: rotate(var(--r, 0deg));
  transform-origin: 50% 90%;
  animation: leaf-settle .9s ease-out both;
}

@keyframes leaf-settle {
  from { transform: translateY(-14px) rotate(calc(var(--r, 0deg) - 18deg)); opacity: 0; }
  to   { transform: translateY(0) rotate(var(--r, 0deg)); opacity: var(--o, .92); }
}

/* 系统开了"减少动态效果"：不飘落，只留底部一层静止的蝴蝶结 */
@media (prefers-reduced-motion: reduce) {
  .autumn-leaf { display: none; }
  .autumn-rest { animation: none; }
}

/* 支持 dvh 的浏览器用动态视口高度：手机地址栏收缩时落点不跳动 */
@supports (height: 100dvh) {
  .autumn-layer { --vh100: 100dvh; }
}

/* 小屏少放一些，别挡视线 */
@media (max-width: 520px) {
  .autumn-pile { --pile-h: 60px; }
}

@media print {
  .bg-layer, .autumn-layer, .topbar, .diary-aside, .viewer-actions, .toast, .btn-img { display: none !important; }
  body { color: #000; background: #fff; }
  .entry-panel { border: 0; box-shadow: none; background: #fff; padding: 0; }
  .viewer-body, .viewer-meta { color: #222; }
}
