:root {
  --ink: #1E2A2A;
  --paper: #F6F3EC;
  --card: #FFFFFF;
  --green: #14453D;
  --gold: #C9A227;
  --crimson: #C0392B;
  --ok: #2E7D32;
  --muted: #8A8578;
  --line: #E4DFD2;
  --radius: 16px;
  --shadow: 0 8px 28px rgba(20, 40, 40, 0.18);
  --header-h: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--paper);
  overscroll-behavior: none;
}

/* ---------- header ---------- */
#app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 12px;
  background: linear-gradient(135deg, #14453D 0%, #1E5A4C 100%);
  color: #FDFBF5;
  box-shadow: 0 2px 12px rgba(0,0,0,0.18);
}
.header-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand-title { font-size: 19px; font-weight: 700; letter-spacing: 1px; }
.brand-sub { display: block; margin-top: 3px; font-size: 12px; color: rgba(253,251,245,0.72); }
.header-actions { display: flex; gap: 8px; flex-shrink: 0; }

.chip {
  border: 1px solid rgba(253,251,245,0.35);
  background: rgba(253,251,245,0.12);
  color: #FDFBF5;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.chip.active { background: var(--gold); border-color: var(--gold); color: #1E2A2A; font-weight: 600; }

.progress-wrap { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.progress-track { flex: 1; height: 8px; border-radius: 999px; background: rgba(253,251,245,0.2); overflow: hidden; }
.progress-fill { height: 100%; width: 0%; border-radius: 999px; background: linear-gradient(90deg, var(--gold), #E8C65A); transition: width 0.5s ease; }
.progress-text { font-size: 12px; color: rgba(253,251,245,0.9); font-variant-numeric: tabular-nums; }

/* ---------- map ---------- */
#map {
  position: fixed;
  top: var(--header-h);
  bottom: 0; left: 0; right: 0;
  background: #E8E4D8;
}
.leaflet-container { font-family: inherit; }

.locate-btn {
  position: fixed;
  right: 16px;
  bottom: 52vh;
  z-index: 900;
  width: 46px; height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--card);
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.locate-btn:active { transform: scale(0.95); }

/* ---------- bottom sheet ---------- */
.sheet {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  z-index: 950;
  height: 46vh;
  background: var(--card);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: height 0.25s ease;
}
.sheet.detail-mode { height: 62vh; }
.sheet-handle {
  flex: 0 0 auto;
  width: 44px; height: 5px;
  margin: 10px auto 4px;
  border-radius: 999px;
  background: var(--line);
}
#sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
  -webkit-overflow-scrolling: touch;
}

/* list mode */
.list-head { font-size: 13px; color: var(--muted); margin: 6px 2px 10px; }
.poi-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 6px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.poi-item:last-child { border-bottom: none; }
.poi-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1.5px currentColor;
}
.poi-dot.open { color: var(--crimson); background: var(--paper); }
.poi-dot.near { color: var(--gold); background: var(--gold); }
.poi-dot.checked { color: var(--ok); background: var(--ok); }
.poi-main { flex: 1; min-width: 0; }
.poi-name { font-size: 15px; font-weight: 600; display: flex; align-items: baseline; gap: 6px; }
.poi-name .badge { font-size: 11px; font-weight: 500; color: var(--muted); }
.poi-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.poi-state { text-align: right; flex-shrink: 0; }
.poi-state .st { font-size: 12px; font-weight: 600; }
.st.checked { color: var(--ok); }
.st.open { color: var(--muted); }
.st.near { color: var(--crimson); }
.poi-state .time { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* detail mode */
.detail-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.back-btn {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}
.detail-title { font-size: 18px; font-weight: 700; flex: 1; }
.detail-meta { font-size: 12px; color: var(--muted); display: flex; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.detail-meta b { color: var(--ink); font-weight: 600; }
.detail-intro { font-size: 14px; line-height: 1.75; color: #333; }
.detail-tip {
  margin-top: 12px;
  padding: 10px 12px;
  background: #FBF7EA;
  border-left: 3px solid var(--gold);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.6;
  color: #5A4A1E;
}
.checkin-btn {
  width: 100%;
  margin-top: 14px;
  padding: 14px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  color: #FDFBF5;
  background: linear-gradient(135deg, var(--crimson), #D9543F);
  box-shadow: 0 6px 16px rgba(192, 57, 43, 0.35);
}
.checkin-btn:disabled {
  background: #C9C4B6;
  box-shadow: none;
  color: #6B675C;
  cursor: not-allowed;
}
.checkin-btn.done { background: var(--ok); box-shadow: 0 6px 16px rgba(46,125,50,0.3); }

/* ---------- sim banner / toast ---------- */
.sim-banner {
  position: fixed;
  top: calc(var(--header-h) + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 960;
  background: #1E2A2A;
  color: #FDFBF5;
  font-size: 12px;
  padding: 8px 14px;
  border-radius: 999px;
  box-shadow: var(--shadow);
}
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(46vh + 24px);
  transform: translateX(-50%) translateY(8px);
  z-index: 990;
  background: rgba(30,42,42,0.95);
  color: #FDFBF5;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  max-width: 80vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.hidden { display: none !important; }

/* leaflet popup tuning */
.leaflet-popup-content-wrapper { border-radius: 12px; }
.leaflet-popup-content { margin: 12px 14px; }
