/* 循迹 · 界面样式（移动优先，深色户外风） */

:root {
  --bg: #0b1210;
  --bg-soft: #0f1a16;
  --panel: rgba(16, 27, 22, 0.92);
  --panel-solid: #121e19;
  --line: rgba(150, 190, 170, 0.16);
  --text: #e9f2ec;
  --muted: #8ea79a;
  --green: #4ade80;
  --green-deep: #16a34a;
  --amber: #fbbf24;
  --red: #ef4444;
  --radius: 18px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

body.page-map {
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
}

a { color: var(--green); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ---------- 通用控件 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn:active { transform: scale(0.975); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(180deg, #5eea8f, var(--green-deep));
  color: #04160b;
  box-shadow: 0 8px 22px rgba(34, 197, 94, 0.25);
}
.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--line);
  color: var(--text);
}
.btn-danger {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fca5a5;
}
.btn-xl { padding: 17px 26px; font-size: 17px; border-radius: 16px; flex: 1; }
.btn-mini { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; }

input, select, textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: rgba(74, 222, 128, 0.55); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }

/* ---------- 首页 ---------- */

.page-home { min-height: 100vh; overflow-y: auto; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 20px 60px; }

.site-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0 8px;
}
.brand {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.brand span {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.28em;
  color: var(--muted);
  margin-top: 2px;
}
.site-head nav { display: flex; gap: 8px; }
.site-head nav a {
  color: var(--muted);
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 10px;
}
.site-head nav a:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }

.hero { padding: 46px 0 36px; }
.hero h1 {
  font-size: clamp(30px, 7vw, 46px);
  line-height: 1.2;
  margin: 0 0 16px;
  letter-spacing: -0.01em;
}
.hero h1 em {
  font-style: normal;
  background: linear-gradient(120deg, #86efac, #22c55e);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero p { color: var(--muted); font-size: 16px; max-width: 30em; margin: 0 0 26px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.section { margin-top: 34px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section h2 { font-size: 17px; margin: 0; letter-spacing: 0.02em; }

.track-list { display: grid; gap: 12px; }

.track-card {
  display: block;
  padding: 18px;
  border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--line);
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.12s ease;
}
.track-card:hover { border-color: rgba(74, 222, 128, 0.45); transform: translateY(-1px); }
.track-card h3 { margin: 0 0 4px; font-size: 16px; font-weight: 650; }
.track-meta { color: var(--muted); font-size: 12.5px; display: flex; gap: 10px; flex-wrap: wrap; }
.track-stats { display: flex; gap: 18px; margin-top: 14px; }
.track-stats div { font-size: 12px; color: var(--muted); }
.track-stats b { display: block; font-size: 16px; color: var(--text); font-weight: 650; }

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(74, 222, 128, 0.12);
  color: #86efac;
  border: 1px solid rgba(74, 222, 128, 0.22);
}

.empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  font-size: 14px;
}

.code-form { display: flex; gap: 10px; }
.code-form input { flex: 1; }
.code-form .btn { flex: 0 0 auto; }

.foot { margin-top: 46px; color: var(--muted); font-size: 12.5px; line-height: 1.8; }
.foot code { background: rgba(255, 255, 255, 0.06); padding: 1px 6px; border-radius: 6px; }

/* ---------- 地图页 ---------- */

.map { position: absolute; inset: 0; background: var(--bg); }
.map-canvas { display: block; position: absolute; inset: 0; }
.map-attrib {
  position: absolute;
  top: calc(var(--safe-t) + 60px);
  right: 8px;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(6, 12, 9, 0.55);
  color: rgba(214, 232, 222, 0.6);
  pointer-events: auto;
}
.map-attrib a { color: rgba(214, 232, 222, 0.75); }

.map-head {
  position: absolute;
  top: calc(var(--safe-t) + 10px);
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  z-index: 5;
}

.round-btn {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}
.round-btn:active { transform: scale(0.94); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 13.5px;
  font-weight: 600;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 8px;
}
.pill.live .dot { background: var(--red); animation: blink 1.4s infinite; }
.pill.ok .dot { background: var(--green); }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* 底部面板 */
.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  padding: 20px 18px calc(18px + var(--safe-b));
  background: linear-gradient(180deg, rgba(11, 18, 16, 0.82), rgba(9, 15, 12, 0.97) 40%);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -20px 40px rgba(0, 0, 0, 0.35);
}
@media (min-width: 720px) {
  .sheet {
    left: 50%;
    transform: translateX(-50%);
    max-width: 560px;
    border-radius: 24px 24px 0 0;
    border: 1px solid var(--line);
    border-bottom: none;
  }
}

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 16px; }
.stat { text-align: center; }
.stat b {
  display: block;
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.stat span { font-size: 11px; color: var(--muted); letter-spacing: 0.04em; }

.controls { display: flex; gap: 10px; align-items: stretch; }
.controls .btn-ghost { flex: 0 0 auto; }

.hint { color: var(--muted); font-size: 12.5px; margin: 12px 2px 0; line-height: 1.6; }

/* ---------- 弹窗 / 提示 ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 8, 6, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.modal-card {
  width: 100%;
  max-width: 440px;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 24px;
  box-shadow: var(--shadow);
  max-height: 88vh;
  overflow-y: auto;
}
.modal-card h3 { margin: 0 0 16px; font-size: 19px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn { flex: 1; }

.save-summary {
  margin-top: 6px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(74, 222, 128, 0.07);
  border: 1px solid rgba(74, 222, 128, 0.18);
  font-size: 13px;
  color: #bbf7d0;
}

.share-box {
  display: flex;
  gap: 8px;
  margin: 14px 0;
}
.share-box input { font-size: 12.5px; }
.share-box .btn { flex: 0 0 auto; }

.toast {
  position: fixed;
  top: calc(var(--safe-t) + 66px);
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  max-width: min(92vw, 460px);
  padding: 12px 18px;
  border-radius: 14px;
  background: rgba(10, 18, 14, 0.95);
  border: 1px solid var(--line);
  font-size: 14px;
  line-height: 1.45;
  text-align: center;
  z-index: 30;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.warn { border-color: rgba(251, 191, 36, 0.55); color: #fde68a; }
.toast.critical { border-color: rgba(239, 68, 68, 0.6); color: #fecaca; background: rgba(40, 12, 12, 0.95); }

/* ---------- 循迹 HUD ---------- */

.hud {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 7;
  padding: 18px 18px calc(16px + var(--safe-b));
  background: linear-gradient(180deg, rgba(11, 18, 16, 0.86), rgba(8, 14, 11, 0.98) 45%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--line);
}
@media (min-width: 720px) {
  .hud {
    left: 50%;
    transform: translateX(-50%);
    max-width: 560px;
    border-radius: 24px 24px 0 0;
    border: 1px solid var(--line);
    border-bottom: none;
  }
}

.hud-status {
  font-size: 26px;
  font-weight: 750;
  letter-spacing: -0.01em;
  line-height: 1.25;
  display: flex;
  align-items: center;
  gap: 10px;
}
.hud-status::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(74, 222, 128, 0.16);
  flex: 0 0 10px;
}
.hud-status.off { color: #fde68a; }
.hud-status.off::before { background: var(--amber); box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.18); animation: blink 1.2s infinite; }
.hud-status.far { color: #fecaca; }
.hud-status.far::before { background: var(--red); box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.2); animation: blink 1s infinite; }

.hud-sub { color: var(--muted); font-size: 13px; margin-top: 6px; }

.progress {
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  margin: 16px 0 14px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #22c55e, #86efac);
  transition: width 0.4s ease;
}

.hud-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 16px; }
.hud-metrics div { text-align: center; }
.hud-metrics b { display: block; font-size: 19px; font-variant-numeric: tabular-nums; font-weight: 700; }
.hud-metrics span { font-size: 11px; color: var(--muted); }

.hud-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hud-actions .btn { padding: 11px 14px; font-size: 14px; }
.hud-actions .btn-danger { margin-left: auto; }

.mini-select {
  width: auto;
  padding: 10px 30px 10px 12px;
  font-size: 13px;
  border-radius: 12px;
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
}

.sim-panel {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}
.sim-row { display: flex; gap: 8px; flex-wrap: wrap; }
.sim-row .btn { flex: 1 1 auto; }
.sim-row .btn.on { background: rgba(74, 222, 128, 0.18); border-color: rgba(74, 222, 128, 0.5); color: #bbf7d0; }

/* ---------- 查看页 ---------- */

.view-title {
  font-size: 21px;
  font-weight: 750;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.view-meta { color: var(--muted); font-size: 12.5px; margin-bottom: 16px; }

@media (max-width: 420px) {
  .stat b { font-size: 19px; }
  .hud-status { font-size: 22px; }
  .controls .btn-ghost { padding: 12px; }
}

/* ---------- 离线 ---------- */

.head-actions { display: flex; gap: 8px; flex: 0 0 auto; }

.offline-badge {
  position: fixed;
  top: calc(var(--safe-t) + 96px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 45;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(69, 46, 8, 0.94);
  border: 1px solid rgba(251, 191, 36, 0.45);
  color: #fde68a;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: var(--shadow);
}

/* ---------- 活动参与者页 ---------- */

.event-title {
  font-size: 24px;
  font-weight: 750;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}
.event-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 18px; line-height: 1.6; }

.wx-hint {
  position: absolute;
  top: calc(var(--safe-t) + 64px);
  left: 12px;
  right: 12px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(69, 46, 8, 0.94);
  border: 1px solid rgba(251, 191, 36, 0.45);
  color: #fde68a;
  font-size: 12.5px;
  box-shadow: var(--shadow);
}
.wx-hint b { color: #fff7d6; font-weight: 700; }

.privacy {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  margin: 4px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}

/* ---------- 领队看板 ---------- */

.sheet.dashboard {
  max-height: 58vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dash-counts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.dash-count {
  text-align: center;
  padding: 8px 4px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
}
.dash-count b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.dash-count span { font-size: 11px; color: var(--muted); }
.dash-count.warn b { color: var(--amber); }
.dash-count.lost b { color: #cbd5e1; }

.dash-list {
  flex: 1;
  min-height: 84px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  -webkit-overflow-scrolling: touch;
}

.dash-row {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  grid-template-areas:
    "dot who when"
    "dot what when";
  gap: 2px 10px;
  align-items: center;
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-align: left;
  font-family: inherit;
  cursor: pointer;
}
.dash-row:active { transform: scale(0.99); }
.dash-dot {
  grid-area: dot;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  align-self: center;
}
.dash-who { grid-area: who; font-size: 14px; font-weight: 650; }
.dash-what { grid-area: what; font-size: 12px; color: var(--muted); }
.dash-when { grid-area: when; font-size: 11px; color: var(--muted); white-space: nowrap; }

.dash-row.off { border-color: rgba(251, 191, 36, 0.4); background: rgba(251, 191, 36, 0.08); }
.dash-row.off .dash-dot { background: var(--amber); }
.dash-row.off .dash-what { color: #fde68a; }
.dash-row.lost { opacity: 0.72; }
.dash-row.lost .dash-dot { background: #94a3b8; }

.dash-tools { text-align: right; font-size: 12px; }
.dash-tools a { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- 起点海报 ---------- */

.page-poster {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 40px;
  gap: 20px;
}

.poster {
  width: 100%;
  max-width: 720px;
  background: #fff;
  color: #111;
  border-radius: 18px;
  padding: 40px 36px 32px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}
.poster-brand { font-size: 12px; letter-spacing: 0.3em; color: #15803d; font-weight: 700; }
.poster-title { font-size: clamp(26px, 6vw, 40px); margin: 10px 0 6px; letter-spacing: -0.01em; }
.poster-meta { color: #555; font-size: 15px; margin: 0 0 22px; }

.poster-qr { display: grid; place-items: center; margin: 0 auto 22px; }
.poster-qr img { width: min(72vw, 320px); height: auto; display: block; }
.poster-qr-fallback {
  max-width: 320px;
  color: #b45309;
  font-size: 14px;
  padding: 24px;
  border: 2px dashed #f59e0b;
  border-radius: 12px;
}

.poster-steps {
  text-align: left;
  max-width: 420px;
  margin: 0 auto 18px;
  padding-left: 22px;
  color: #222;
  font-size: 15px;
  line-height: 1.9;
}
.poster-steps b { color: #15803d; }
.poster-note { color: #666; font-size: 13px; margin: 0 0 10px; }
.poster-url { color: #888; font-size: 11px; word-break: break-all; margin: 0; }

.poster-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

@media print {
  @page { size: A4 portrait; margin: 14mm; }
  body.page-poster { background: #fff; padding: 0; display: block; }
  .poster { box-shadow: none; border-radius: 0; max-width: none; padding: 0; }
  .no-print { display: none !important; }
  .poster-qr img { width: 62mm; }
  .poster-title { font-size: 28pt; }
  .poster-steps { font-size: 12pt; }
}
