:root {
  --pink: #ff5a7a;
  --pink-soft: #ff8fa3;
  --orange: #ffa26b;
  --bg: #fff5f7;
  --card: #ffffff;
  --text: #2c2730;
  --muted: #9b93a1;
  --line: #f0e6ea;
  --grad: linear-gradient(135deg, #ff7a8a 0%, #ff9a6b 100%);
  --shadow: 0 8px 24px rgba(255, 90, 122, 0.14);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: #e9e4e8;
  color: var(--text);
  display: flex; justify-content: center; align-items: center;
  overflow: hidden;
}
#phone {
  position: relative;
  width: 390px; max-width: 100vw; height: 844px; max-height: 100vh;
  background: var(--bg);
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  border-radius: 0;
}
@media (min-width: 430px) { #phone { border-radius: 38px; border: 10px solid #1c1c1e; height: 860px; } }

#statusbar {
  height: calc(38px + var(--safe-t));
  padding-top: var(--safe-t);
  background: var(--grad);
  color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding-left: 22px; padding-right: 22px;
  font-size: 13px; font-weight: 600;
  flex: 0 0 auto;
}
#sb-icons { letter-spacing: 1px; opacity: 0.95; }

#app { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 16px 16px; }
#app::-webkit-scrollbar { width: 0; }

/* 顶部伴侣状态条 */
.topbar {
  margin: 12px -16px 0; padding: 16px 20px;
  background: var(--grad); color: #fff;
  border-radius: 0 0 26px 26px;
  box-shadow: var(--shadow);
}
.topbar .row { display: flex; align-items: center; justify-content: space-between; }
.topbar .couple { display: flex; align-items: center; justify-content: center; gap: 10px; }
.topbar .who { display: flex; align-items: center; gap: 8px; flex: 0 1 auto; min-width: 0; }
.topbar .who.you { flex-direction: row-reverse; }
.topbar .who .meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.topbar .who.you .meta { text-align: right; }
.topbar .avatar { width: 38px; height: 38px; border-radius: 50%; background: rgba(255,255,255,0.25); display: flex; align-items: center; justify-content: center; font-size: 18px; flex: 0 0 auto; }
.topbar .name { font-size: 16px; font-weight: 700; max-width: 110px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .sub { font-size: 12px; opacity: 0.9; margin-top: 1px; }
.topbar .loc-mini { font-size: 11px; opacity: 0.92; margin-top: 2px; max-width: 132px; white-space: normal; word-break: break-word; line-height: 1.3; }
.topbar .who.you .loc-mini { text-align: right; }
.topbar .heart-link { font-size: 22px; flex: 0 0 auto; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15)); animation: beat 1.6s ease-in-out infinite; }
@keyframes beat { 0%,100% { transform: scale(1); } 25% { transform: scale(1.18); } 40% { transform: scale(1); } }
.topbar .days-badge { text-align: center; margin-top: 12px; font-size: 13px; font-weight: 600; background: rgba(255,255,255,0.22); display: inline-block; padding: 7px 14px; border-radius: 20px; width: 100%; border: none; color: #fff; cursor: pointer; }
.topbar .days-badge.days-set { background: rgba(255,255,255,0.32); font-weight: 700; }
.topbar .days-badge .set-link { text-decoration: underline; cursor: pointer; opacity: 0.9; }
.dot-on { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 3px rgba(74,222,128,0.3); display: inline-block; }
.dot-off { width: 8px; height: 8px; border-radius: 50%; background: #cbd5e1; display: inline-block; }

/* 卡片 */
.card { background: var(--card); border-radius: 20px; padding: 18px; box-shadow: var(--shadow); margin-top: 16px; }
.section-title { font-size: 14px; color: var(--muted); margin: 22px 4px 0; font-weight: 600; }
.miss-card { padding: 16px 18px; }
.miss-top { display: flex; justify-content: space-around; align-items: center; }
.miss-stat { text-align: center; }
.miss-num { font-size: 30px; font-weight: 700; color: var(--pink); line-height: 1.1; }
.miss-lab { font-size: 12px; color: var(--muted); margin-top: 4px; }
.miss-last { text-align: center; color: var(--muted); font-size: 12px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }

/* 情话卡片 */
.quote-card { background: var(--card); border-radius: 24px; padding: 24px 20px; box-shadow: var(--shadow); margin-top: 16px; text-align: center; position: relative; }
.quote-card .cat { display: inline-block; font-size: 12px; color: var(--pink); background: #ffe6ec; padding: 3px 12px; border-radius: 20px; }
.quote-card .text { font-size: 21px; line-height: 1.7; margin: 18px 6px; font-weight: 600; letter-spacing: 0.5px; }
.quote-card .sign { color: var(--muted); font-size: 14px; margin-top: 6px; }
.quote-actions { display: flex; gap: 10px; margin-top: 8px; }
.btn { flex: 1; border: none; border-radius: 14px; padding: 12px; font-size: 14px; font-weight: 600; background: #fff0f3; color: var(--pink); cursor: pointer; transition: .15s; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--grad); color: #fff; }
.btn-ghost { background: #f4f0f2; color: var(--text); }

/* 宫格入口 */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; }
.grid .cell { background: var(--card); border-radius: 18px; padding: 14px 6px; text-align: center; box-shadow: var(--shadow); cursor: pointer; }
.grid .cell .ic { font-size: 24px; }
.grid .cell .lb { font-size: 11px; color: var(--muted); margin-top: 6px; }

/* 底部导航 */
#tabbar {
  flex: 0 0 auto;
  display: flex; height: calc(64px + var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(255,255,255,0.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
#tabbar .tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; color: var(--muted); cursor: pointer; }
#tabbar .tab .ic { font-size: 22px; }
#tabbar .tab.active { color: var(--pink); font-weight: 700; }
#tabbar .tab .ic { position: relative; }
.tab-badge { position: absolute; top: -6px; right: -10px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 9px; background: #ff3b5c; color: #fff; font-size: 10px; line-height: 16px; font-weight: 700; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,.25); }

/* 悬浮按钮 */
#fab {
  position: absolute; right: 20px; bottom: calc(80px + var(--safe-b));
  width: 60px; height: 60px; border-radius: 50%; border: none;
  background: var(--grad); color: #fff; font-size: 26px;
  box-shadow: 0 10px 26px rgba(255,90,122,0.45); cursor: pointer; z-index: 30;
  transition: transform .15s;
}
#fab:active { transform: scale(0.9); }

/* 列表项 */
.item { background: var(--card); border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow); margin-top: 12px; display: flex; align-items: center; gap: 12px; }
.item .main { flex: 1; }
.item .t { font-size: 15px; font-weight: 600; }
.item .s { font-size: 12px; color: var(--muted); margin-top: 3px; }
.item .tag { font-size: 11px; color: var(--pink); background: #ffe6ec; padding: 2px 8px; border-radius: 10px; }
.item .right { color: var(--pink); font-weight: 700; font-size: 13px; }

/* 倒计时大数字 */
.count-big { font-size: 34px; font-weight: 800; color: var(--pink); }
.count-sub { font-size: 12px; color: var(--muted); }

/* 表单 */
.field { width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; font-size: 15px; margin-top: 10px; background: #faf7f9; outline: none; }
.field:focus { border-color: var(--pink-soft); }
.label { font-size: 13px; color: var(--muted); margin-top: 14px; display: block; }

/* 登录/注册分段切换 */
.seg { display: flex; background: #f1e8ee; border-radius: 14px; padding: 4px; margin-top: 28px; }
.seg-item { flex: 1; text-align: center; padding: 10px 0; font-size: 15px; font-weight: 600; color: var(--muted); border-radius: 11px; cursor: pointer; transition: all .2s; }
.seg-item.on { background: #fff; color: var(--pink); box-shadow: 0 2px 8px rgba(0,0,0,.08); }

/* 登录/绑定页 */
.center-page { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 0 28px; }
.logo { text-align: center; }
.logo .heart { font-size: 64px; }
.logo h1 { font-size: 30px; margin: 10px 0 4px; color: var(--pink); letter-spacing: 2px; }
.logo p { color: var(--muted); font-size: 14px; margin: 0; }

/* 日历 */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 12px; }
.cal-grid .d { aspect-ratio: 1; border-radius: 10px; background: #faf7f9; display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--text); cursor: pointer; overflow: hidden; padding: 4px; text-align: center; line-height: 1.2; }
.cal-grid .d.has { background: #ffe6ec; color: var(--pink); font-weight: 700; }
.cal-head { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; }
.cal-head .m { font-weight: 700; }

/* 表情选择 */
.emoji-row { display: flex; gap: 14px; justify-content: center; margin: 14px 0; }
.emoji-row span { font-size: 34px; cursor: pointer; filter: grayscale(0.4); }
.emoji-row span.on { filter: none; transform: scale(1.2); }

/* Modal */
#modal { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: none; align-items: center; justify-content: center; z-index: 50; padding: 24px; }
#modal.show { display: flex; }
.sheet { background: #fff; border-radius: 24px; padding: 22px; width: 100%; max-width: 340px; animation: pop .2s ease; }
@keyframes pop { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.sheet h3 { margin: 0 0 6px; }
.sheet .desc { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.sheet .actions { display: flex; gap: 10px; margin-top: 16px; }

/* Toast */
#toast { position: fixed; left: 50%; bottom: 120px; transform: translateX(-50%); background: rgba(44,39,48,0.92); color: #fff; padding: 10px 18px; border-radius: 20px; font-size: 13px; opacity: 0; transition: .25s; z-index: 99; pointer-events: none; max-width: 80%; text-align: center; }
#toast.show { opacity: 1; }

/* 想你弹窗动画 */
.miss-pop { position: fixed; left: 50%; top: 40%; transform: translate(-50%,-50%) scale(0.5); font-size: 70px; z-index: 80; opacity: 0; pointer-events: none; }
.miss-pop.play { animation: miss 1.6s ease forwards; }
@keyframes miss { 0% { opacity: 0; transform: translate(-50%,-50%) scale(0.4); } 30% { opacity: 1; transform: translate(-50%,-50%) scale(1.1); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%,-90%) scale(1); } }

.empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 13px; }
.empty .e { font-size: 40px; opacity: 0.5; }

.toggle { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--line); }
.switch { width: 46px; height: 26px; border-radius: 20px; background: #d8d2d6; position: relative; transition: .2s; cursor: pointer; }
.switch.on { background: var(--pink); }
.switch::after { content: ''; position: absolute; width: 20px; height: 20px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: .2s; }
.switch.on::after { left: 23px; }

.pill-tabs { display: flex; gap: 8px; margin-top: 14px; }
.pill { padding: 7px 14px; border-radius: 20px; background: #f4f0f2; color: var(--muted); font-size: 13px; cursor: pointer; }
.pill.on { background: var(--grad); color: #fff; }

/* 聊天 */
.chat-wrap { display: flex; flex-direction: column; height: calc(100% - 8px); margin: 0 -16px; }
.chat-list { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); }
.chat-list::-webkit-scrollbar { width: 0; }
.bubble { max-width: 76%; padding: 9px 13px; border-radius: 18px; font-size: 15px; line-height: 1.5; word-break: break-word; position: relative; box-shadow: var(--shadow); }
.bubble.mine { align-self: flex-end; background: var(--grad); color: #fff; border-bottom-right-radius: 5px; }
.bubble.theirs { align-self: flex-start; background: #fff; color: var(--text); border-bottom-left-radius: 5px; }
.bubble .ts { font-size: 10px; opacity: 0.65; margin-top: 4px; text-align: right; }
.bubble .chat-media { max-width: 180px; max-height: 260px; border-radius: 12px; display: block; cursor: pointer; }
.bubble .chat-media[controls] { max-width: 200px; }
.chat-input { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 10px 12px calc(10px + var(--safe-b)); background: #fff; border-top: 1px solid var(--line); }
.chat-input .field { flex: 1; margin: 0; padding: 10px 12px; }
.chat-ico { font-size: 22px; cursor: pointer; line-height: 1; user-select: none; }
.chat-send { flex: 0 0 auto; padding: 10px 16px; margin: 0; }

/* 共享位置 */
#map { width: 100%; background: #e9e3e6; }
#map img { max-width: none; }   /* 修正 Leaflet 图标被全局规则压缩 */
.loc-cards { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.loc-card { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 16px; padding: 12px 14px; box-shadow: var(--shadow); }
.loc-ic { font-size: 22px; flex: 0 0 auto; }
.loc-main { flex: 1; min-width: 0; }
.loc-name { font-weight: 700; font-size: 15px; }
.loc-co { font-size: 12px; color: var(--muted); margin-top: 2px; word-break: break-all; }
.loc-ts { font-size: 11px; color: var(--muted); margin-top: 2px; }
.loc-dist { text-align: center; margin-top: 12px; font-size: 14px; color: var(--text); }
.loc-dist b { color: var(--pink); font-size: 18px; }

/* 下次见面倒计时 */
.meet-target { text-align: center; font-size: 13px; color: var(--muted); margin-top: 8px; }
.meet-count { display: flex; gap: 8px; justify-content: center; margin-top: 16px; }
.meet-box { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 6px; flex: 1; text-align: center; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 5px; }
.meet-box b { font-size: 26px; color: var(--pink); font-variant-numeric: tabular-nums; line-height: 1; }
.meet-box span { font-size: 11px; color: var(--muted); }
.meet-past { text-align: center; font-size: 20px; font-weight: 800; color: var(--pink); padding: 24px 0; }
