/* ============================================================
   星语树洞 · Star Whisper Tree
   移动优先 · 粉紫渐变 · 玻璃拟态 · 治愈系
   ============================================================ */

:root {
  --ink: #32214b;
  --muted: #7c6a94;
  --pink: #ec4899;
  --violet: #8b5cf6;
  --grad: linear-gradient(120deg, #f472b6, #a78bfa);
  --card: rgba(255, 255, 255, 0.78);
  --card-solid: #ffffff;
  --card-border: rgba(255, 255, 255, 0.9);
  --line: rgba(139, 92, 246, 0.12);
  --shadow: 0 12px 32px rgba(139, 92, 246, 0.16);
  --shadow-sm: 0 6px 18px rgba(139, 92, 246, 0.10);
  --radius: 22px;
  --radius-sm: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: linear-gradient(180deg, #fdf2f8 0%, #f6ecff 45%, #eadcff 100%);
  background-attachment: fixed;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(84px + var(--safe-bottom));
}

/* ---------- 星空与光斑背景 ---------- */
.sky { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.blob { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .55; animation: blobFloat 16s ease-in-out infinite; }
.blob-a { width: 46vmax; height: 46vmax; left: -12vmax; top: -14vmax; background: radial-gradient(circle, #f9a8d4, transparent 65%); }
.blob-b { width: 42vmax; height: 42vmax; right: -14vmax; top: 8vmax; background: radial-gradient(circle, #c4b5fd, transparent 65%); animation-delay: -5s; }
.blob-c { width: 40vmax; height: 40vmax; left: 16vmax; bottom: -18vmax; background: radial-gradient(circle, #fbcfe8, transparent 65%); animation-delay: -10s; }
@keyframes blobFloat { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-24px) scale(1.05); } }

.stars { position: absolute; inset: 0; }
.star { position: absolute; width: 3px; height: 3px; border-radius: 50%;
  background: #b794f6; opacity: .5; animation: twinkle 3.4s ease-in-out infinite; }
@keyframes twinkle { 0%, 100% { opacity: .2; transform: scale(.8); } 50% { opacity: .8; transform: scale(1.2); } }

/* ---------- 布局容器 ---------- */
#app { position: relative; z-index: 1; max-width: 760px; margin: 0 auto; padding: 0 16px; }

/* ---------- 顶栏 ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 2px; margin-bottom: 10px;
}
.brand { display: flex; align-items: center; gap: 10px; border: 0; background: none; cursor: pointer; text-align: left; padding: 0; }
.brand-logo {
  width: 44px; height: 44px; border-radius: 15px; display: grid; place-items: center;
  font-size: 22px; color: #fff;
  background: var(--grad); box-shadow: 0 8px 18px rgba(167, 139, 250, .45);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 19px; letter-spacing: .5px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-text small { color: var(--muted); font-size: 12px; }
.top-nav { display: none; gap: 6px; background: var(--card); border: 1px solid var(--card-border); border-radius: 999px; padding: 5px; backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: var(--shadow-sm); }

.nav-btn {
  border: 0; cursor: pointer; font-family: inherit; background: transparent; color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 999px;
  font-size: 14px; font-weight: 600; transition: all .22s ease; -webkit-tap-highlight-color: transparent;
}
.nav-btn:hover { color: var(--ink); }
.nav-btn.active { color: #fff; background: var(--grad); box-shadow: 0 6px 14px rgba(236, 72, 153, .35); }

/* ---------- 视图切换 ---------- */
.view { display: none; }
.view.active { display: block; animation: viewIn .42s cubic-bezier(.22,.8,.36,1) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- 卡片通用 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  padding: 20px;
  margin-bottom: 16px;
}
.card-title { margin: 0 0 4px; font-size: 18px; }
.card-hint { margin: 0 0 14px; font-size: 13px; color: var(--muted); }
.section-title { font-size: 17px; margin: 4px 0 10px; }
.empty-hint { text-align: center; color: var(--muted); font-size: 14px; padding: 26px 12px; }

/* ---------- 按钮 ---------- */
.btn-primary, .btn-ghost {
  border: 0; cursor: pointer; font-family: inherit; font-size: 15px; font-weight: 700;
  border-radius: 999px; padding: 12px 20px; transition: transform .16s ease, box-shadow .16s ease, opacity .16s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary { color: #fff; background: var(--grad); box-shadow: 0 10px 22px rgba(167, 139, 250, .4); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 14px 28px rgba(167, 139, 250, .5); }
.btn-primary:active { transform: scale(.97); }
.btn-ghost { color: var(--violet); background: rgba(139, 92, 246, .10); border: 1px solid rgba(139, 92, 246, .25); }
.btn-ghost:hover { background: rgba(139, 92, 246, .18); }
.btn-block { width: 100%; }

/* ---------- Hero ---------- */
.hero { text-align: center; padding: 34px 22px 28px; position: relative; overflow: hidden; }
.hero::before { content: ""; position: absolute; inset: -40% -20% auto; height: 60%; background: radial-gradient(circle, rgba(249, 168, 212, .35), transparent 60%); }
.hero-badge { display: inline-block; font-size: 13px; font-weight: 600; color: var(--violet);
  background: rgba(139, 92, 246, .10); border: 1px solid rgba(139, 92, 246, .2);
  padding: 6px 14px; border-radius: 999px; margin-bottom: 16px; position: relative; }
.hero h2 { margin: 0 0 12px; font-size: clamp(26px, 7.4vw, 36px); line-height: 1.3; letter-spacing: 1px; }
.hero-sub { margin: 0 auto 18px; max-width: 420px; color: var(--muted); font-size: 14.5px; position: relative; }
.hero-stats { display: flex; justify-content: center; gap: 28px; margin: 4px 0 20px; position: relative; }
.hero-stats div { display: flex; flex-direction: column; }
.hero-stats b { font-size: 22px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-stats span { font-size: 12px; color: var(--muted); }
.hero-cta { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; position: relative; }

/* ---------- 发布表单 ---------- */
.mood-row { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: none; }
.mood-row::-webkit-scrollbar { display: none; }
.mood-btn {
  flex: 0 0 auto; display: flex; align-items: center; gap: 5px; border: 1.5px solid var(--line);
  background: #fff; border-radius: 999px; padding: 8px 13px; font-family: inherit; font-size: 13.5px;
  cursor: pointer; color: var(--ink); transition: all .2s ease; -webkit-tap-highlight-color: transparent;
}
.mood-btn .m-emoji { font-size: 17px; }
.mood-btn.selected { color: #fff; border-color: transparent; transform: translateY(-2px); box-shadow: 0 6px 14px rgba(0,0,0,.12); }
.mood-btn:active { transform: scale(.96); }

textarea, input[type="text"] {
  width: 100%; font-family: inherit; font-size: 15px; color: var(--ink);
  background: rgba(255,255,255,.85); border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 13px 14px; resize: vertical; outline: none; transition: border-color .2s ease, box-shadow .2s ease;
}
textarea { min-height: 96px; }
textarea:focus, input:focus { border-color: var(--violet); box-shadow: 0 0 0 4px rgba(139, 92, 246, .12); }
textarea::placeholder, input::placeholder { color: #a99bc2; }

.composer-meta { display: flex; justify-content: flex-end; margin: 6px 2px 12px; }
.char-count { font-size: 12px; color: var(--muted); }
.char-count b { color: var(--violet); }

.tag-picker { margin-bottom: 14px; }
.pick-label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1.5px solid var(--line); background: #fff; color: var(--muted); border-radius: 999px;
  padding: 6px 12px; font-size: 13px; font-family: inherit; cursor: pointer; transition: all .2s ease;
  -webkit-tap-highlight-color: transparent;
}
.chip:hover { border-color: rgba(139, 92, 246, .4); }
.chip.on { color: #fff; background: var(--grad); border-color: transparent; box-shadow: 0 5px 12px rgba(236, 72, 153, .3); }

/* ---------- 倾诉流 ---------- */
.stream-head { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.stream-head .section-title { margin: 0; }
.quick-filters { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.quick-filters::-webkit-scrollbar { display: none; }
.quick-filters .chip { flex: 0 0 auto; }

.whisper-list { display: flex; flex-direction: column; gap: 14px; }

.whisper { animation: cardIn .5s cubic-bezier(.22,.8,.36,1) both; }
@keyframes cardIn { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }

.w-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-size: 20px;
  color: #fff; box-shadow: 0 4px 10px rgba(0,0,0,.12); flex: 0 0 auto;
}
.w-who { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.w-who .nick { font-size: 14px; font-weight: 700; }
.w-who .time { font-size: 12px; color: var(--muted); }
.mood { margin-left: auto; font-size: 22px; filter: drop-shadow(0 2px 4px rgba(0,0,0,.08)); }

.w-text { margin: 0 0 10px; font-size: 15px; white-space: pre-wrap; word-break: break-word; }
.whisper .chips { margin-bottom: 12px; }
.whisper .chip { font-size: 12px; padding: 4px 10px; pointer-events: none; }

.w-foot { display: flex; gap: 10px; border-top: 1px dashed var(--line); padding-top: 12px; }
.hug-btn {
  border: 0; cursor: pointer; font-family: inherit; display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 700; color: var(--pink); background: rgba(236, 72, 153, .10);
  border: 1px solid rgba(236, 72, 153, .25); border-radius: 999px; padding: 8px 16px;
  transition: all .2s ease; -webkit-tap-highlight-color: transparent; position: relative;
}
.hug-btn:hover { background: rgba(236, 72, 153, .18); }
.hug-btn:active { transform: scale(.92); }
.hug-btn .hug-ico { font-size: 17px; transition: transform .3s ease; }
.hug-btn.hugged .hug-ico { animation: hugPulse .5s ease; }
@keyframes hugPulse { 0% { transform: scale(1); } 40% { transform: scale(1.5) rotate(-12deg); } 100% { transform: scale(1); } }
.hug-btn.big { padding: 12px 22px; font-size: 16px; }
.reply-toggle {
  border: 0; cursor: pointer; font-family: inherit; display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 600; color: var(--muted); background: rgba(139, 92, 246, .08);
  border: 1px solid transparent; border-radius: 999px; padding: 8px 16px; transition: all .2s ease;
  -webkit-tap-highlight-color: transparent;
}
.reply-toggle:hover { color: var(--violet); background: rgba(139, 92, 246, .14); }
.reply-toggle.open { color: var(--violet); background: rgba(139, 92, 246, .14); }

.replies { display: none; margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 12px; }
.replies.open { display: block; animation: viewIn .3s ease both; }
.reply { display: flex; gap: 8px; margin-bottom: 10px; }
.reply .avatar { width: 30px; height: 30px; font-size: 14px; }
.reply-body { flex: 1; min-width: 0; background: rgba(139, 92, 246, .06); border-radius: 14px; padding: 9px 12px; }
.reply-body .r-nick { font-size: 12px; font-weight: 700; color: var(--violet); }
.reply-body .r-text { font-size: 14px; margin: 2px 0 0; }
.reply-form { display: flex; gap: 8px; align-items: flex-end; }
.reply-input { flex: 1; min-height: 40px; height: 40px; padding: 9px 12px; }
.reply-send {
  border: 0; cursor: pointer; font-family: inherit; color: #fff; background: var(--grad);
  border-radius: 12px; width: 44px; height: 40px; font-size: 17px; flex: 0 0 auto;
  transition: transform .16s ease; -webkit-tap-highlight-color: transparent;
}
.reply-send:active { transform: scale(.92); }
.replies-hint { font-size: 12.5px; color: var(--muted); margin: 2px 0 10px; }

/* ---------- 分类浏览 ---------- */
.browse-head { padding: 6px 2px 14px; }
.browse-head h2 { margin: 0 0 4px; font-size: 24px; }
.browse-head p { margin: 0; color: var(--muted); font-size: 14px; }
.filter-card .filter-label { font-size: 13.5px; font-weight: 700; margin: 14px 0 8px; }
.filter-card .filter-label:first-child { margin-top: 0; }
.filter-card .chips { gap: 7px; }

/* ---------- 今日星语 ---------- */
.today-head { text-align: center; padding: 8px 2px 14px; }
.date-chip { display: inline-block; font-size: 13px; color: var(--violet); font-weight: 600;
  background: rgba(139, 92, 246, .10); border: 1px solid rgba(139, 92, 246, .2);
  padding: 5px 14px; border-radius: 999px; margin-bottom: 10px; }
.today-head h2 { margin: 0 0 4px; font-size: 26px; }
.today-head p { margin: 0; color: var(--muted); font-size: 14px; }

.today-card { text-align: center; overflow: hidden; }
.today-illu { border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 16px; line-height: 0; }
.illu { width: 100%; height: auto; display: block; }
.quote-meta { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.mood-big { font-size: 30px; }
.today-card .nick { font-size: 14.5px; font-weight: 700; }
.quote-time { font-size: 12px; color: var(--muted); }
.today-card blockquote { margin: 0 auto 12px; max-width: 480px; font-size: 17px; line-height: 1.8;
  color: var(--ink); quotes: "“" "”"; }
.today-card blockquote::before { content: open-quote; font-size: 26px; color: var(--pink); font-weight: 800; }
.today-card blockquote::after { content: close-quote; font-size: 26px; color: var(--pink); font-weight: 800; }
.today-card .chips { justify-content: center; margin-bottom: 16px; }
.today-card .chip { pointer-events: none; }
.today-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.today-note { margin: 14px 0 0; font-size: 12px; color: var(--muted); }

.today-history { display: flex; flex-direction: column; gap: 12px; }
.mini-quote { text-align: left; }
.mini-quote .mq-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.mini-quote .mq-emoji { font-size: 20px; }
.mini-quote .mq-meta { font-size: 12.5px; color: var(--muted); }
.mini-quote p { margin: 0; font-size: 14.5px; line-height: 1.7; }

/* ---------- 树洞信箱 ---------- */
.mailbox-head { text-align: center; padding: 8px 2px 14px; }
.mailbox-emoji { font-size: 52px; display: block; margin-bottom: 6px; filter: drop-shadow(0 8px 16px rgba(236,72,153,.35)); animation: floaty 3.6s ease-in-out infinite; }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.mailbox-head h2 { margin: 0 0 4px; font-size: 26px; }
.mailbox-head p { margin: 0; color: var(--muted); font-size: 14px; }
.mailbox input { margin-bottom: 12px; }
.mailbox textarea { min-height: 130px; }

.mail-thread { display: flex; flex-direction: column; gap: 12px; }
.bubble { max-width: 86%; padding: 13px 16px; border-radius: 18px; font-size: 14.5px; line-height: 1.7;
  box-shadow: var(--shadow-sm); position: relative; animation: viewIn .4s ease both; }
.bubble.mine { align-self: flex-end; background: var(--grad); color: #fff; border-bottom-right-radius: 6px; }
.bubble.reply { align-self: flex-start; background: #fff; border: 1px solid var(--card-border); border-bottom-left-radius: 6px; }
.bubble-title { font-weight: 700; margin-bottom: 2px; }
.bubble .b-time { display: block; margin-top: 6px; font-size: 11.5px; opacity: .75; }
.bubble.mine .b-time { text-align: right; }

.typing { align-self: flex-start; background: #fff; border: 1px solid var(--card-border); border-radius: 18px;
  border-bottom-left-radius: 6px; padding: 13px 16px; display: inline-flex; gap: 5px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--violet); opacity: .4; animation: typingBlink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes typingBlink { 0%, 100% { transform: translateY(0); opacity: .4; } 50% { transform: translateY(-5px); opacity: 1; } }

/* ---------- 底部导航（移动端） ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: flex; justify-content: space-around; gap: 4px;
  background: rgba(255, 255, 255, .82); border-top: 1px solid var(--card-border);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  padding: 8px 10px calc(8px + var(--safe-bottom));
  box-shadow: 0 -8px 24px rgba(139, 92, 246, .12);
}
.bottom-nav .nav-btn { flex-direction: column; gap: 2px; flex: 1; padding: 6px 4px; font-size: 11px; font-weight: 600; }
.bottom-nav .nav-ico { font-size: 19px; line-height: 1; }
.bottom-nav .nav-btn.active { box-shadow: none; }

/* ---------- 页脚 ---------- */
.site-footer { text-align: center; padding: 26px 10px 8px; color: var(--muted); }
.site-footer p { margin: 0 0 6px; font-size: 13.5px; }
.site-footer .legal { font-size: 12px; opacity: .85; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(104px + var(--safe-bottom)); transform: translate(-50%, 20px);
  background: rgba(50, 33, 75, .92); color: #fff; font-size: 14px; font-weight: 600;
  padding: 11px 20px; border-radius: 999px; box-shadow: 0 10px 24px rgba(0,0,0,.25);
  opacity: 0; pointer-events: none; z-index: 90; transition: all .3s ease; max-width: 86vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 飘心动画 ---------- */
.hearts-layer { position: fixed; inset: 0; pointer-events: none; z-index: 80; overflow: hidden; }
.fly-heart { position: fixed; transform: translate(-50%, -50%); font-size: 18px;
  animation: flyUp 1.4s ease-out forwards; will-change: transform, opacity; }
@keyframes flyUp {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.6); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% - var(--dy, 80px))) scale(1.5); }
}

/* ---------- 桌面端 ---------- */
@media (min-width: 768px) {
  body { padding-bottom: 40px; }
  .bottom-nav { display: none; }
  .top-nav { display: flex; }
  #app { padding: 0 20px; }
  .hero { padding: 44px 34px 34px; }
  .stream-head { flex-direction: row; align-items: center; justify-content: space-between; }
  .stream-head .section-title { margin: 0; }
  .toast { bottom: 32px; }
}

/* ---------- 动效减弱 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}
