/* 啊呜的好朋友们 · 基础样式（切片 0：暖金基调，克制；粒子/Bloom 属后续切片） */

:root {
  --bg: #fdf6e9;
  --bg-soft: #f9edd7;
  --card: #fffaf0;
  --gold: #f2c94c;
  --gold-deep: #e0a92e;
  --ink: #4a3b2a;
  --ink-soft: #8a7458;
  --line: #e8dac0;
  --danger: #b3502e;
  --ok: #4c7a43;
  --radius: 18px;
}

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

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 24px 20px calc(96px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

/* ---------- 底部 4-Tab 导航 ---------- */
#tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 480px;
  display: flex;
  background: rgba(255, 250, 240, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}

/* hidden 属性的 display:none 会被上方 display:flex 盖掉，需显式恢复 */
#tabbar[hidden] { display: none; }

.tab {
  flex: 1;
  position: relative;
  border: 0;
  background: none;
  padding: 10px 2px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.2;
  cursor: pointer;
}

.tab .tab-icon {
  display: inline-flex;
  transition: transform 0.18s ease, filter 0.18s ease, color 0.18s ease;
}
.tab .tab-icon svg { width: 22px; height: 22px; }

.tab.active { color: #a86e12; font-weight: 600; }
/* 选中态：整图标暖金发亮（B2 调参定稿，2026-07-19 用户拍板） */
.tab.active .tab-icon {
  transform: translateY(-1px) scale(1.15);
  color: #ffb52e;
  filter: drop-shadow(0 0 2px rgba(255, 224, 140, 1))
    drop-shadow(0 0 7px rgba(255, 170, 40, 0.65))
    drop-shadow(0 0 14px rgba(255, 170, 40, 0.3));
}

/* ---------- 通用控件 ---------- */
.btn-primary {
  display: inline-block;
  background: var(--gold);
  border: none;
  border-radius: 999px;
  padding: 14px 30px;
  font-size: 17px;
  font-weight: 600;
  color: #5d3f10;
  box-shadow: 0 4px 14px rgba(224, 169, 46, 0.35);
  cursor: pointer;
}
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.6; }

.btn-ghost {
  display: inline-block;
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 14px;
  color: var(--ink-soft);
  cursor: pointer;
}

.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 14px;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  padding: 13px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fffdf7;
  font-size: 16px;
  color: var(--ink);
}
.field input:focus { outline: 2px solid var(--gold); border-color: transparent; }

.form-msg { min-height: 22px; font-size: 14px; color: var(--danger); margin: 6px 0 12px; }
.form-msg.ok { color: var(--ok); }

.soft { color: var(--ink-soft); font-size: 14px; }

/* ---------- 登录前引导页（大面积留白） ---------- */
.landing {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}
.landing-hello { font-size: 42px; letter-spacing: 2px; }
.landing-sub {
  font-size: 20px;
  color: var(--ink-soft);
  letter-spacing: 5px;
  margin: 14px 0 56px;
}

/* ---------- 表单页（登录/引导） ---------- */
.form-page { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.form-page h1 { font-size: 24px; margin-bottom: 6px; }
.form-page .soft { margin-bottom: 28px; }
.form-page .btn-primary { width: 100%; margin-top: 4px; }
.form-page .btn-ghost { align-self: center; margin-top: 18px; border: none; text-decoration: underline; }

/* ---------- Tab 占位页 ---------- */
.tab-page { flex: 1; display: flex; flex-direction: column; }
.tab-page h1 { font-size: 22px; margin-top: 12px; }
.empty-hint {
  margin: auto;
  padding-bottom: 12vh;
  text-align: center;
  color: var(--ink-soft);
  font-size: 15px;
  letter-spacing: 1px;
}
.tab-page .btn-ghost { align-self: center; margin-bottom: 24px; }

/* 「我在」寄语编辑 */
.empty-hint .hint-edit {
  border: none;
  background: none;
  color: var(--ink-soft);
  font-size: 14px;
  cursor: pointer;
  opacity: 0.55;
  margin-left: 8px;
  padding: 4px;
}
.empty-hint .hint-edit:active { opacity: 1; }
.hint-input {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fffdf7;
  font-size: 16px;
  color: var(--ink);
  width: min(260px, 62%);
  text-align: center;
}
.hint-input:focus { outline: 2px solid var(--gold); border-color: transparent; }
.hint-btn {
  border: none;
  background: none;
  color: var(--ink-soft);
  font-size: 13px;
  cursor: pointer;
  padding: 8px 6px;
  text-decoration: underline;
}

/* ---------- 状态页 ---------- */
.loading, .error-box { margin: 38vh auto 0; text-align: center; color: var(--ink-soft); }
.error-box .btn-primary { margin-top: 18px; }

/* ---------- 模块一 · 绘本屋（切片 1） ---------- */
.shelf-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}
.shelf-head h1 { margin: 0; }

.btn-small { padding: 9px 18px; font-size: 14px; }

.book-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 18px;
}
.book-grid .empty-hint,
.book-grid .loading,
.book-grid .form-msg { grid-column: 1 / -1; }

/* 空书架时：网格撑满剩余高度，标语垂直居中 */
.book-grid.is-empty { flex: 1; align-content: center; }

.book-card {
  background: var(--card);
  border: none;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(122, 74, 31, 0.08);
  cursor: pointer;
  padding: 0;
  text-align: left;
  font: inherit;
  color: inherit;
}
.book-cover {
  width: 100%;
  aspect-ratio: 3 / 4;
  background: var(--bg-soft) center / cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  font-size: 13px;
}
.book-body { padding: 10px 12px 12px; }
.book-title { font-size: 15px; font-weight: 600; line-height: 1.35; }
.book-meta { font-size: 12px; color: var(--ink-soft); margin-top: 3px; }

.form-head { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.form-head h1 { font-size: 20px; margin: 0; }
.back-btn {
  border: none;
  background: none;
  color: var(--ink-soft);
  font-size: 15px;
  cursor: pointer;
  padding: 6px 2px;
  white-space: nowrap;
}

.book-form { margin-top: 18px; }
.book-form textarea {
  width: 100%;
  min-height: 110px;
  padding: 13px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fffdf7;
  font-size: 16px;
  font-family: inherit;
  color: var(--ink);
  resize: vertical;
}
.book-form textarea:focus { outline: 2px solid var(--gold); border-color: transparent; }
.book-form select {
  width: 100%;
  padding: 13px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fffdf7;
  font-size: 16px;
  color: var(--ink);
}
.book-form .btn-primary { width: 100%; }

.hearts { display: flex; gap: 3px; font-size: 24px; color: #e3d5b8; user-select: none; }
.hearts .heart { cursor: pointer; }
.hearts .heart.active { color: #e25563; }

.file-btn {
  display: inline-block;
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 12px 16px;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 14px;
  background: #fffdf7;
}
.img-preview-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.img-preview-row img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; }

.divider { border: none; border-top: 1px dashed var(--line); margin: 22px 0; }
.section-label { font-size: 14px; color: var(--ink-soft); margin-bottom: 14px; }

.detail-title { font-size: 24px; margin-top: 14px; }
.book-sub { color: var(--ink-soft); font-size: 13px; margin: 6px 0 18px; }

.entry-list { margin-top: 20px; }
.entry {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
  box-shadow: 0 2px 10px rgba(122, 74, 31, 0.06);
}
.entry-head {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: var(--ink-soft);
}
.age-tag {
  background: var(--bg-soft);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  color: #a86e12;
}
.entry-text { margin: 8px 0 0; font-size: 15px; line-height: 1.65; white-space: pre-wrap; }
.entry-images { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.entry-images img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
  cursor: pointer;
}

/* ---------- 设置页 + 头像入口 ---------- */
.avatar-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--gold);
  color: #5d3f10;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(224, 169, 46, 0.35);
  flex-shrink: 0;
}

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

.settings-group {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 16px 16px;
  margin-top: 16px;
  box-shadow: 0 2px 10px rgba(122, 74, 31, 0.06);
}
.settings-title { font-size: 13px; color: var(--ink-soft); margin-bottom: 10px; }
.settings-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  font-size: 14px;
}
.settings-label { color: var(--ink-soft); flex-shrink: 0; }
.settings-value { text-align: right; }
.settings-group .field { margin-bottom: 12px; }
.settings-group .btn-small { width: 100%; }

.btn-danger {
  color: #b3502e;
  border-color: #e3b8a8;
  margin-top: 24px;
  align-self: center;
}

/* ---------- 离线待同步（切片 2） ---------- */
.pending-zone {
  margin-top: 16px;
  background: rgba(249, 237, 215, 0.6);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 10px 14px 12px;
}
.pending-title { font-size: 13px; color: #a86e12; margin-bottom: 8px; }
.pending-card {
  background: var(--card);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 6px;
  opacity: 0.85;
}
.pending-card:last-child { margin-bottom: 0; }

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(76px + env(safe-area-inset-bottom));
  background: rgba(74, 59, 42, 0.92);
  color: #fdf6e9;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 50;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  max-width: 86vw;
  text-align: center;
}

/* ---------- 模块三 · 期待相遇（信封墙） ---------- */
.tab-badge {
  position: absolute;
  top: 4px;
  left: calc(50% + 4px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #d45a35;
  color: #fff;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
  font-weight: 600;
}

.wish-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px 14px;
  margin-top: 30px;
}
.wish-grid .loading,
.wish-grid .form-msg,
.wish-grid .empty-hint { grid-column: 1 / -1; }

.envelope {
  position: relative;
  background: #fffdf6;
  border: 1px solid var(--line);
  border-radius: 10px;
  aspect-ratio: 4 / 3.2;
  transform: rotate(var(--r, 0deg));
  box-shadow: 0 3px 10px rgba(122, 74, 31, 0.1);
  padding: 0 10px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
/* 信封翻盖折线 */
.envelope::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 10px;
  pointer-events: none;
  opacity: 0.45;
  background:
    linear-gradient(to bottom right, transparent 49.6%, var(--line) 49.6%, var(--line) 50.4%, transparent 50.4%) top left / 51% 60% no-repeat,
    linear-gradient(to bottom left, transparent 49.6%, var(--line) 49.6%, var(--line) 50.4%, transparent 50.4%) top right / 51% 60% no-repeat;
}
/* 封面从信封上边缘探出 */
.env-cover {
  position: absolute;
  top: -16px;
  left: 50%;
  width: 44%;
  aspect-ratio: 3 / 4;
  transform: translateX(-50%) rotate(-4deg);
  background: var(--bg-soft) center / cover no-repeat;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 3px 8px rgba(122, 74, 31, 0.28);
}
.env-title {
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: #6b4f2a;
  line-height: 1.4;
  /* 抬到邮戳行之上，长书名两行截断，避免与邮戳叠字 */
  margin-bottom: 30px;
  padding: 0 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.env-stamp {
  position: absolute;
  right: 8px;
  bottom: 8px;
  border: 1px dashed #b39a6d;
  border-radius: 6px;
  font-size: 11px;
  color: #8a7458;
  padding: 2px 6px;
  transform: rotate(-4deg);
  background: rgba(255, 255, 255, 0.75);
}
/* 即将到期（7 天内）：暖光 + 轻颤 */
.envelope.env-soon {
  box-shadow: 0 0 0 2px rgba(242, 201, 76, 0.55), 0 0 18px rgba(242, 201, 76, 0.45);
  animation: env-shiver 2.6s ease-in-out infinite;
}
@keyframes env-shiver {
  0%, 100% { transform: rotate(var(--r, 0deg)) translateX(0); }
  50% { transform: rotate(var(--r, 0deg)) translateX(0.7px); }
}
/* 已到期未读：邮戳橘红 */
.envelope.env-overdue .env-stamp {
  color: #c25e3a;
  border-color: #c25e3a;
  font-weight: 700;
}

/* 归档盒 */
.archive-box { margin-top: 26px; }
.archive-toggle {
  width: 100%;
  background: var(--bg-soft);
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 12px;
  font-size: 14px;
  color: var(--ink-soft);
  cursor: pointer;
}
.archive-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.archive-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-soft);
  background: #f5f0e6;
  border-radius: 10px;
  padding: 8px 12px;
  opacity: 0.78;
}

/* 计划时间行 + 期待相遇带入提示 */
.plan-row { display: flex; gap: 10px; }
.plan-row select { flex: 1; }
.wish-cover-note { font-size: 13px; color: #a86e12; margin: -6px 0 14px; }

/* ---------- 登录/引导页标题居中 + 期待相遇空态居中 ---------- */
.form-page h1,
.form-page .soft { text-align: center; }

.wish-grid.is-empty { flex: 1; align-content: center; }

/* ---------- 模块四 · 我在（灯塔星点 · 暗色夜空） ---------- */
.mom-hint {
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
  margin-top: 8px;
  letter-spacing: 1px;
}

.mom-search { display: flex; gap: 10px; margin-top: 14px; }
.mom-search input {
  flex: 1;
  padding: 12px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fffdf7;
  font-size: 15px;
  color: var(--ink);
}
.mom-search input:focus { outline: 2px solid var(--gold); border-color: transparent; }

.mom-sky {
  position: relative;
  margin-top: 8px;
  height: 320px;
  overflow: visible; /* 星点直接洒在夜空页面上，不再是一个黑框 */
}
.mom-sky .loading,
.mom-sky .form-msg { color: #b9b2a0; text-align: center; margin-top: 130px; }
.mom-sky-empty {
  color: #b9b2a0;
  text-align: center;
  margin-top: 62px;
  font-size: 14px;
  padding: 0 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.mom-sky-illo { width: 108px; opacity: 0.9; }
.mom-sky-illo svg { display: block; width: 100%; height: auto; }

.mom-star {
  position: absolute;
  transform: translateX(-50%);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: opacity 0.3s;
}
.mom-star-dot {
  border-radius: 50%;
  background: #ffd98a;
  box-shadow: 0 0 6px 2px rgba(255, 200, 110, 0.8), 0 0 18px 6px rgba(255, 190, 90, 0.35);
  transition: transform 0.2s, box-shadow 0.3s;
  animation: star-twinkle 3.4s ease-in-out infinite;
}
.mom-star-label {
  font-size: 10px;
  color: #d8cba8;
  margin-top: 7px;
  white-space: nowrap;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}
.mom-star.dim { opacity: 0.15; }
.mom-star.dim .mom-star-dot { box-shadow: none; animation-play-state: paused; }
.mom-star.lit { z-index: 2; }
.mom-star.lit .mom-star-dot {
  transform: scale(1.6);
  box-shadow: 0 0 10px 4px rgba(255, 210, 120, 0.95), 0 0 32px 12px rgba(255, 190, 90, 0.5);
}
.sky-crowded .mom-star-label { display: none; }
/* 背景装饰星（氛围，不可点） */
.deco-star {
  position: absolute;
  border-radius: 50%;
  background: #efe3c2;
  pointer-events: none;
  animation: star-twinkle 4.6s ease-in-out infinite;
}
@keyframes star-twinkle {
  0%, 100% { opacity: 0.72; }
  50% { opacity: 1; }
}
.star-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.star-lines polyline {
  fill: none;
  stroke: rgba(255, 205, 120, 0.55);
  stroke-width: 1.2;
  stroke-linecap: round;
}

.mom-list { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.mom-card {
  background: var(--card);
  border: none;
  border-radius: var(--radius);
  padding: 12px 16px;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(122, 74, 31, 0.06);
  font: inherit;
  color: inherit;
}
.mom-card-title { font-size: 15px; font-weight: 600; }
.mom-card-meta { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.mom-card-snippet { font-size: 13px; color: var(--ink-soft); margin-top: 6px; line-height: 1.5; }
.mom-card-snippet mark { background: rgba(242, 201, 76, 0.55); color: inherit; border-radius: 3px; padding: 0 1px; }
.mom-card-tags { font-size: 12px; color: #a86e12; margin-top: 6px; }

.mom-detail-note { font-size: 15px; line-height: 1.8; white-space: pre-wrap; margin-top: 10px; }
.mom-detail-cover { max-width: 45%; border-radius: 10px; margin: 8px 0; display: block; }

/* ---------- 我在 · 整页夜空主题（文档：暗色夜空，闹→静呼吸感） ---------- */
.mom-page {
  margin: -24px -20px calc(-96px - env(safe-area-inset-bottom));
  padding: 24px 20px calc(96px + env(safe-area-inset-bottom));
  min-height: 100dvh;
  background:
    radial-gradient(ellipse at 30% 0%, rgba(255, 196, 120, 0.13), transparent 46%),
    radial-gradient(ellipse at 28% 0%, #232a5e 0%, #121740 55%, #0b0f2c 100%);
  color: #e8e2d5;
}
.mom-page h1 { color: #f0e6cd; }
.mom-page .mom-hint { color: #b9b2a0; }
.mom-page .mom-search input {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
  color: #f0e6cd;
}
.mom-page .mom-search input::placeholder { color: #8d89a0; }
.mom-page .mom-card {
  background: rgba(255, 255, 255, 0.06);
  box-shadow: none;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.mom-page .mom-card-title { color: #f0e6cd; }
.mom-page .mom-card-meta,
.mom-page .mom-card-snippet { color: #b0a890; }
.mom-page .mom-card-tags { color: #e0b45e; }
.mom-page .detail-title,
.mom-page .mom-detail-note { color: #f0e6cd; }
.mom-page .book-sub { color: #b0a890; }
.mom-page .back-btn { color: #b9b2a0; }
.mom-page .field label { color: #b9b2a0; }
.mom-page .field input,
.mom-page .book-form textarea {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
  color: #f0e6cd;
}
.mom-page .field input::placeholder,
.mom-page .book-form textarea::placeholder { color: #8d89a0; }
.mom-page .file-btn {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.2);
  color: #b9b2a0;
}
.mom-page .section-label,
.mom-page .empty-hint { color: #b9b2a0; }
.mom-page .hint-input {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
  color: #f0e6cd;
}
.mom-page .hint-btn,
.mom-page .hint-edit { color: #b9b2a0; }
