/* 自托管字体子集：只打包了 items.json 签文实际用到的约2600个汉字 + 基本拉丁字符，
   体积从原始完整字体的 35MB+ 压到了 2.1MB。不再依赖 fonts.googleapis.com——
   国内网络环境下 Google Fonts 域名基本长期连不上，之前用 @import 的话，这些用户
   会一直吃不到自定义字体、只能看后备字体；自托管之后离线也能正常显示。
   注意：因为是子集字体，只覆盖了当前 items.json 里出现过的汉字，以后往
   items.json 里加新签文时，如果用到了生僻字，这几个 woff2 需要重新生成一遍
   （不然那几个字会自动降级成后备字体，不会报错，只是显示不一致）。 */
@font-face {
  font-family: "ZCOOL XiaoWei";
  src: url("fonts/ZCOOLXiaoWei-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Noto Sans SC";
  src: url("fonts/NotoSansSC-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Noto Sans SC";
  src: url("fonts/NotoSansSC-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Noto Sans SC";
  src: url("fonts/NotoSansSC-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/JetBrainsMono-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/JetBrainsMono-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  /* —— 色板：宣纸 + 墨 + 印泥 —— */
  --paper: #f3ede0;
  --paper-deep: #e8dfcb;
  --paper-line: #d9cdb0;
  --ink: #2a2420;
  --ink-soft: #6b6255;
  --ink-faint: #9c927e;
  --seal: #b23b2e;
  --seal-deep: #8c2a20;
  --bamboo: #5c6b47;
  --gold: #b8892b;
  --gold-glow: #e8c468;

  --font-display: "ZCOOL XiaoWei", "Noto Serif SC", serif;
  --font-body: "Noto Sans SC", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --radius: 10px;
  --shadow-card: 0 2px 0 var(--paper-line), 0 6px 16px rgba(42, 36, 32, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background-image: radial-gradient(
      circle at 20% 10%,
      rgba(178, 59, 46, 0.04),
      transparent 40%
    ),
    radial-gradient(circle at 85% 80%, rgba(92, 107, 71, 0.05), transparent 45%);
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* —— 顶部栏 —— */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: linear-gradient(to bottom, var(--paper) 80%, transparent);
  backdrop-filter: blur(2px);
}

.brand {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 2px;
  color: var(--ink);
}

.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px 5px 10px;
  background: var(--seal);
  color: var(--paper);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  box-shadow: 0 2px 6px rgba(178, 59, 46, 0.35);
  transform: rotate(-2deg);
}

.streak-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold-glow);
}

/* —— 主体区域 —— */
main {
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 18px 100px;
}

.view {
  display: none;
}
.view.active {
  display: block;
  animation: fade-in 0.25s ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ================= 签到页 ================= */

.daily-quote {
  margin: 18px auto 0;
  max-width: 320px;
  text-align: center;
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: 0.5px;
  color: var(--ink-soft);
  line-height: 1.6;
  position: relative;
  padding: 0 8px;
}
.daily-quote::before,
.daily-quote::after {
  content: "";
  display: block;
  width: 22px;
  height: 1px;
  margin: 8px auto 0;
  background: var(--paper-line);
}
.daily-quote::after {
  margin: 0 auto 0;
}

.qian-tube-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px 0 10px;
}

.qian-tube {
  width: 120px;
  height: auto;
  filter: drop-shadow(0 8px 14px rgba(42, 36, 32, 0.18));
}

.draw-date {
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-faint);
}

.draw-btn {
  margin-top: 22px;
  padding: 14px 46px;
  background: var(--ink);
  color: var(--paper);
  border: none;
  border-radius: 6px;
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 6px;
  position: relative;
  box-shadow: 0 4px 0 #14100d, 0 8px 16px rgba(0, 0, 0, 0.2);
  transition: transform 0.08s ease;
}
.draw-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #14100d, 0 3px 8px rgba(0, 0, 0, 0.2);
}
.draw-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

/* 只在本地环境出现的调试按钮，故意用跟正式 UI 不同的观感（虚线框、等宽字体），
   一眼能看出这是开发工具而不是正式功能，避免以后忘了它是干嘛的 */
.dev-preview-btn {
  margin-top: 14px;
  padding: 6px 14px;
  background: transparent;
  color: var(--ink-faint);
  border: 1px dashed var(--ink-faint);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
}
.dev-preview-btn:hover {
  color: var(--seal);
  border-color: var(--seal);
}

.draw-btn::before,
.draw-btn::after {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: rgba(243, 237, 224, 0.35);
}
.draw-btn::before {
  left: 10px;
}
.draw-btn::after {
  right: 10px;
}

.today-hint {
  margin-top: 16px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.7;
}

/* 今日全球求签数：一个很轻的氛围感数字，不是核心信息，字号、颜色都比
   today-hint 更淡一档，默认隐藏（接口没配置好/请求失败/数字为0时），
   出现也不该抢"今天抽到了什么"这个主角的注意力 */
.global-count {
  margin-top: 10px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-faint);
  letter-spacing: 0.3px;
}

/* —— 抽到的卡片区 —— */
.cards-row {
  margin-top: 26px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 14px;
}

.qian-card {
  position: relative;
  background: var(--paper-deep);
  border: 1px solid var(--paper-line);
  border-left: 3px solid var(--accent, var(--bamboo));
  border-radius: var(--radius);
  padding: 16px 14px 60px;
  min-height: 150px;
  box-shadow: var(--shadow-card);
  opacity: 0;
  transform: translateY(14px) rotateX(-25deg);
  transform-origin: top center;
  animation: card-reveal 0.55s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
  /* 用 flow-root 代替原来 ::after 的 clearfix 写法，腾出 ::after
     给下面的"开光扫光"一次性动画用 */
  display: flow-root;
}

@keyframes card-reveal {
  to {
    opacity: 1;
    transform: none;
  }
}

/* 普通款的"翻角"：右上角一个类目专属色的小折角，让每张卡片按类目
   自然呈现不同的色彩身份，随手一瞥就能分辨，但克制在角落，不抢签文的主体位置 */
.qian-card:not(.hidden)::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 24px 24px 0;
  border-color: transparent var(--accent, var(--bamboo)) transparent transparent;
  opacity: 0.85;
  border-top-right-radius: calc(var(--radius) - 1px);
  pointer-events: none;
}

/* 普通款揭晓瞬间的"开光"扫光：一道柔光斜着扫过卡面一次，
   配合印章落下的时间点出现，制造"眼前一亮"的仪式感，
   但只是单次掠过、不常驻，克制在不抢隐藏款风头的程度 */
.qian-card:not(.hidden)::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    115deg,
    transparent 42%,
    rgba(255, 255, 255, 0.65) 50%,
    transparent 58%
  );
  background-size: 240% 240%;
  background-position: -160% -160%;
  opacity: 0;
  pointer-events: none;
}

.qian-card:not(.hidden).sweep::after {
  animation: card-sweep 0.85s ease-out forwards;
  animation-delay: var(--sweep-delay, 0s);
}

@keyframes card-sweep {
  0% {
    opacity: 0;
    background-position: -160% -160%;
  }
  18% {
    opacity: 0.95;
  }
  55% {
    opacity: 0.5;
  }
  100% {
    opacity: 0;
    background-position: 60% 60%;
  }
}

.qian-card .card-watermark {
  position: absolute;
  left: -6px;
  bottom: -6px;
  width: 96px;
  height: 96px;
  color: var(--accent, var(--bamboo));
  opacity: 0.07;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.qian-card.hidden .card-watermark {
  color: var(--gold);
  opacity: 0.09;
}

.qian-card .card-watermark svg {
  width: 100%;
  height: 100%;
  display: block;
}

.qian-card .card-head,
.qian-card .name,
.qian-card .flavor {
  position: relative;
  z-index: 1;
}

.qian-card .card-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qian-card .draw-time {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-faint);
  letter-spacing: 0.5px;
}

.item-icon {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-bg, rgba(92, 107, 71, 0.16));
  color: var(--accent, var(--bamboo));
  overflow: hidden;
}

.item-icon svg {
  width: 18px;
  height: 18px;
  display: block;
  flex: none;
}

.qian-card.hidden .card-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qian-card.hidden .item-icon {
  background: rgba(184, 137, 43, 0.18);
  color: var(--gold);
}

.qian-card .cat {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--bamboo);
  letter-spacing: 1px;
}

.qian-card .name {
  margin-top: 6px;
  font-family: var(--font-display);
  font-size: 19px;
  color: var(--ink);
}

.qian-card .flavor {
  margin-top: 8px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-soft);
}

/* 印章：改成绝对定位，钉在卡片右下角的固定预留区域里，不再参与文字排版。
   之前用 float:right 让文字环绕印章，签文一长就被挤成窄窄一条、断行很难看
   （截图反馈过这个问题）。现在卡片底部用 padding 留出固定空间给印章，
   签文永远占满整行宽度正常换行，两者互不干扰。 */
.seal-stamp {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 2;
  width: 42px;
  height: 42px;
  background: var(--seal);
  color: var(--paper);
  font-family: var(--font-display);
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  clip-path: polygon(
    8% 2%, 22% 0%, 40% 4%, 58% 0%, 76% 3%, 94% 0%, 100% 16%,
    97% 34%, 100% 52%, 96% 70%, 100% 88%, 88% 100%, 70% 97%,
    52% 100%, 34% 96%, 16% 100%, 0% 84%, 3% 66%, 0% 48%,
    4% 30%, 0% 14%
  );
  opacity: 0;
  transform: scale(1.7) rotate(-14deg);
  animation: stamp-hit 0.35s cubic-bezier(0.3, 1.5, 0.4, 1) forwards;
  animation-delay: 0.4s;
  box-shadow: 0 1px 3px rgba(140, 42, 32, 0.5);
}

@keyframes stamp-hit {
  0% {
    opacity: 0;
    transform: scale(2.1) rotate(-18deg);
  }
  60% {
    opacity: 0.95;
  }
  100% {
    opacity: 0.92;
    transform: scale(1) rotate(-8deg);
  }
}

/* 卡片左下角的"分享"按钮，跟右下角的印章分居两侧，视觉上刚好对称。
   默认比较克制（细边框、无底色），不抢签文和印章的风头；hover/active 时
   才提示墨色/印泥色，呼应整体宣纸+墨+印泥的调性。 */
.qian-card .share-btn {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 2;
  padding: 5px 12px;
  background: transparent;
  border: 1px solid var(--paper-line);
  border-radius: 999px;
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: 11.5px;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.qian-card .share-btn:hover {
  border-color: var(--seal);
  color: var(--seal);
}
.qian-card .share-btn:disabled {
  opacity: 0.6;
  cursor: default;
}
.qian-card.hidden .share-btn {
  border-color: rgba(184, 137, 43, 0.5);
}
.qian-card.hidden .share-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}

/* 图鉴（时间轴/图鉴墙）弹层里的"生成分享图"按钮，跟随签文说明放在弹层底部 */
.popover-share-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 11px;
  background: transparent;
  border: 1px solid var(--paper-line);
  border-radius: 999px;
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: 11px;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.popover-share-btn:hover {
  border-color: var(--seal);
  color: var(--seal);
}
.popover-share-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

/* 隐藏款：旋转金色描边 + 呼吸光晕
   —— 之前用 filter:hue-rotate 直接套在整张卡片上，连卡片里的墨色文字也会跟着变色，
   看起来像色彩故障而不是"描边旋转"。改成用 ::before 单独做一层圆环，只转这一层。

   之前 spin-ring 是直接 transform: rotate() 转这个 ::before 元素本身——但这个
   环形其实是一个方形（用 mask-composite 抠出中空效果），旋转到 45° 附近时，
   方形的对角线比边长长，四个角就会戳出卡片轮廓，看起来像卡片斜着裂开了一块
   （截图反馈过这个问题）。改成用 @property 注册一个可动画的角度变量，动画只转
   conic-gradient 内部的颜色分布（from 角度），::before 这个方形容器本身完全不转，
   自然不会有任何一帧的角会超出卡片边界。不支持 @property 的老浏览器会直接退化成
   一圈不转的静态描边，不会出现旋转错位的问题。 */
@property --spin-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

.qian-card.hidden {
  position: relative;
  z-index: 0;
  background: var(--paper-deep);
  border: 2px solid transparent;
  animation: card-reveal 0.55s cubic-bezier(0.2, 0.8, 0.3, 1) forwards,
    glow-breathe 2.4s ease-in-out infinite;
}

.qian-card.hidden::before {
  content: "";
  position: absolute;
  inset: -2px;
  z-index: -1;
  border-radius: inherit;
  padding: 2px;
  background: conic-gradient(
    from var(--spin-angle),
    var(--gold),
    var(--gold-glow),
    var(--seal),
    var(--gold)
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: spin-ring 5s linear infinite;
}

@keyframes spin-ring {
  to {
    --spin-angle: 360deg;
  }
}

@keyframes glow-breathe {
  0%,
  100% {
    box-shadow: var(--shadow-card), 0 0 0px rgba(232, 196, 104, 0.4);
  }
  50% {
    box-shadow: var(--shadow-card), 0 0 22px rgba(232, 196, 104, 0.65);
  }
}

.qian-card.hidden .cat::before {
  content: "隐 · ";
  color: var(--gold);
}

/* ================= 图鉴页 ================= */

.collection-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 18px 0 20px;
}

.collection-head h2 {
  font-family: var(--font-display);
  font-size: 20px;
  margin: 0;
}

.collection-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-soft);
}

.category-filter {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 14px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--paper-line);
  scrollbar-width: none;
  cursor: grab;
  user-select: none;
}

.category-filter.dragging {
  cursor: grabbing;
}

.category-filter::-webkit-scrollbar {
  display: none;
}

.category-chip {
  flex: 0 0 auto;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--paper-line);
  background: var(--paper-deep);
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: 12.5px;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.category-chip .count {
  margin-left: 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  opacity: 0.75;
}

.category-chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.timeline {
  position: relative;
  padding-left: 96px;
  animation: collection-fade-in 0.25s ease both;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 76px;
  top: 6px;
  bottom: 6px;
  width: 1px;
  background: var(--paper-line);
}

.timeline-day {
  position: relative;
  margin-bottom: 22px;
}

.timeline-date-badge {
  position: absolute;
  left: -90px;
  top: -3px;
  width: 70px;
  height: 54px;
}

.timeline-date-badge svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.timeline-dot {
  position: absolute;
  left: -20px;
  top: 6px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--paper);
}

.timeline-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.timeline-item,
.wall-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: var(--paper-deep);
  border: 1px solid var(--paper-line);
  border-radius: 8px;
  font-size: 13.5px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.timeline-item:hover,
.timeline-item.open,
.wall-item:hover,
.wall-item.open {
  background: var(--paper);
  border-color: var(--bamboo);
}

.timeline-item.hidden,
.wall-item.hidden {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold) inset;
}

.timeline-item.hidden:hover,
.timeline-item.hidden.open,
.wall-item.hidden:hover,
.wall-item.hidden.open {
  box-shadow: 0 0 0 1px var(--gold) inset, 0 0 12px rgba(232, 196, 104, 0.45);
}

/* 悬浮/点击后弹出的签文描述——纸片轻轻展开的感觉，而不是生硬的浏览器 title 提示 */
.item-popover {
  position: absolute;
  left: 8px;
  right: 8px;
  top: calc(100% + 6px);
  z-index: 20;
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-left: 3px solid var(--seal);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-soft);
  box-shadow: var(--shadow-card);
  opacity: 0;
  transform: translateY(-4px) scale(0.97);
  transform-origin: top center;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.timeline-item.open .item-popover,
.wall-item.open .item-popover {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

@media (hover: hover) and (pointer: fine) {
  .timeline-item:hover .item-popover,
  .wall-item:hover .item-popover {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
  }
}

.item-popover::before {
  content: "";
  position: absolute;
  top: -5px;
  left: 18px;
  width: 8px;
  height: 8px;
  background: var(--paper);
  border-left: 1px solid var(--paper-line);
  border-top: 1px solid var(--paper-line);
  transform: rotate(45deg);
}

.item-popover .empty-flavor {
  color: var(--ink-faint);
  font-style: italic;
}

.item-popover .popover-time {
  display: block;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-faint);
}

.timeline-item .item-icon.small {
  width: 22px;
  height: 22px;
  border-radius: 6px;
}

.timeline-item .item-icon.small svg {
  width: 13px;
  height: 13px;
}

.timeline-item .name,
.wall-item .name {
  font-weight: 500;
}

.timeline-item .cat,
.wall-item .cat {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-faint);
}

/* —— 时间轴 / 图鉴墙 切换 —— */
.view-toggle {
  display: inline-flex;
  align-self: flex-start;
  margin: 12px 0 14px;
  padding: 3px;
  background: var(--paper-deep);
  border: 1px solid var(--paper-line);
  border-radius: 999px;
}

.view-toggle button {
  border: none;
  background: none;
  padding: 6px 16px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 12.5px;
  color: var(--ink-soft);
  transition: background 0.15s ease, color 0.15s ease;
}

.view-toggle button.active {
  background: var(--ink);
  color: var(--paper);
}

/* —— 图鉴墙：每个物件只出现一次，按抽到次数聚合展示 —— */
/* .wall-grid 和 [hidden] 属性选择器的 CSS 优先级相同（都是 0,1,0），
   author 样式表里写的 .wall-grid{display:grid} 排在浏览器默认的
   [hidden]{display:none} 之后，会把它盖掉——结果是即使 JS 给元素设了
   hidden = true，它照样按 grid 布局显示出来，导致图鉴墙和时间轴同时
   出现在页面上。这里显式补一条 [hidden] 规则，把 hidden 属性的优先级
   找回来。 */
.wall-grid[hidden] {
  display: none;
}

.wall-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  animation: collection-fade-in 0.25s ease both;
}

@keyframes collection-fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .timeline,
  .wall-grid {
    animation: none;
  }
}

.wall-item {
  flex-wrap: wrap;
  align-items: center;
}

.wall-item .item-icon {
  width: 26px;
  height: 26px;
  border-radius: 7px;
}

.wall-item .item-icon svg {
  width: 15px;
  height: 15px;
}

.wall-item .cat {
  flex-basis: 100%;
  margin-left: 0;
  margin-top: 2px;
}


.repeat-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-faint);
  background: var(--paper-line);
  border-radius: 999px;
  padding: 1px 7px;
  line-height: 1.5;
}

.milestone {
  position: relative;
  margin: 4px 0 22px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.milestone .timeline-dot {
  background: var(--gold);
}

.milestone-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px dashed var(--gold);
  border-radius: 999px;
  color: var(--gold);
  font-size: 12px;
  font-family: var(--font-mono);
}

.empty-state {
  margin-top: 60px;
  text-align: center;
  color: var(--ink-faint);
  font-size: 13px;
  line-height: 1.8;
}

/* ================= 设置页 ================= */

.settings-list {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-item {
  background: var(--paper-deep);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
  padding: 16px;
}

.settings-item h3 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 16px;
}

.settings-item p {
  margin: 0 0 12px;
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.6;
}

.settings-item button,
.settings-item label.file-btn {
  display: inline-block;
  padding: 9px 18px;
  background: var(--ink);
  color: var(--paper);
  border: none;
  border-radius: 6px;
  font-size: 13px;
}

.settings-item.danger {
  border-color: var(--seal);
}
.settings-item.danger button {
  background: var(--seal);
}

.settings-item input[type="file"] {
  display: none;
}

.backup-hint {
  margin: 10px 0 0;
  font-size: 11.5px;
  color: var(--ink-faint);
}
.backup-hint.warn {
  color: var(--seal);
  font-weight: 500;
}

.settings-note {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--ink-faint);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%) translateY(10px);
  background: var(--ink);
  color: var(--paper);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 12.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 50;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.update-banner {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%) translateY(10px);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 12px 10px 18px;
  border-radius: 999px;
  font-size: 12.5px;
  box-shadow: var(--shadow-card);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 60;
}
.update-banner.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.update-banner button {
  background: var(--gold);
  color: var(--ink);
  border: none;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

/* —— 安装引导横幅 —— */
/* 跟 .update-banner 共用同一套"底部胶囊条幅"定位逻辑，但特意用竹青色而不是
   墨色打底——两者语义不同（一个是"有更新"，一个是"要不要装"），万一某个
   用户凑巧同时符合两个条件（app.js 里会互斥处理，但样式上留一层保险），
   视觉上也能一眼区分开，不会看成同一条消息。 */
.install-banner {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%) translateY(10px);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bamboo);
  color: var(--paper);
  padding: 10px 10px 10px 16px;
  border-radius: 999px;
  font-size: 12.5px;
  box-shadow: var(--shadow-card);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 55;
  max-width: calc(100vw - 36px);
}
.install-banner.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.install-banner span {
  line-height: 1.4;
}
.install-banner button {
  border: none;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
}
#installActionBtn {
  background: var(--gold);
  color: var(--ink);
  font-weight: 600;
  padding: 6px 14px;
}
#installDismissBtn {
  background: transparent;
  color: var(--paper);
  opacity: 0.7;
  padding: 4px 6px;
  font-size: 13px;
}
#installDismissBtn:hover {
  opacity: 1;
}

/* iOS 场景下点"添加"弹出的操作步骤提示——不是系统层面的东西（iOS 没有可编程的
   安装 API），只能用一段浮层文案告诉用户"去哪儿点"。跟 .item-popover 一样走
   淡入展开而不是生硬的 alert()。 */
.install-steps {
  position: fixed;
  left: 50%;
  bottom: 152px;
  transform: translateX(-50%) translateY(6px);
  width: min(300px, calc(100vw - 48px));
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-left: 3px solid var(--bamboo);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--ink-soft);
  box-shadow: var(--shadow-card);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 56;
}
.install-steps.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.install-steps b {
  color: var(--ink);
}

/* ================= 底部 Tab 栏 ================= */

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--paper);
  border-top: 1px solid var(--paper-line);
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 10;
}

.tabbar button {
  flex: 1;
  border: none;
  background: none;
  padding: 12px 0 10px;
  font-family: var(--font-body);
  font-size: 12.5px;
  color: var(--ink-faint);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.tabbar button .glyph {
  font-family: var(--font-display);
  font-size: 18px;
  color: inherit;
}

.tabbar button.active {
  color: var(--seal);
}

/* ================= 无障碍 / 减少动效 ================= */

:focus-visible {
  outline: 2px solid var(--seal);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 380px) {
  .brand {
    font-size: 19px;
  }
  main {
    padding-left: 14px;
    padding-right: 14px;
  }
}
