/* ============================================================================
 *  finish.css —— 收尾层
 *  这一层只做两件事：
 *    1. 把设计评审里「还差一点」的细节补齐（方印、接触印相、纸、焦点、按压态…）
 *    2. 把移动端的硬伤兜住（滚动锁、安全区、键盘、点击区域、离线/更新提示）
 *  放在 style.css 之后加载，所以能覆盖前面的规则，不动原文件。
 * ==========================================================================*/

/* ---------------------------------------------------------------------------
 *  1. 滚动锁：iOS 上 overflow:hidden 锁不住，用 fixed + 还原位置
 * -------------------------------------------------------------------------*/
body.locked {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  overflow: hidden;
  touch-action: none;
}

/* 弹层打开时，底部导航和方印让开，别从遮罩里露出来 */
body.locked .tabbar {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
}
body.locked .fab {
  opacity: 0;
  pointer-events: none;
}
.tabbar { transition: opacity 0.22s ease, transform 0.22s ease; }
.fab { transition: opacity 0.22s ease, transform 0.3s var(--ease), background 0.3s; }

/* 弹层打开时星空压暗，把注意力收回到纸上 */
body.locked #stars { opacity: 0.35; }
#stars { transition: opacity 0.3s ease; }

/* ---------------------------------------------------------------------------
 *  2. 「写一条」：48px 朱砂方印，象牙「写」字
 * -------------------------------------------------------------------------*/
.tabbar .fab {
  width: 48px !important;
  height: 48px !important;
  border-radius: 2px !important;
  margin-top: -14px !important;
  background: var(--seal) !important;
  color: #fdf6ef !important;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.22) inset,
    0 0 0 1px rgba(242, 237, 227, 0.16),
    0 14px 24px -14px rgba(0, 0, 0, 0.95) !important;
}
.tabbar .fab .ico { display: none; }
.tabbar .fab::after {
  content: "写";
  font-family: var(--zh-serif);
  font-size: 15px;
  letter-spacing: 0.04em;
  line-height: 1;
  color: #fdf6ef;
}
.tabbar .fab:active { transform: scale(0.94) !important; background: var(--seal-2) !important; }

/* 只在首页 / 记录 / 相册露出方印 */
body[data-route="ours"] .fab,
body[data-route="timeline"] .fab,
body[data-route="letter"] .fab,
body[data-route="settings"] .fab { display: none; }

/* ---------------------------------------------------------------------------
 *  3. 导航：字再大一点（9px 真的看不清），按压态补上
 * -------------------------------------------------------------------------*/
.tab i { font-size: 11px !important; letter-spacing: 0.14em !important; }
.tab:active .ico { transform: scale(0.9); }
.tab:active i { border-bottom-color: var(--line-2); }

/* ---------------------------------------------------------------------------
 *  4. 记录：去卡片，只留一道发丝线和呼吸
 * -------------------------------------------------------------------------*/
.moment {
  background: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

/* 可点区域统一到 44px，别再用 19px 的小叉 */
.icon-btn {
  min-width: 44px;
  min-height: 44px;
  margin: -6px;
}
.m-acts button { min-height: 44px !important; padding-inline: 10px !important; }
.react { min-height: 40px; }

.cp-x {
  width: 44px !important;
  height: 44px !important;
  top: -10px !important;
  right: -10px !important;
  background: transparent !important;
  font-size: 0 !important;
  display: grid;
  place-items: center;
  border: 0;
}
.cp-x::after {
  content: "×";
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  color: #fdf6ef;
  background: rgba(10, 12, 16, 0.78);
  box-shadow: 0 0 0 1px rgba(242, 237, 227, 0.22);
}

/* ---------------------------------------------------------------------------
 *  5. 相册：接触印相 —— 3 列、2px 缝、零圆角
 * -------------------------------------------------------------------------*/
.album-grid { gap: 2px !important; }
.album-item { border-radius: 0 !important; }
.album-item:active { opacity: 0.82; }

/* ---------------------------------------------------------------------------
 *  6. 编辑面板：跟住软键盘、底部按钮常驻、能下滑关闭
 * -------------------------------------------------------------------------*/
.sheet-card {
  max-height: calc(var(--vvh, 100svh) - 16px) !important;
  padding-bottom: calc(10px + env(safe-area-inset-bottom)) !important;
}
.sheet-body {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.sheet-foot {
  position: sticky;
  bottom: 0;
  z-index: 3;
  margin-top: 4px;
  padding-bottom: calc(4px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(18, 21, 28, 0), rgba(14, 17, 23, 0.96) 32%);
}
.sheet-foot .btn-primary,
.sheet-foot .btn-ghost { min-height: 48px; }
.btn-primary[aria-busy="true"] { opacity: 0.6; pointer-events: none; }
.btn-primary:disabled { opacity: 0.5; }

/* 心情：六个词一排，选中加朱砂点（原来 emoji 已换成线性图标） */
.mood { min-height: 52px; }
.mood.on { color: var(--ivory) !important; }

/* ---------------------------------------------------------------------------
 *  7. 情书：纸页带毛边与噪点，正文先占位，避免打字时整页往下长
 * -------------------------------------------------------------------------*/
.letter {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/><feColorMatrix type='saturate' values='0'/></filter><rect width='140' height='140' filter='url(%23n)' opacity='0.35'/></svg>");
  background-blend-mode: multiply;
  background-repeat: repeat;
}
.letter-body { min-height: 15em; }
.letter-sign-row { min-height: 44px; }

/* 灯箱：照片落在同一张纸上 */
.lb-figure {
  background: var(--paper);
  padding: 12px 12px 0;
  border-radius: 1px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18), 0 28px 60px -40px #000;
}
.lb-figure .lb-img { background: #d9d1c1; }
.lb-figure .lb-img img { max-height: 62svh; border-radius: 0; }
.lb-figure figcaption {
  background: var(--paper);
  padding: 10px 2px calc(14px + env(safe-area-inset-bottom));
}
.lb-figure figcaption b,
.lb-figure figcaption span { color: var(--ink-2) !important; }
.lb-figure figcaption b { color: var(--ink) !important; }
.lightbox { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }

/* 双击放大 */
.lb-img img.zoomed {
  transform: scale(2);
  max-height: none !important;
  cursor: zoom-out;
  transition: transform 0.25s var(--ease);
}
.lb-img { overflow: auto; }

/* 图片挂了也要有个交代 */
.img-broken {
  min-height: 80px;
  background: repeating-linear-gradient(135deg, rgba(242, 237, 227, 0.05) 0 6px, transparent 6px 12px);
  opacity: 0.5;
}

/* ---------------------------------------------------------------------------
 *  8. 设置：危险区单独隔开
 * -------------------------------------------------------------------------*/
.danger-zone {
  margin-top: 44px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.danger-zone .sec-no,
.danger-zone h2 { color: var(--seal-lit); }
.danger-zone .btn-ghost.danger {
  border-color: rgba(178, 58, 46, 0.5);
  color: var(--seal-lit);
}

/* ---------------------------------------------------------------------------
 *  9. 焦点可见 + 按压反馈（屏幕上看得见「我点到了」）
 * -------------------------------------------------------------------------*/
:where(button, a, input, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--seal-lit);
  outline-offset: 3px;
}
:where(.tab, .chip, .link, .entry, .album-item, .react, .btn-ghost, .btn-primary):active {
  opacity: 0.72;
}
.entry:active { transform: translateY(1px); }

/* ---------------------------------------------------------------------------
 * 10. 启动屏 / 离线 / 更新 / 无脚本
 * -------------------------------------------------------------------------*/
.splash {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: var(--night-0);
  transition: opacity 0.5s ease;
}
.splash.gone { opacity: 0; pointer-events: none; }
.splash-mark {
  width: 46px;
  height: 46px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  place-items: center;
  border: 1px solid var(--seal);
  color: var(--seal-lit);
  font-family: var(--zh-serif);
  font-size: 13px;
  line-height: 1;
}
.splash-mark i { font-style: normal; }
.splash-name {
  margin: 0;
  font-family: var(--zh-serif);
  font-size: 15px;
  letter-spacing: 0.24em;
  color: var(--ivory-2);
}
.splash-sub {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--dim);
}
.noscript {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-content: center;
  padding: 40px;
  text-align: center;
  background: var(--night-0);
  color: var(--ivory);
  font-size: 14px;
  line-height: 1.9;
}

.netbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ivory-2);
  background: rgba(178, 58, 46, 0.16);
  border-top: 1px solid rgba(178, 58, 46, 0.35);
}
.netdot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--seal-lit);
  animation: netPulse 1.8s ease-in-out infinite;
}
@keyframes netPulse { 50% { opacity: 0.3; } }

.updatebar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--tab-h) + 20px + env(safe-area-inset-bottom));
  z-index: 46;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 9px 9px 16px;
  border-radius: 2px;
  font-size: 12px;
  color: var(--ivory);
  background: rgba(22, 26, 34, 0.97);
  border: 1px solid var(--line-2);
  box-shadow: 0 18px 40px -20px #000;
}
.updatebar button {
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 1px;
  background: var(--seal);
  color: #fdf6ef;
  font-size: 12px;
  letter-spacing: 0.1em;
}

/* 错误提示：停留更久 + 朱砂边 */
.toast.err {
  border-color: rgba(178, 58, 46, 0.6);
  color: #f0d9d4;
}

/* ---------------------------------------------------------------------------
 * 11. 首页小注：示例计数 / 天数副行
 * -------------------------------------------------------------------------*/
.ledger-note {
  margin: 10px 0 0;
  font-size: 11px;
  line-height: 1.8;
  letter-spacing: 0.04em;
  color: var(--dim);
}
.since-line {
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--muted);
}
.since-line b {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 400;
  color: var(--ivory);
}

/* 长昵称不撑破版式 */
.pair-names,
.ours-names,
.lock-title {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.who-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------------------------------------------------------------------
 * 12. 小字兜底：任何地方不再低于 11px
 * -------------------------------------------------------------------------*/
.album-date,
.demo-tag,
.m-hint,
.sec-sub,
.eyebrow,
.month .n { font-size: 11px; }