/* ===== tokens（spec §4，勿改名） ===== */
:root {
  --bg: #F3F5F7;
  --glass: rgba(255,255,255,.62);
  --glass-stroke: rgba(255,255,255,.85);
  --card: #FFFFFF;
  --blue: #3B82F6;
  --mint: #34D399;
  --ink: #1E293B;
  --ink-2: #64748B;
  --shadow-soft: 0 12px 40px rgba(15,23,42,.10), 0 2px 8px rgba(15,23,42,.06);
  --shadow-float: 0 18px 50px rgba(15,23,42,.14), 0 4px 12px rgba(15,23,42,.08);
  --inset: 12px;
  --radius-stage: 26px;
  --radius-card: 20px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.5 -apple-system, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
}

/* ===== 舞台与外框（spec §4：纯视觉边界，禁硬件仿真） ===== */
.stage {
  position: fixed; inset: var(--inset);
  border-radius: var(--radius-stage);
  overflow: hidden;
  background: #E8EDF1;
  border: 1px solid rgba(15,23,42,.12);   /* no-JS 回退线框 */
  box-shadow: var(--shadow-soft);
}
.stage.frame-ready { border-color: transparent; } /* JS 弧线 SVG 接管 */
#frame {
  position: fixed; inset: var(--inset);
  width: calc(100% - 2 * var(--inset));
  height: calc(100% - 2 * var(--inset));
  pointer-events: none; z-index: 900;
  filter: drop-shadow(0 24px 60px rgba(15,23,42,.10));
}
#frame path { fill: none; stroke: rgba(15,23,42,.30); stroke-width: 1.5; }

#map { position: absolute; inset: 0; background: #E8EDF1; }
.leaflet-container { font: inherit; background: #E8EDF1; }
.leaflet-control-attribution {
  background: rgba(255,255,255,.55) !important;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  font-size: 9px; color: var(--ink-2);
  border-radius: 8px 0 0 0; padding: 1px 6px;
}
.leaflet-control-attribution a { color: var(--ink-2); }

/* ===== 玻璃通用 ===== */
.glass {
  background: var(--glass);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--glass-stroke);
  box-shadow: var(--shadow-soft);
}

/* ===== 顶部状态胶囊（spec §5.1） ===== */
.capsule {
  position: absolute; top: calc(14px + env(safe-area-inset-top, 0px));
  left: 50%; transform: translateX(-50%);
  z-index: 500; display: flex; align-items: center; gap: 10px;
  padding: 8px 16px 8px 8px; border-radius: 999px;
  max-width: calc(100% - 88px);
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; object-fit: cover;
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(15,23,42,.18); flex: none;
}
.avatar-fallback {
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--mint));
}
.battery {
  font-size: 12px; font-weight: 600; flex: none;
  background: rgba(52,211,153,.15); border: 1px solid rgba(52,211,153,.4);
  padding: 2px 8px; border-radius: 999px;
}
.status { display: flex; flex-direction: column; min-width: 0; }
.status strong { font-size: 13px; line-height: 1.3; white-space: nowrap; }
.status small { font-size: 11px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== 右侧控制列（spec §5.2） ===== */
.controls {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  z-index: 500; display: flex; flex-direction: column; gap: 10px;
}
.ctl {
  width: 42px; height: 42px; border-radius: 999px;
  border: 1px solid var(--glass-stroke);
  background: rgba(255,255,255,.75);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--ink); cursor: pointer; padding: 0;
}
button.ctl { font: inherit; }
.ctl:active { transform: scale(.94); }
.ctl-static { cursor: default; }

/* ===== 底部抽屉（spec §5.4） ===== */
.sheet {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  z-index: 500; width: min(calc(100% - 20px), 480px);
  background: var(--card); border-radius: var(--radius-card);
  box-shadow: var(--shadow-float); padding: 14px 16px;
}
.sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.stat-num { display: block; font-size: 17px; font-weight: 700; }
.stat-num small { font-size: 12px; font-weight: 600; }
.stat-cap { display: block; font-size: 11px; color: var(--ink-2); margin-top: 2px; }
.stat-mood { grid-column: 1 / -1; border-top: 1px dashed #E2E8F0; padding-top: 10px; }

/* ===== 标点与西蒙点（spec §5.3） ===== */
.pin {
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(255,255,255,.92); border: 2px solid var(--mint);
  box-shadow: 0 6px 16px rgba(15,23,42,.18);
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.pin-sq { border-radius: 14px; border-color: #94A3B8; }
.simon { position: relative; width: 56px; height: 56px; }
.simon .ring {
  position: absolute; inset: 0; border-radius: 50%;
  background: rgba(59,130,246,.35);
  animation: pulse 2.2s ease-out infinite;
}
.simon img {
  position: absolute; inset: 6px; width: 44px; height: 44px;
  border-radius: 50%; object-fit: cover;
  border: 2.5px solid #fff; box-shadow: 0 4px 12px rgba(15,23,42,.25);
}
@keyframes pulse {
  0% { transform: scale(.6); opacity: .9; }
  70% { transform: scale(1.5); opacity: 0; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* ===== 玻璃气泡（Leaflet popup 覆写，spec §5.3） ===== */
.leaflet-popup-content-wrapper {
  background: var(--glass);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--glass-stroke);
  border-radius: 14px; box-shadow: var(--shadow-soft); color: var(--ink);
}
.leaflet-popup-content { margin: 10px 14px; font-size: 12px; line-height: 1.5; }
.leaflet-popup-tip { background: rgba(255,255,255,.62); }
.leaflet-popup-close-button { color: var(--ink-2) !important; }

/* ===== 提示 / 骨架 / noscript（spec §10） ===== */
#tile-toast {
  position: absolute; top: 66px; left: 50%; transform: translateX(-50%);
  z-index: 600; border-radius: 999px; padding: 6px 14px;
  font-size: 12px; color: var(--ink-2);
}
#skeleton {
  position: absolute; inset: 0; z-index: 950;
  background: linear-gradient(110deg, #EEF2F5 30%, #F7FAFC 45%, #EEF2F5 60%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.noscript { position: fixed; left: 0; right: 0; bottom: 20px; text-align: center; color: var(--ink-2); }

@supports (padding: env(safe-area-inset-top, 0px)) {
  .capsule { max-width: calc(100% - 76px); }
}

/* ===== 三端断点（spec §3） ===== */
@media (min-width: 768px) {
  .capsule { padding: 10px 20px 10px 10px; }
  .sheet { width: 560px; }
}
@media (min-width: 1280px) {
  :root { --inset: 16px; }
  .capsule { top: 20px; }
  .controls { right: 20px; }
  .sheet { left: 28px; transform: none; bottom: 28px; width: 380px; }
}

#tile-toast.glass { border-radius: 999px; }
