/* ♥ 心动信号站 · 夜空主题 */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --sky-0: #0d1230;
  --sky-1: #131a3e;
  --pink: #ff5c8a;
  --pink-soft: #ff9fbe;
  --pink-dim: rgba(255, 92, 138, 0.35);
  --ink: #f4f2ff;
  --ink-dim: rgba(244, 242, 255, 0.62);
  --panel: rgba(19, 26, 62, 0.82);
  --panel-border: rgba(255, 159, 190, 0.22);
  --radius: 14px;
  --radius-full: 999px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --font: "PingFang SC", "Microsoft YaHei", "SF Pro SC", system-ui, -apple-system, sans-serif;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--sky-0);
  color: var(--ink);
  user-select: none;
  touch-action: manipulation;
}

#sky {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
}

.hidden { display: none !important; }

button { font-family: var(--font); cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: var(--font); }

/* ---------- 顶部：恋爱时光 ---------- */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 18px 10px;
  background: linear-gradient(rgba(13, 18, 48, 0.85), rgba(13, 18, 48, 0));
}

.couple { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 600; }
.heart-link { color: var(--pink); font-size: 14px; animation: beat 1.6s ease-in-out infinite; }
@keyframes beat {
  0%, 100% { transform: scale(1); }
  12% { transform: scale(1.25); }
  24% { transform: scale(1); }
}

.together { text-align: center; line-height: 1.25; }
.together-label { font-size: 11px; color: var(--ink-dim); margin: 0 3px; }
.together-num {
  font-size: 22px; font-weight: 700; color: var(--pink-soft);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 14px var(--pink-dim);
}
.together-sub { display: block; font-size: 11px; color: var(--ink-dim); font-variant-numeric: tabular-nums; }

.love-point {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-full);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(8px);
}
.lp-heart { color: var(--pink); font-size: 14px; }
.lp-num { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- 发送爱心 ---------- */
#scene {
  position: fixed;
  left: 50%; bottom: 15vh;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: min(92vw, 420px);
}

#sendBtn {
  position: relative;
  width: 108px; height: 108px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 35% 30%, rgba(255, 130, 165, 0.25), rgba(255, 92, 138, 0.08));
  border: 1px solid var(--panel-border);
  box-shadow: 0 0 28px var(--pink-dim), inset 0 0 22px rgba(255, 92, 138, 0.18);
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
  touch-action: none;
}
#sendBtn:hover { border-color: rgba(255, 159, 190, 0.55); box-shadow: 0 0 44px rgba(255, 92, 138, 0.55), inset 0 0 26px rgba(255, 92, 138, 0.28); }
.send-heart {
  font-size: 52px;
  color: var(--pink);
  text-shadow: 0 0 18px rgba(255, 92, 138, 0.9), 0 0 46px rgba(255, 92, 138, 0.5);
  line-height: 1;
  transition: transform 0.12s ease;
}
#sendBtn.charging .send-heart { animation: beat 0.8s ease-in-out infinite; }

.charge-ring {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--pink);
  border-right-color: var(--pink);
  opacity: 0;
  transform: rotate(0deg);
}
#sendBtn.charging .charge-ring { opacity: 0.9; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.send-row { display: flex; gap: 10px; }
.ghost-btn {
  padding: 8px 16px;
  border-radius: var(--radius-full);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--ink-dim);
  font-size: 13px;
  backdrop-filter: blur(8px);
  transition: color 0.2s, border-color 0.2s;
}
.ghost-btn:hover { color: var(--ink); border-color: rgba(255, 159, 190, 0.5); }
.ghost-btn.small { font-size: 12px; padding: 6px 12px; }

.note-box { width: 100%; }
#noteInput {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-full);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--ink);
  font-size: 14px;
  outline: none;
  text-align: center;
  backdrop-filter: blur(8px);
}
#noteInput::placeholder { color: var(--ink-dim); }

.send-hint { font-size: 12px; color: var(--ink-dim); letter-spacing: 2px; }

/* ---------- 底部导航 ---------- */
#dock {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  left: 50%; transform: translateX(-50%);
  z-index: 10;
  display: flex;
  gap: 12px;
}
.dock-btn {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  width: 74px; padding: 10px 0 8px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
  transition: border-color 0.2s, transform 0.15s;
}
.dock-btn:hover { border-color: rgba(255, 159, 190, 0.55); transform: translateY(-2px); }
.dock-ico { font-size: 19px; }
.dock-tip { font-size: 11px; color: var(--ink-dim); }
.badge {
  position: absolute; top: -6px; right: -4px;
  min-width: 19px; height: 19px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
  border-radius: var(--radius-full);
  background: var(--pink);
  color: #fff;
  font-size: 11px; font-weight: 700;
  box-shadow: 0 0 10px var(--pink-dim);
}

/* ---------- 字幕 / 里程碑 ---------- */
.note-overlay {
  position: fixed;
  top: 22vh; left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  max-width: 86vw;
  padding: 12px 26px;
  border-radius: var(--radius-full);
  background: rgba(13, 18, 48, 0.72);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
  font-size: 17px;
  letter-spacing: 1px;
  color: #ffd9e4;
  text-shadow: 0 0 12px var(--pink-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: floatIn 0.8s ease both;
}
@keyframes floatIn { from { opacity: 0; transform: translate(-50%, 14px); } to { opacity: 1; transform: translate(-50%, 0); } }

.milestone-overlay {
  position: fixed; inset: 0;
  z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: rgba(13, 18, 48, 0.55);
  backdrop-filter: blur(6px);
}
.milestone-card {
  width: min(86vw, 360px);
  padding: 34px 28px;
  border-radius: 20px;
  background: var(--panel);
  border: 1px solid rgba(255, 159, 190, 0.4);
  box-shadow: var(--shadow), 0 0 60px var(--pink-dim);
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  animation: floatIn 0.6s ease both;
}
.ms-icon { font-size: 34px; color: var(--pink); text-shadow: 0 0 20px var(--pink-dim); }
.ms-title { font-size: 22px; font-weight: 700; color: var(--pink-soft); }
.ms-text { font-size: 14px; color: var(--ink-dim); line-height: 1.7; }
.milestone-card .ghost-btn { margin-top: 6px; }

/* ---------- 抽屉 ---------- */
.drawer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 76vh;
  z-index: 50;
  display: flex; flex-direction: column;
  background: var(--panel);
  border-top: 1px solid var(--panel-border);
  border-radius: 22px 22px 0 0;
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  animation: riseUp 0.32s cubic-bezier(0.22, 0.9, 0.36, 1) both;
}
@keyframes riseUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.drawer-title { font-size: 17px; font-weight: 600; color: var(--pink-soft); }
.drawer-close { font-size: 16px; color: var(--ink-dim); padding: 6px 10px; }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px calc(env(safe-area-inset-bottom, 0px) + 24px);
  display: flex; flex-direction: column; gap: 14px;
  -webkit-overflow-scrolling: touch;
}

.letter-new, .capsule-new { display: flex; flex-direction: column; gap: 10px; }
.letter-new textarea, .capsule-new textarea {
  width: 100%;
  min-height: 88px;
  padding: 13px 15px;
  border-radius: var(--radius);
  background: rgba(13, 18, 48, 0.6);
  border: 1px solid var(--panel-border);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  outline: none;
  resize: vertical;
}
textarea::placeholder { color: var(--ink-dim); }
textarea:focus { border-color: rgba(255, 159, 190, 0.55); }

.solid-btn {
  align-self: flex-end;
  padding: 10px 24px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #ff5c8a, #ff7fa3);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 18px rgba(255, 92, 138, 0.45);
  transition: transform 0.15s, box-shadow 0.2s;
}
.solid-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(255, 92, 138, 0.6); }
.solid-btn.big { align-self: stretch; text-align: center; padding: 13px; font-size: 15px; }

/* 信件卡片 */
.letter-list, .capsule-list, .mile-list { display: flex; flex-direction: column; gap: 10px; }

.letter {
  padding: 13px 15px;
  border-radius: var(--radius);
  background: rgba(13, 18, 48, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  animation: floatIn 0.4s ease both;
}
.letter.unread { border-color: rgba(255, 159, 190, 0.5); background: rgba(255, 92, 138, 0.08); }
.letter-meta, .capsule-meta {
  margin-top: 8px;
  font-size: 11px;
  color: var(--ink-dim);
  display: flex; justify-content: space-between;
}

/* 胶囊卡片 */
.capsule {
  padding: 14px 15px;
  border-radius: var(--radius);
  background: rgba(13, 18, 48, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  animation: floatIn 0.4s ease both;
}
.capsule.locked { border-style: dashed; }
.capsule-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.capsule-state { font-size: 12px; color: var(--pink-soft); }
.capsule-count { font-size: 12px; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.capsule-text { font-size: 14px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.capsule .ghost-btn { margin-top: 10px; align-self: flex-start; }

.capsule-date-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; color: var(--ink-dim);
}
#capsuleDate {
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(13, 18, 48, 0.6);
  border: 1px solid var(--panel-border);
  color: var(--ink);
  font-size: 14px;
  outline: none;
  color-scheme: dark;
}

/* 心动值面板 */
.lp-hero { text-align: center; padding: 10px 0 14px; }
.lp-big {
  font-size: 46px; font-weight: 700; color: var(--pink-soft);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 24px var(--pink-dim);
}
.lp-cap { font-size: 12px; color: var(--ink-dim); margin-top: 4px; }
.lp-split { font-size: 12px; color: var(--ink-dim); margin-top: 10px; }

.mile {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 15px;
  border-radius: var(--radius);
  background: rgba(13, 18, 48, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.mile.done { border-color: rgba(255, 159, 190, 0.45); }
.mile-num { font-size: 18px; font-weight: 700; color: var(--pink-soft); min-width: 56px; font-variant-numeric: tabular-nums; }
.mile-info { flex: 1; }
.mile-name { font-size: 14px; }
.mile-desc { font-size: 11px; color: var(--ink-dim); margin-top: 2px; }
.mile-state { font-size: 16px; }

/* ---------- 覆盖层（设置/身份/口令） ---------- */
.overlay {
  position: fixed; inset: 0;
  z-index: 80;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(13, 18, 48, 0.6);
  backdrop-filter: blur(10px);
}
.setup-card {
  width: min(88vw, 380px);
  max-height: 86vh;
  overflow-y: auto;
  padding: 30px 26px;
  border-radius: 22px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px;
  text-align: center;
  animation: floatIn 0.5s ease both;
}
.setup-title { font-size: 24px; font-weight: 700; color: var(--pink-soft); text-shadow: 0 0 18px var(--pink-dim); }
.setup-sub { font-size: 13px; color: var(--ink-dim); margin-top: -6px; }

.field { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.field span { font-size: 12px; color: var(--ink-dim); padding-left: 4px; }
.field input {
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(13, 18, 48, 0.6);
  border: 1px solid var(--panel-border);
  color: var(--ink);
  font-size: 15px;
  outline: none;
  color-scheme: dark;
}
.field input:focus { border-color: rgba(255, 159, 190, 0.55); }

.pin-input {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  background: rgba(13, 18, 48, 0.6);
  border: 1px solid var(--panel-border);
  color: var(--ink);
  font-size: 16px;
  letter-spacing: 4px;
  text-align: center;
  outline: none;
}
.pin-err { font-size: 12px; color: #ff9f9f; }

.id-row { display: flex; align-items: center; justify-content: center; gap: 18px; padding: 8px 0; }
.id-btn {
  min-width: 108px;
  padding: 18px 22px;
  border-radius: 18px;
  background: rgba(13, 18, 48, 0.6);
  border: 1px solid var(--panel-border);
  font-size: 19px;
  font-weight: 600;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}
.id-btn:hover { border-color: rgba(255, 159, 190, 0.6); box-shadow: 0 0 24px var(--pink-dim); transform: translateY(-2px); }
.id-mid { color: var(--pink); font-size: 20px; animation: beat 1.6s ease-in-out infinite; }

/* toast */
#toast {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 18vh);
  left: 50%; transform: translateX(-50%);
  z-index: 90;
  padding: 10px 22px;
  border-radius: var(--radius-full);
  background: rgba(13, 18, 48, 0.85);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
  font-size: 14px;
  color: var(--ink);
  animation: floatIn 0.4s ease both;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .couple { font-size: 15px; }
  .together-num { font-size: 19px; }
  #sendBtn { width: 96px; height: 96px; }
  .send-heart { font-size: 46px; }
}
