/* ============================================================
 *  甲如 · 样式
 *  改颜色只需要改下面 :root 里的变量，不用管其他部分。
 * ============================================================ */

:root {
  --bg: #FBF7F3;
  --surface: #FFFFFF;
  --ink: #241E1C;
  --ink-2: #5B5049;
  --ink-3: #7C6F66;
  --line: #EDE3DA;
  --primary: #B9777F;
  --primary-soft: #F7E7E8;
  --gold: #C0A062;
  --sage: #9CAF9A;

  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "SimSun", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", system-ui, sans-serif;

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;
  --shadow: 0 1px 2px rgba(36, 30, 28, .04), 0 10px 28px rgba(36, 30, 28, .06);
  --pad: 20px;
  --tabh: 64px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.7;
  padding-bottom: calc(var(--tabh) + 24px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 500; letter-spacing: .01em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; font-size: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
img { display: block; max-width: 100%; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: baseline; gap: 10px;
  padding: 14px var(--pad) 10px;
  background: rgba(251, 247, 243, .86);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid rgba(237, 227, 218, .7);
}
.brand {
  font-family: var(--serif);
  font-size: 19px;
  letter-spacing: .12em;
}
.brand-sub {
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: .04em;
}

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex;
  height: calc(var(--tabh) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  font-size: 11px;
  color: var(--ink-3);
  transition: color .18s ease;
  min-height: 44px;
}
.tab svg { transition: transform .18s ease; }
.tab.on { color: var(--primary); }
.tab.on svg { transform: translateY(-1px); }

/* ---------- 主区域 ---------- */
main {
  max-width: 780px;
  margin: 0 auto;
  padding: 8px var(--pad) 40px;
}
body.ready main { animation: rise .5s cubic-bezier(.22, 1, .36, 1) both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 首页 · 主视觉 ---------- */
.hero { padding: 26px 0 18px; }
.kicker {
  font-size: 12px;
  letter-spacing: .22em;
  color: var(--ink-3);
  margin-bottom: 14px;
}
.hero h1 {
  font-family: var(--serif);
  font-size: clamp(28px, 8.4vw, 40px);
  line-height: 1.42;
  font-weight: 400;
  letter-spacing: .02em;
}
.hero h1 em {
  font-style: normal;
  color: var(--primary);
  position: relative;
}
.hero-note {
  margin-top: 12px;
  color: var(--ink-2);
  font-size: 14px;
}

.count {
  display: flex; gap: 6px;
  margin-top: 24px;
}
.c-unit {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 4px 10px;
  text-align: center;
}
.c-unit b {
  display: block;
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 400;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.c-unit span {
  display: block;
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 3px;
  letter-spacing: .1em;
}
.count-hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: .08em;
}

.days-together {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--ink-3);
  letter-spacing: .08em;
}

.bd { margin-top: 26px; position: relative; }
.bd-line {
  font-family: var(--serif);
  font-size: clamp(26px, 7.6vw, 34px);
  color: var(--primary);
  letter-spacing: .1em;
}
.bd-sub { font-size: 13px; color: var(--ink-3); margin-top: 4px; letter-spacing: .08em; }
.confetti {
  /* 生日当天的纸屑：铺满整屏，从顶上飘下来、落出屏幕就结束。
     fixed 是为了滚动页面时它还在屏幕里，不跟着内容走。 */
  position: fixed; left: 0; top: 0;
  /* canvas 是替换元素，光给 inset 不会拉伸（会退回 300×150 的默认尺寸），
     宽高得显式写。dvh 写在后面，手机浏览器地址栏收起时不会露底。 */
  width: 100vw; height: 100vh;
  height: 100dvh;
  pointer-events: none;
  z-index: 45;              /* 盖住顶栏(30)和底栏(40)，让位给灯箱(60) */
}

/* ---------- 区块 ---------- */
.sec { margin-top: 34px; }
.sec-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 14px;
}
.sec-head h2 {
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: .08em;
}
.sec-side { font-size: 12px; color: var(--ink-3); letter-spacing: .06em; }

/* ---------- 今日一甲 ---------- */
.today-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .28s cubic-bezier(.22, 1, .36, 1), box-shadow .28s ease;
}
.today-card:hover { transform: translateY(-3px); box-shadow: 0 2px 4px rgba(36,30,28,.05), 0 18px 40px rgba(36,30,28,.09); }
.today-card .workimg { border-radius: 0; aspect-ratio: 1 / 1; }
.today-info { padding: 16px 18px 18px; }
.today-info h3 {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 400;
  margin-bottom: 6px;
}
.today-info p { color: var(--ink-2); font-size: 14px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: #8E4E57;
  font-size: 12px;
  letter-spacing: .02em;
  white-space: nowrap;
}

/* ---------- 三个入口 ---------- */
.entries { display: grid; gap: 10px; }
.entry {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 16px;
  transition: border-color .2s ease, transform .2s ease;
}
.entry:hover { border-color: #DCC9BB; transform: translateX(3px); }
.e-ico {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: 12px;
  background: #FAF1EE;
  color: var(--primary);
  flex: 0 0 auto;
}
.entry b { display: block; font-weight: 500; font-size: 15px; flex: 0 0 auto; white-space: nowrap; }
.entry i {
  display: block; font-style: normal;
  font-size: 12.5px; color: var(--ink-3);
  margin-top: 1px; flex: 1 1 auto; min-width: 0;
}

/* ---------- 抖音卡 ---------- */
.douyin {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  background: linear-gradient(180deg, #FFFFFF, #FDF8F5);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.dj-ava {
  width: 46px; height: 46px; border-radius: 50%;
  overflow: hidden; flex: 0 0 auto;
  background: #F3E1E1;
  display: grid; place-items: center;
  font-family: var(--serif); font-size: 20px; color: #8E4E57;
}
.dj-ava img { width: 100%; height: 100%; object-fit: cover; }
.dj-body { flex: 1; min-width: 0; }
.dj-body b { font-weight: 500; }
.dj-handle { font-size: 12px; color: var(--ink-3); margin-left: 8px; }
.dj-body i {
  display: block; font-style: normal;
  font-size: 12.5px; color: var(--ink-2);
  margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dj-badge {
  font-size: 11px; color: var(--ink-3);
  border: 1px solid var(--line);
  padding: 2px 8px; border-radius: 999px;
  flex: 0 0 auto;
}

.foot-note {
  margin-top: 40px;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-3);
  letter-spacing: .04em;
}

/* ---------- 页头 ---------- */
.page-head { padding: 22px 0 16px; }
.page-head.center { text-align: center; }
.page-head h1 {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 400;
  letter-spacing: .04em;
}
.page-head p { color: var(--ink-2); font-size: 13.5px; margin-top: 6px; }
.count-num {
  font-size: 14px;
  color: var(--primary);
  margin-left: 4px;
  font-family: var(--sans);
}

/* ---------- 图库内的子页签（我的款式 / 参考素材） ---------- */
.subtabs {
  display: flex; gap: 8px;
  margin-top: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0;
}
.subtab {
  font: inherit; font-size: 14px; cursor: pointer;
  padding: 9px 14px 10px;
  border: 0; border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: none; color: var(--ink-3);
  display: inline-flex; align-items: baseline; gap: 6px;
  transition: color .16s ease, border-color .16s ease;
}
.subtab span {
  font-size: 11.5px; color: var(--ink-3);
  background: #F4EAE4; border-radius: 999px; padding: 1px 8px;
}
.subtab:hover { color: var(--ink); }
.subtab.on {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 500;
}
.subtab.on span { background: var(--primary-soft); color: #8E4C55; }
#viewWorks, #viewLib { padding-top: 4px; }

/* ---------- 详情页返回 ---------- */
.page-back { padding: 14px 0 2px; }
.back-btn {
  font: inherit; font-size: 13.5px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 8px 15px 8px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2);
  transition: border-color .16s ease, color .16s ease, background .16s ease;
}
.back-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.back-btn:active { transform: translateY(1px); }

/* ---------- 筛选 ---------- */
.filters {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 14px;
}
.frow { display: flex; gap: 10px; align-items: flex-start; padding: 5px 0; }
.flabel {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--ink-3);
  padding-top: 5px;
  letter-spacing: .08em;
  width: 34px;
}
.fchips {
  display: flex; flex-wrap: wrap; gap: 6px;
  /* flex 子项默认 min-width:auto，内容一多会把整行撑破（素材那边 9 个风格
     选项就撑出过屏幕）。给 0 才会按可用宽度收缩。
     按钮用换行而不是横向滚动：滚动会把靠后的选项藏起来，
     看着像"只有这几个"——宁可多占一行。 */
  min-width: 0;
  padding-bottom: 2px;
}
.fchip {
  flex: 0 0 auto;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #FDFAF7;
  font-size: 12.5px;
  color: var(--ink-2);
  transition: all .16s ease;
}
.fchip.on {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.fmore { display: none; }
.fmore.open { display: block; }
.fmore-btn {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--ink-3);
  padding: 4px 0;
}
.fmore-btn span { display: inline-block; transition: transform .2s ease; }
.fmore-btn.open span { transform: rotate(180deg); }

.result-bar {
  display: flex; align-items: center; gap: 8px;
  margin: 14px 2px 12px;
  font-size: 12.5px;
  color: var(--ink-3);
}
.result-bar #rnum { color: var(--primary); font-weight: 500; }
.clear {
  margin-left: auto;
  font-size: 12px;
  color: var(--ink-3);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- 网格与卡片 ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.grid-3 { margin-top: 4px; }

.card {
  position: relative;
  display: block;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  transition: transform .26s cubic-bezier(.22, 1, .36, 1), box-shadow .26s ease;
}
.card:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.workimg { aspect-ratio: 1 / 1; overflow: hidden; background: #F7EFE9; }
.workimg svg, .workimg img { width: 100%; height: 100%; display: block; object-fit: cover; }
.card-meta {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 8px;
  padding: 9px 12px 11px;
}
.card-name { font-size: 13.5px; font-weight: 500; }
.card-tag { font-size: 11px; color: var(--ink-3); flex: 0 0 auto; }

.heart {
  position: absolute; top: 8px; right: 8px;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .82);
  color: var(--ink-3);
  backdrop-filter: blur(6px);
  transition: color .18s ease, transform .18s ease;
}
.heart.on { color: var(--primary); }
.heart.pop { animation: pop .34s cubic-bezier(.22, 1.4, .36, 1); }
@keyframes pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.28); }
  100% { transform: scale(1); }
}
.src-dot {
  position: absolute; bottom: 52px; left: 10px;
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .85);
  color: var(--ink-3);
}

/* ---------- 空状态 ---------- */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-3);
  font-size: 14px;
}
.empty .btn { margin-top: 16px; }

/* ---------- 轻提示（收藏/取消的回执） ---------- */
.toast {
  position: fixed; left: 50%; bottom: 92px;
  transform: translate(-50%, 8px);
  z-index: 60;
  max-width: calc(100vw - 40px);
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(36, 30, 28, .9);
  color: #F7F1EC;
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
  opacity: 0; pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* 存储不可用时的提醒（灵感板） */
.store-warn {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  background: #FBF1EC;
  border: 1px solid #EBD9CF;
  color: #8E4E57;
  font-size: 12.5px;
  line-height: 1.6;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 14px;
  color: var(--ink);
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}
.btn:hover { border-color: #DCC9BB; }
.btn:active { transform: scale(.98); }
.btn-main { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-main:hover { background: #A9666F; border-color: #A9666F; }
.btn-line { width: 100%; margin-top: 18px; }
.btn-lg { padding: 0 34px; font-size: 15px; }

/* ---------- 详情 ---------- */
.detail { padding-top: 10px; }
.detail-img {
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.detail-img .workimg { aspect-ratio: 1 / 1; }
.detail-body h1 {
  font-family: var(--serif);
  font-size: 27px;
  font-weight: 400;
  margin: 22px 0 6px;
  letter-spacing: .04em;
}
.quote {
  font-family: var(--serif);
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.9;
  padding-left: 14px;
  border-left: 2px solid var(--primary-soft);
  margin: 12px 0 4px;
}
.tags { margin-top: 20px; display: grid; gap: 10px; }
.tag-row { display: flex; gap: 10px; align-items: flex-start; }
.tag-k {
  flex: 0 0 auto; width: 34px;
  font-size: 12px; color: var(--ink-3);
  padding-top: 5px; letter-spacing: .08em;
}
.tag-row .chips { margin-top: 0; }
.src-none {
  margin-top: 18px;
  font-size: 12.5px;
  color: var(--ink-3);
}
.detail-acts {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-top: 16px;
}

/* ---------- 摇一摇 ---------- */
.shake-stage {
  display: grid; place-items: center;
  margin: 6px auto 0;
  max-width: 300px;
}
.shake-card {
  width: 100%;
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.shake-card .workimg { aspect-ratio: 1 / 1; }
.shake-card.rolling { filter: saturate(1.05); }
.shake-card.settle { animation: settle .42s cubic-bezier(.22, 1.4, .36, 1); }
@keyframes settle {
  0% { transform: scale(1.04); }
  60% { transform: scale(.985); }
  100% { transform: scale(1); }
}
.shake-name {
  text-align: center;
  font-family: var(--serif);
  font-size: 20px;
  margin-top: 18px;
  letter-spacing: .06em;
}
.shake-acts {
  display: flex; gap: 10px; justify-content: center;
  margin-top: 18px;
}

/* ---------- 信 ---------- */
.letter { padding-top: 14px; }
.letter h1 {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 400;
  letter-spacing: .06em;
  margin-bottom: 20px;
}
.letter-body p {
  font-family: var(--serif);
  font-size: 16px;
  line-height: 2.05;
  color: #322A26;
  margin-bottom: 18px;
  text-align: justify;
}
.letter-body p:first-child .cap {
  font-size: 34px;
  float: left;
  line-height: .9;
  padding: 4px 2px 0 0;   /* 后面常跟标点，留 2px 就够，多了会显出一个空格 */
  margin-right: 2px;
  color: var(--primary);
}
.sign {
  text-align: right;
  font-family: var(--serif);
  color: var(--ink-2);
  margin-top: 8px;
  letter-spacing: .08em;
}
.reasons { margin: 0; padding: 0; list-style: none; counter-reset: rz; }
.reasons li {
  position: relative;
  padding-left: 27px;
  font-size: 14.5px;
  line-height: 1.95;
  color: #3A312C;
  margin-bottom: 6px;
}
/* 用计数器自己画序号：两位数（10. 11. 12.）才不会被推到正文右边 */
.reasons li::before {
  counter-increment: rz;
  content: counter(rz) ".";
  position: absolute; left: 0; top: 0;
  width: 20px; text-align: right;
  color: var(--primary);
  font-family: var(--serif);
  font-variant-numeric: tabular-nums;
}
.wishes { list-style: none; margin: 0; padding: 0; }
.wishes li {
  display: flex; gap: 10px; align-items: baseline;
  font-size: 14.5px;
  line-height: 1.9;
  padding: 7px 0;
  border-bottom: 1px dashed var(--line);
}
.wishes li:last-child { border-bottom: 0; }
.dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--gold);
  flex: 0 0 auto;
  transform: translateY(-3px);
}

/* ---------- 桌面 ---------- */
@media (min-width: 620px) {
  :root { --pad: 28px; }
  .grid { grid-template-columns: repeat(3, 1fr); gap: 14px; }
  /* 四个入口在桌面上排 2×2：一行四列时每张只有 160 多像素宽，
     副文案（「一千多张参考图，能按条件筛」）会被挤成两行、末字单独一行。 */
  .entries { grid-template-columns: repeat(2, 1fr); }
  .entry { padding: 16px 18px; }
  .entry:hover { transform: translateY(-3px); }
  .today-card { display: grid; grid-template-columns: 1fr 1fr; align-items: center; }
  .today-card .workimg { aspect-ratio: 1 / 1; height: auto; min-height: 0; }
  .today-info { padding: 24px 26px; }
  .detail { display: grid; grid-template-columns: 1fr 1fr; gap: 34px; align-items: start; }
  .detail-body h1 { margin-top: 4px; }
  .letter-body p { font-size: 16.5px; }
  .tabbar {
    left: 50%; right: auto;
    width: min(660px, 100%);
    transform: translateX(-50%);
    border-radius: 20px 20px 0 0;
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
  }
}

@media (min-width: 980px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
  main { max-width: 880px; }
  .detail { grid-template-columns: 1.1fr 1fr; gap: 48px; }
}

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