:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --ink: #1f2329;
  --muted: #8a909a;
  --line: #e8eaed;
  --accent: #e53935;
  --accent-soft: rgba(229, 57, 53, 0.16);
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 6px 18px rgba(0, 0, 0, 0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.title-wrap h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.subtitle {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--muted);
}
.topbar-actions { display: flex; gap: 8px; }

.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn:hover { border-color: #cfd3d9; }
.btn.ghost { color: #5a6068; }
.btn.danger { color: var(--accent); border-color: #f3c4c4; }
.btn.danger:hover { background: var(--accent-soft); }

/* Layout */
.layout {
  flex: 1;
  display: flex;
  min-height: 0;
}
.map-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
#map { width: 100%; height: 100%; }

.legend {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 500;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12px;
  color: #5a6068;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-hint { color: var(--muted); }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.demo-unlit { background: #cfd8dc; border: 2px solid #90a4ae; }
.demo-lit { background: var(--accent); border: 2px solid #b71c1c; box-shadow: 0 0 0 3px var(--accent-soft); }

/* Markers */
.park-marker { background: transparent; border: none; overflow: visible; }
.park-marker .pin {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #cfd8dc;
  border: 2px solid #8a99a3;
  transition: all 0.2s ease;
}
.park-marker.lit .pin {
  background: var(--accent);
  border-color: #b71c1c;
  box-shadow: 0 0 0 4px var(--accent-soft), 0 0 12px rgba(229, 57, 53, 0.7);
}
.park-marker .mlabel {
  position: absolute;
  left: 20px;
  top: -3px;
  white-space: nowrap;
  font-size: 11px;
  line-height: 18px;
  color: #4a5159;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  padding: 0 5px;
  border-radius: 5px;
  pointer-events: none;
}
.park-marker.lit .mlabel {
  color: #fff;
  background: var(--accent);
  border-color: #b71c1c;
  font-weight: 600;
}

/* Sidebar */
.sidebar {
  width: 320px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px;
  overflow: hidden;
}
.stats {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.stats-num {
  font-size: 26px;
  font-weight: 700;
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.stats-num .sep { color: var(--muted); font-weight: 400; }
.stats-num .unit { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 6px; }
.progress {
  margin-top: 12px;
  height: 8px;
  background: #eceef1;
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #ff7043, var(--accent));
  border-radius: 99px;
  transition: width 0.4s ease;
}
.stats-pct { margin-top: 8px; font-size: 13px; color: var(--muted); }

.list-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.tab {
  flex: 1;
  background: #f1f3f5;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 6px;
  font-size: 13px;
  font-weight: 600;
  color: #5a6068;
  cursor: pointer;
  transition: all 0.15s ease;
}
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tab-badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  margin-left: 2px;
  border-radius: 10px;
  background: rgba(0,0,0,0.12);
  font-size: 12px;
}
.tab:not(.active) .tab-badge { background: #e3e6ea; color: #5a6068; }

.park-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
/* 全部公园面板：让内部列表在面板内滚动 */
#allPanel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.list-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.filter-select {
  flex: 1;
  padding: 7px 8px;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #333;
}
.filter-check {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #5a6068;
  white-space: nowrap;
  cursor: pointer;
}
.park-list .empty {
  color: var(--muted);
  font-size: 13px;
  padding: 12px 4px;
  line-height: 1.6;
}
.list-group-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin: 12px 2px 6px;
  letter-spacing: 0.5px;
}
.aitem {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  margin-bottom: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.15s ease;
}
.aitem:hover { border-color: #cfd3d9; background: #fafbfc; }
.aitem .aname { font-size: 14px; font-weight: 500; }
.aitem.lit .aname { font-weight: 600; }
.aitem .abadge {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}
.aitem .abadge.none { color: #b8c0c8; font-weight: 400; }

.vitem {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.vitem:hover { border-color: #cfd3d9; background: #fafbfc; }
.vitem .vname { font-size: 14px; font-weight: 600; display: flex; justify-content: space-between; }
.vitem .vmeta { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.vitem .vcount { color: var(--accent); font-weight: 600; }

/* Search */
.search-box { position: relative; margin-bottom: 14px; }
.search-box input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease;
}
.search-box input:focus { border-color: var(--accent); }
.search-results {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.search-results li {
  padding: 9px 12px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.search-results li:last-child { border-bottom: none; }
.search-results li:hover { background: #fafbfc; }
.search-results li .s-cat { font-size: 11px; color: var(--muted); }
.search-results li .s-lit { color: var(--accent); font-size: 11px; font-weight: 600; }
.search-results .s-empty { padding: 10px 12px; color: var(--muted); font-size: 12px; }

/* Toggle */
.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #5a6068;
  margin-bottom: 14px;
  cursor: pointer;
  user-select: none;
}
.toggle input { width: 15px; height: 15px; accent-color: var(--accent); }

/* Popup */
.leaflet-popup-content { margin: 12px 14px; font-size: 13px; line-height: 1.7; }
.popup-date-row { margin: 6px 0; display: flex; align-items: center; gap: 6px; }
.popup-date-row input[type="date"] {
  font-size: 12px;
  padding: 3px 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
}
/* 到访日期列表 */
.visit-list { margin: 8px 0; max-height: 180px; overflow-y: auto; }
.visit-empty { color: #9aa3ab; font-size: 12px; padding: 2px 0; }
.visit-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--accent-soft);
  border-radius: 5px;
  padding: 3px 8px;
  margin: 4px 0;
  font-size: 13px;
}
.visit-date { color: #b71c1c; font-weight: 600; }
.visit-del {
  background: none;
  border: none;
  color: #b71c1c;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.visit-del:hover { opacity: 0.6; }
.popup-add {
  margin-top: 4px;
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
}
.popup-clear {
  margin-top: 8px;
  display: inline-block;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  border: 1px solid #f3c4c4;
  border-radius: 6px;
  padding: 3px 10px;
}
.popup-clear:hover { background: var(--accent-soft); }
.popup-name { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.popup-row { color: #5a6068; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1f2329;
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 1000;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 收起地图按钮（仅手机端显示）*/
.map-toggle { display: none; }
@media (max-width: 720px) {
  .layout { flex-direction: column; }
  .map-wrap { height: 35vh; min-height: 35vh; flex: none; }
  .sidebar {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--line);
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding: 12px;
  }
  .stats { margin-bottom: 10px; padding: 10px 12px; }
  .stats-num { font-size: 22px; }
  .toggle { margin-bottom: 10px; }
  .list-tabs { margin-bottom: 10px; }
  .list-filter { margin-bottom: 8px; }
  .map-toggle {
    display: block;
    position: fixed;
    right: 14px;
    bottom: 14px;
    z-index: 700;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 22px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: var(--shadow);
    cursor: pointer;
  }
  .layout.map-collapsed .map-wrap { height: 0 !important; min-height: 0 !important; }
}
