/* ============ 汪汪星球 · 设计系统 v2 ============
   原则: 克制配色、地图为核心画布、细线分层、克制动效
   颜色: 墨蓝 #14182A / 琥珀 #F59E0B / 线 #ECEDF2 / 底 #F6F7F9
   图标: Lucide(stroke 继承当前色)  动效: 250ms ease */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --ink: #14182A;
  --ink-2: #5A6072;
  --muted: #9BA1B1;
  --amber: #F59E0B;
  --amber-soft: #FFF4E0;
  --line: #ECEDF2;
  --bg: #F6F7F9;
  --card: #FFFFFF;
  --danger: #E5484D;
  --ok: #2F9E44;
  --r-sm: 10px; --r-md: 14px; --r-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.05), 0 2px 8px rgba(16,24,40,.05);
  --shadow-md: 0 4px 20px rgba(16,24,40,.08);
}
html, body { height: 100%; font-family: -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif; background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
button { font-family: inherit; cursor: pointer; }
svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- 动画 ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulseDot { 0% { box-shadow: 0 0 0 0 rgba(47,158,68,.45); } 70% { box-shadow: 0 0 0 8px rgba(47,158,68,0); } 100% { box-shadow: 0 0 0 0 rgba(47,158,68,0); } }
@keyframes spin { to { transform: rotate(360deg); } }
.page { animation: fadeUp .28s ease; }
.modal { animation: fadeIn .18s ease; }
.modal-box { animation: fadeUp .22s ease; }

/* ---------- 登录 ---------- */
#auth-view { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--bg); padding: 24px; }
.auth-brand { font-size: 30px; font-weight: 800; color: var(--ink); }
.auth-sub { font-size: 13px; color: var(--muted); margin: 6px 0 26px; }
.auth-box { background: var(--card); border-radius: var(--r-lg); padding: 28px 26px; width: 100%; max-width: 380px; box-shadow: var(--shadow-md); border: 1px solid var(--line); }
.auth-tabs { display: flex; margin-bottom: 20px; background: var(--bg); border-radius: var(--r-sm); padding: 3px; }
.auth-tab { flex: 1; background: none; border: none; padding: 9px; font-size: 14px; color: var(--ink-2); border-radius: 8px; transition: all .2s; }
.auth-tab.active { background: var(--card); color: var(--ink); font-weight: 700; box-shadow: var(--shadow-sm); }
.auth-field { margin-bottom: 14px; }
.auth-field label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; font-weight: 600; }
.auth-input { width: 100%; padding: 11px 13px; border: 1.5px solid var(--line); border-radius: var(--r-sm); font-size: 14px; outline: none; background: var(--bg); transition: border .2s, background .2s; }
.auth-input:focus { border-color: var(--amber); background: #fff; }
.auth-btn { width: 100%; background: var(--ink); color: #fff; border: none; border-radius: var(--r-sm); padding: 12px; font-size: 15px; font-weight: 700; transition: transform .12s, background .2s; }
.auth-btn:hover { background: #2A2F45; }
.auth-btn:active { transform: scale(.98); }
.auth-btn.small { width: auto; padding: 10px 18px; }
.ghost-btn { width: 100%; background: var(--bg); color: var(--ink-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 11px; font-size: 14px; margin-top: 8px; transition: background .2s; }
.ghost-btn:hover { background: #EDEEF3; }
.auth-err { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 18px; text-align: center; }

/* ---------- 主框架: 左侧菜单 ---------- */
#main-view { height: 100vh; display: flex; }
.side { width: 230px; min-width: 230px; background: var(--card); border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 10; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 22px 20px 18px; font-size: 17px; font-weight: 800; }
.brand-dot { font-size: 22px; }
.side-nav { flex: 1; padding: 6px 10px; }
.side-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 14px; margin-bottom: 4px; border: none; background: none; border-radius: var(--r-sm); font-size: 14px; color: var(--ink-2); font-weight: 600; transition: background .18s, color .18s, transform .12s; }
.side-item .side-ic { display: inline-flex; width: 22px; height: 22px; align-items: center; justify-content: center; color: var(--muted); transition: color .18s; }
.side-item:hover { background: var(--bg); color: var(--ink); }
.side-item:active { transform: scale(.97); }
.side-item.active { background: var(--amber-soft); color: #8A5A00; }
.side-item.active .side-ic { color: var(--amber); }
.side-user { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--line); }
.side-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--amber-soft); display: flex; align-items: center; justify-content: center; font-size: 19px; }
.side-avatar.big { width: 56px; height: 56px; font-size: 27px; }
.side-user-info { flex: 1; min-width: 0; }
.side-user-info b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-info span { font-size: 11px; color: var(--muted); }
.side-exit { background: none; border: none; color: var(--muted); padding: 6px; border-radius: 8px; transition: all .18s; }
.side-exit:hover { color: var(--danger); background: #FDECEC; }

.content { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.content-top { display: flex; align-items: baseline; gap: 12px; padding: 20px 26px 14px; }
.content-top h1 { font-size: 20px; font-weight: 800; }
.content-hint { font-size: 12px; color: var(--muted); }
.page { flex: 1; overflow-y: auto; display: flex; flex-direction: column; padding: 0 26px 24px; }

/* ---------- 位置页 ---------- */
.loc-toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.pet-select { padding: 10px 12px; border: 1.5px solid var(--line); border-radius: var(--r-sm); font-size: 14px; background: var(--card); outline: none; min-width: 200px; }
.pet-status { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.map-shell { position: relative; flex: 1; min-height: 320px; border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-sm); border: 1px solid var(--line); }
#map { width: 100%; height: 100%; }
.map-legend { position: absolute; bottom: 14px; left: 14px; background: rgba(255,255,255,.92); backdrop-filter: blur(6px); border-radius: 999px; padding: 6px 14px; font-size: 12px; color: var(--ink-2); display: flex; align-items: center; gap: 7px; box-shadow: var(--shadow-sm); z-index: 500; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; }
.legend-dot.live { animation: pulseDot 2s infinite; }
.pet-info { margin-top: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px; font-size: 13px; color: var(--ink-2); line-height: 1.9; box-shadow: var(--shadow-sm); }

/* ---------- 朋友圈 ---------- */
.feed-list { display: flex; flex-direction: column; gap: 14px; max-width: 640px; }
.post-item { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; box-shadow: var(--shadow-sm); transition: box-shadow .2s, transform .2s; animation: fadeUp .3s ease; }
.post-item:hover { box-shadow: var(--shadow-md); }
.post-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.post-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--amber-soft); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.post-nick { font-weight: 700; font-size: 14px; }
.post-time { font-size: 11px; color: var(--muted); }
.post-content { font-size: 14px; line-height: 1.75; margin-bottom: 10px; white-space: pre-wrap; }
.post-img { width: 100%; max-height: 320px; object-fit: cover; border-radius: var(--r-md); }
.post-del { background: none; border: none; color: var(--muted); font-size: 12px; cursor: pointer; margin-left: auto; padding: 4px 8px; border-radius: 6px; transition: all .15s; }
.post-del:hover { color: var(--danger); background: #FDECEC; }
.post-actions { display: flex; gap: 8px; margin-top: 6px; }
.post-act { display: inline-flex; align-items: center; gap: 6px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 13px; color: var(--ink-2); transition: all .18s; }
.post-act:hover { transform: translateY(-1px); }
.post-act.liked { background: #FDECEC; color: var(--danger); border-color: #F5C2C4; }
.post-act svg { width: 15px; height: 15px; }
.post-comments { margin-top: 12px; background: var(--bg); border-radius: var(--r-md); padding: 12px; }
.cmt-item { font-size: 13px; color: var(--ink-2); padding: 3px 0; }
.cmt-item b { color: var(--ink); }
.cmt-empty { font-size: 12px; color: var(--muted); }
.cmt-input-row { display: flex; gap: 8px; margin-top: 8px; }
.cmt-input { flex: 1; border: 1.5px solid var(--line); border-radius: 999px; padding: 8px 14px; font-size: 13px; outline: none; background: #fff; }
.cmt-send { background: var(--ink); color: #fff; border: none; border-radius: 999px; padding: 8px 16px; font-size: 13px; font-weight: 600; transition: background .2s; }
.fab { position: fixed; right: 26px; bottom: 28px; background: var(--ink); color: #fff; border: none; border-radius: 999px; padding: 13px 22px; font-size: 14px; font-weight: 700; display: inline-flex; align-items: center; gap: 8px; box-shadow: var(--shadow-md); transition: transform .15s, background .2s; z-index: 800; }
.fab:hover { transform: translateY(-2px); background: #2A2F45; }
.fab svg { width: 17px; height: 17px; }

/* ---------- 交友 ---------- */
.friends-add { display: flex; gap: 10px; margin-bottom: 8px; max-width: 640px; }
.friends-add .auth-input { margin-bottom: 0; flex: 1; }
.sec-title { font-size: 12px; color: var(--muted); padding: 16px 0 8px; font-weight: 700; letter-spacing: 1px; }
.fr-item { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md); margin-bottom: 10px; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; max-width: 640px; box-shadow: var(--shadow-sm); animation: fadeUp .25s ease; }
.fr-nick { font-weight: 700; font-size: 14px; }
.fr-sub { font-size: 12px; color: var(--muted); }
.mini-btn { background: var(--ink); color: #fff; border: none; border-radius: 8px; padding: 8px 16px; font-size: 13px; font-weight: 600; transition: background .2s, transform .12s; }
.mini-btn:active { transform: scale(.96); }
.mini-btn.gray { background: var(--bg); color: var(--ink-2); }

/* ---------- 我的 ---------- */
.me-head { display: flex; align-items: center; gap: 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; margin-bottom: 8px; box-shadow: var(--shadow-sm); max-width: 640px; }
.me-head h2 { font-size: 18px; }
.me-email { font-size: 12px; color: var(--muted); }
.pet-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px; margin-bottom: 12px; display: flex; align-items: center; gap: 14px; max-width: 640px; box-shadow: var(--shadow-sm); transition: box-shadow .2s; animation: fadeUp .25s ease; }
.pet-card:hover { box-shadow: var(--shadow-md); }
.pet-avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--amber-soft); display: flex; align-items: center; justify-content: center; font-size: 24px; }
.pet-name { font-weight: 700; font-size: 15px; }
.pet-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pet-card .mini-btn { margin-left: auto; }
#tab-me .auth-btn { max-width: 640px; }

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; background: rgba(20,24,42,.5); z-index: 2000; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(3px); }
.modal-box { background: #fff; border-radius: var(--r-lg); padding: 24px; width: 90%; max-width: 400px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-md); }
.modal-box h3 { margin-bottom: 16px; font-size: 16px; }
.post-text { width: 100%; min-height: 90px; padding: 12px; border: 1.5px solid var(--line); border-radius: var(--r-sm); font-size: 14px; margin-bottom: 10px; background: var(--bg); outline: none; }
.pick-img { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 13px; padding: 8px 14px; border: 1.5px dashed var(--line); border-radius: var(--r-sm); cursor: pointer; margin-bottom: 10px; transition: border .2s; }
.pick-img:hover { border-color: var(--amber); }
.post-preview-img { width: 100%; max-height: 200px; object-fit: cover; border-radius: var(--r-md); margin-bottom: 8px; }

/* ---------- 移动端 ---------- */
.tabbar { display: none; }
@media (max-width: 820px) {
  .side { display: none; }
  #main-view { flex-direction: column; }
  .content { flex: 1; }
  .content-top { padding: 14px 16px 10px; }
  .page { padding: 0 14px 90px; }
  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: rgba(255,255,255,.95); backdrop-filter: blur(10px); border-top: 1px solid var(--line); z-index: 1000; padding-bottom: env(safe-area-inset-bottom); }
  .tabbar-btn { flex: 1; background: none; border: none; padding: 10px 0; font-size: 12px; color: var(--muted); transition: color .2s; }
  .tabbar-btn.active { color: var(--amber); font-weight: 700; }
  .fab { right: 16px; bottom: 80px; }
}
.pet-marker { width: 22px; height: 22px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.35); background: var(--amber); }
.pet-marker.live-pulse { animation: pulseDot 2s infinite; }
.empty { color: var(--muted); font-size: 13px; text-align: center; padding: 34px 0; }

/* ============ 全局 Toast 提示 ============ */
#toast-wrap{position:fixed;top:18px;left:50%;transform:translateX(-50%);z-index:99999;display:flex;flex-direction:column;gap:8px;align-items:center;pointer-events:none;max-width:92vw}
.toast{background:#1f2937;color:#fff;padding:10px 18px;border-radius:12px;font-size:14px;line-height:1.5;box-shadow:0 8px 24px rgba(0,0,0,.18);animation:toastIn .25s ease;max-width:88vw;text-align:center;word-break:break-all}
.toast-success{background:#16a34a}
.toast-error{background:#dc2626}
.toast-info{background:#1f2937}
.toast.hide{opacity:0;transform:translateY(-10px);transition:all .3s ease}
@keyframes toastIn{from{opacity:0;transform:translateY(-12px)}to{opacity:1;transform:translateY(0)}}

/* ============ 铃铛 / 通知面板 ============ */
.top-actions{display:flex;align-items:center;gap:10px;margin-left:auto}
.bell-btn{position:relative;background:none;border:none;cursor:pointer;color:#4b5563;padding:6px;border-radius:8px}
.bell-btn:hover{background:#f3f4f6}
.bell-dot{position:absolute;top:4px;right:4px;width:9px;height:9px;background:#ef4444;border-radius:50%;border:2px solid #fff}
.notif-panel{position:absolute;top:52px;right:16px;width:320px;max-width:92vw;background:#fff;border:1px solid #e5e7eb;border-radius:14px;box-shadow:0 12px 32px rgba(0,0,0,.14);z-index:90;overflow:hidden}
.notif-head{display:flex;justify-content:space-between;align-items:center;padding:12px 14px;border-bottom:1px solid #f3f4f6}
.notif-clear{background:none;border:none;color:#f59e0b;cursor:pointer;font-size:12px}
.notif-list{max-height:320px;overflow-y:auto}
.notif-item{padding:10px 14px;border-bottom:1px solid #f9fafb;cursor:pointer;font-size:13px}
.notif-item:hover{background:#f9fafb}
.notif-item.unread{background:#fefce8}
.notif-item b{color:#111827}
.notif-item .n-body{color:#6b7280;margin-top:2px}
.notif-item .n-time{color:#9ca3af;font-size:11px;margin-top:3px}

/* ============ 聊天浮窗 ============ */
.chat-wrap{position:fixed;right:18px;bottom:70px;width:320px;max-width:94vw;background:#fff;border:1px solid #e5e7eb;border-radius:14px;box-shadow:0 16px 40px rgba(0,0,0,.16);z-index:95;display:flex;flex-direction:column;overflow:hidden}
.chat-head{display:flex;justify-content:space-between;align-items:center;padding:11px 14px;background:linear-gradient(135deg,#f59e0b,#f97316);color:#fff}
.chat-close{background:none;border:none;color:#fff;font-size:16px;cursor:pointer}
.chat-body{height:300px;overflow-y:auto;padding:12px;background:#f9fafb;display:flex;flex-direction:column;gap:8px}
.chat-msg{max-width:78%;padding:8px 12px;border-radius:12px;font-size:13px;line-height:1.5;word-break:break-word}
.chat-msg.mine{align-self:flex-end;background:#f59e0b;color:#fff;border-bottom-right-radius:3px}
.chat-msg.theirs{align-self:flex-start;background:#fff;border:1px solid #e5e7eb;border-bottom-left-radius:3px}
.chat-msg .cm-time{display:block;font-size:10px;color:inherit;opacity:.7;margin-top:3px}
.chat-input-row{display:flex;gap:8px;padding:10px;border-top:1px solid #f3f4f6}
.chat-input-row .auth-input{flex:1;margin:0}

/* ============ 评价弹窗 ============ */
.modal-mask{position:fixed;inset:0;background:rgba(0,0,0,.45);z-index:120;display:flex;align-items:center;justify-content:center}
.modal-mask .modal-box{width:420px;max-width:92vw;max-height:82vh;overflow-y:auto;background:#fff;border-radius:16px;padding:20px}
.review-stats{display:flex;align-items:center;gap:10px;margin:10px 0;color:#6b7280;font-size:14px}
.review-stats .avg{font-size:26px;font-weight:800;color:#f59e0b}
.stars{font-size:30px;color:#d1d5db;cursor:pointer;user-select:none;margin:6px 0}
.stars span.on{color:#f59e0b}
.review-list{margin-top:12px;max-height:200px;overflow-y:auto}
.review-item{padding:8px 0;border-bottom:1px solid #f9fafb;font-size:13px}
.review-item .r-star{color:#f59e0b}
.review-item .r-user{font-weight:600;margin-right:6px}
.review-item .r-text{color:#4b5563;margin-top:2px}
