/* 国潮清新绿 UI */
:root {
  --g-deep: #2F7D5B;
  --g-main: #2F9E6E;
  --g-light: #EAF5EE;
  --bg: #F4F8F2;
  --gold: #C9A86A;
  --seal: #C0392B;
  --ink: #2B3A31;
  --muted: #8AA094;
  --glass: rgba(255, 255, 255, .88);
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body { font-family: "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--ink); overflow: hidden; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }
.small { font-size: 11px; }

/* ---- 登录门 ---- */
.gate { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; }
.gate-bg { position: absolute; inset: 0; background: linear-gradient(160deg, #2F7D5B, #1E5C41 55%, #143F2D); }
.gate-bg::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 80% 15%, rgba(201,168,106,.25), transparent 40%); }
.gate-card { position: relative; width: 86%; max-width: 380px; background: rgba(255,255,255,.97); border-radius: 20px; padding: 34px 26px 26px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.gate-seal { width: 62px; height: 62px; margin: 0 auto 12px; background: var(--seal); color: #fff; font-size: 34px; font-weight: 700; line-height: 62px; border-radius: 12px; box-shadow: inset 0 0 0 2px rgba(255,255,255,.4); }
.gate-card h1 { font-size: 24px; letter-spacing: 4px; color: var(--g-deep); }
.gate-sub { color: var(--muted); font-size: 13px; margin: 6px 0 22px; }
.wx-btn { display: flex; align-items: center; justify-content: center; gap: 8px; background: #2AAE67; color: #fff; font-size: 16px; font-weight: 600; padding: 13px; border-radius: 999px; cursor: pointer; }
.wx-btn:active { opacity: .85; }
.wx-btn.green { background: #2AAE67; margin-bottom: 12px; }
.nick-input { width: 100%; margin-top: 14px; padding: 11px 14px; border: 1px solid #D8E5DC; border-radius: 10px; font-size: 14px; outline: none; }
.login-tip { margin-top: 12px; font-size: 11px; color: var(--muted); line-height: 1.6; }
.privacy { text-align: left; }
.privacy h3 { color: var(--g-deep); margin-bottom: 8px; }
.privacy ul { font-size: 12px; color: #57685e; line-height: 1.8; padding-left: 16px; max-height: 200px; overflow-y: auto; }
.agree { display: block; font-size: 12px; margin: 12px 0; color: #57685e; }

/* ---- 按钮 ---- */
.btn { border: none; border-radius: 999px; padding: 10px 20px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn:disabled { opacity: .4; }
.btn.primary { background: var(--g-main); color: #fff; }
.btn.green { background: #2AAE67; color: #fff; }
.btn.warn { background: var(--seal); color: #fff; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid #D8E5DC; }
.btn.big { padding: 13px 34px; font-size: 16px; }
.btn.wide { width: 100%; margin-top: 10px; }

/* ---- 主框架 ---- */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar { height: 50px; background: var(--g-deep); color: #fff; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: 1px; }
.seal { width: 26px; height: 26px; background: var(--seal); border-radius: 6px; font-size: 15px; line-height: 26px; text-align: center; box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.4); }
.top-right { font-size: 12px; opacity: .85; }

.page { flex: 1; display: none; position: relative; overflow: hidden; }
.page.active { display: block; }
.scroll-body { height: 100%; overflow-y: auto; padding: 12px 12px 20px; }

/* ---- 首页地图 ---- */
#map { position: absolute; inset: 0; }
#map .leaflet-tile-pane { filter: saturate(.82) brightness(1.04); }
.map-stats { position: absolute; top: 10px; left: 10px; right: 10px; z-index: 900; display: flex; justify-content: space-around; }
.glass { background: var(--glass); backdrop-filter: blur(8px); border-radius: 14px; box-shadow: 0 4px 16px rgba(30,80,55,.12); }
.ms-item { text-align: center; padding: 8px 4px; flex: 1; }
.ms-item b { display: block; font-size: 16px; color: var(--g-deep); }
.ms-item span { font-size: 10px; color: var(--muted); }
.rank-strip { position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 900; padding: 10px 14px; max-height: 150px; overflow-y: auto; }
.strip-title { font-size: 13px; font-weight: 700; color: var(--g-deep); margin-bottom: 6px; }
.rank-list { list-style: none; font-size: 12px; }
.rank-list li { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px dashed #E2EEE6; }
.rank-list li:last-child { border-bottom: none; }
.rank-no { width: 20px; text-align: center; font-weight: 700; color: var(--gold); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.rank-name { flex: 1; }
.rank-val { color: var(--g-deep); font-weight: 600; }

/* ---- 跑步 ---- */
#runMap { position: absolute; inset: 0; }
#runMap .leaflet-tile-pane { filter: saturate(.82) brightness(1.04); }
.run-panel { position: absolute; left: 10px; right: 10px; bottom: 14px; z-index: 900; padding: 14px; }
.run-stats { display: flex; justify-content: space-around; margin-bottom: 8px; }
.rs { text-align: center; }
.rs b { display: block; font-size: 26px; font-variant-numeric: tabular-nums; color: var(--g-deep); }
.rs span { font-size: 11px; color: var(--muted); }
.run-status { text-align: center; font-size: 12px; color: var(--muted); margin-bottom: 10px; min-height: 18px; }
.run-status.hot { color: var(--seal); font-weight: 700; }
.run-diag { background: #F3F7F4; border: 1px solid #E2EEE6; border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; font-size: 11px; color: #4A5D52; }
.run-diag div { display: flex; gap: 8px; line-height: 1.7; }
.run-diag b { flex: 0 0 62px; color: var(--g-deep); font-weight: 600; }
.run-diag span { flex: 1; word-break: break-all; }
.run-btns { display: flex; justify-content: center; gap: 10px; }

/* ---- 蓝牙设备 ---- */
.ble-box { margin-top: 12px; border-top: 1px dashed #DCE9E0; padding-top: 10px; }
.ble-head { display: flex; align-items: center; justify-content: space-between; }
.ble-title { font-size: 13px; font-weight: 700; color: var(--g-deep); }
.ble-btns { display: flex; gap: 6px; }
.btn.blue { background: #2F6FB0; color: #fff; }
.btn.sm { padding: 6px 12px; font-size: 12px; }
.ble-data { display: flex; gap: 8px; margin-top: 9px; }
.bd { flex: 1; text-align: center; background: var(--g-light); border-radius: 10px; padding: 7px 2px; }
.bd b { display: block; font-size: 18px; color: var(--g-deep); font-variant-numeric: tabular-nums; }
.bd span { font-size: 10px; color: var(--muted); }
.bd.on { background: linear-gradient(135deg, var(--g-deep), var(--g-main)); }
.bd.on b, .bd.on span { color: #fff; }
.ble-note { font-size: 10.5px; color: var(--muted); line-height: 1.55; margin-top: 7px; }
.ble-tools { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.ble-switch { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.ble-src { font-size: 10px; color: #2F6FB0; background: #EAF3FB; border-radius: 6px; padding: 1px 6px; }

/* ---- 语音播报 ---- */
.voice-box { margin-top: 10px; border-top: 1px dashed #DCE9E0; padding-top: 10px; }
.voice-head { display: flex; align-items: center; justify-content: space-between; }
.mini-select { font-size: 12px; padding: 5px 6px; border: 1px solid #D8E5DC; border-radius: 8px; background: #fff; color: var(--ink); outline: none; }
.voice-box input[type=checkbox] { accent-color: var(--g-main); width: 15px; height: 15px; }
#bleChartWrap { margin: 8px 0; }
#bleChart { width: 100%; border-radius: 10px; background: #fff; border: 1px solid #E2EEE6; }

/* ---- 通用卡片 ---- */
.card { background: #fff; border-radius: 16px; padding: 14px 16px; margin-bottom: 12px; box-shadow: 0 3px 12px rgba(30,80,55,.08); }
.card h3 { font-size: 15px; color: var(--g-deep); margin-bottom: 8px; }
.team-form { display: flex; gap: 8px; margin-top: 10px; }
.team-form input { flex: 1; padding: 9px 12px; border: 1px solid #D8E5DC; border-radius: 10px; font-size: 13px; outline: none; }
.team-form .btn { flex-shrink: 0; padding: 9px 18px; }
#myTeamBox { margin-top: 12px; border-top: 1px dashed #E2EEE6; padding-top: 10px; }
.team-name { font-weight: 700; color: var(--g-deep); }
.team-code { display: inline-block; background: var(--g-light); color: var(--g-deep); padding: 2px 10px; border-radius: 8px; font-size: 12px; margin-left: 8px; }

/* ---- 个人中心 ---- */
.me-card { background: linear-gradient(135deg, var(--g-deep), var(--g-main)); color: #fff; }
.me-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.avatar { width: 54px; height: 54px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; color: #fff; border: 3px solid rgba(255,255,255,.6); }
.me-name { font-size: 18px; font-weight: 700; }
.me-card .muted { color: rgba(255,255,255,.75); }
.me-stats { display: flex; justify-content: space-around; }
.me-stats div { text-align: center; }
.me-stats b { display: block; font-size: 20px; }
.me-stats span { font-size: 11px; color: rgba(255,255,255,.75); }
.terr-list { list-style: none; font-size: 13px; }
.terr-list li { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px dashed #E2EEE6; }
.badge-wall { display: flex; flex-wrap: wrap; gap: 10px; }
.badge { width: 74px; text-align: center; font-size: 11px; color: var(--muted); }
.badge .b-ico { width: 52px; height: 52px; margin: 0 auto 4px; border-radius: 50%; background: #EDF2EE; line-height: 52px; font-size: 24px; filter: grayscale(1); opacity: .45; }
.badge.on .b-ico { background: linear-gradient(135deg, var(--gold), #E8CF9E); filter: none; opacity: 1; box-shadow: 0 4px 10px rgba(201,168,106,.4); }
.badge.on { color: var(--ink); font-weight: 600; }
.track-list { list-style: none; font-size: 13px; }
.track-list li { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed #E2EEE6; }
.track-play { background: var(--g-light); color: var(--g-deep); border: none; border-radius: 999px; padding: 5px 12px; font-size: 12px; cursor: pointer; }
.ble-tag { background: #EAF3FB; color: #2F6FB0; border-radius: 6px; padding: 1px 6px; font-size: 11px; }

/* ---- 底部导航 ---- */
.tabbar { height: 58px; background: #fff; display: flex; border-top: 1px solid #E2EEE6; flex-shrink: 0; padding-bottom: env(safe-area-inset-bottom); }
.tab { flex: 1; border: none; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: 10px; cursor: pointer; }
.tab.active { color: var(--g-main); font-weight: 700; }

/* ---- 弹窗 ---- */
.modal { position: fixed; inset: 0; z-index: 1500; background: rgba(20,40,30,.6); display: flex; align-items: center; justify-content: center; }
.modal-card { background: #fff; border-radius: 18px; padding: 18px; width: 88%; max-width: 360px; max-height: 88vh; overflow-y: auto; text-align: center; }
.modal-card h3 { color: var(--g-deep); margin-bottom: 12px; }
#shareCanvas { width: 100%; border-radius: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.15); margin-bottom: 10px; }
.modal-card .btn { margin: 4px; }
.replay-card { max-width: 400px; }
#replayMap { height: 260px; border-radius: 12px; margin-bottom: 10px; }
.replay-ctrl { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.replay-ctrl input[type=range] { flex: 1; }

/* ---- Toast ---- */
.toast { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 3000; background: rgba(30,60,45,.92); color: #fff; font-size: 13px; padding: 10px 20px; border-radius: 999px; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 80%; text-align: center; }

/* ---- 调试模拟 ---- */
.debug-chip { background: rgba(255,255,255,.18); color: #fff; border: 1px solid rgba(255,255,255,.5); border-radius: 999px; padding: 3px 10px; font-size: 11px; margin-right: 8px; cursor: pointer; }
.sim-banner { background: #FFF3CD; color: #8A6D1E; font-size: 12px; text-align: center; padding: 6px 10px; flex-shrink: 0; border-bottom: 1px solid #F0D98A; }
.debug-panel { position: absolute; top: 10px; left: 10px; right: 10px; z-index: 900; padding: 12px 14px; }
.dbg-title { font-size: 13px; font-weight: 700; color: var(--g-deep); margin-bottom: 4px; }
.dbg-row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.dbg-row .btn { flex: 1; min-width: 90px; padding: 8px 6px; font-size: 12px; }
#dbgHint { margin-top: 8px; line-height: 1.5; font-size: 11px; }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }

/* 地图地盘标签 */
.terr-label { background: rgba(255,255,255,.92); border: none; border-radius: 8px; font-size: 11px; font-weight: 700; padding: 2px 8px; box-shadow: 0 2px 8px rgba(0,0,0,.15); color: #333; white-space: nowrap; }
.landmark-icon { text-align: center; font-size: 20px; }
