/* Shenzhen robotics & city map. Dark UI over Carto tiles. */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel2: #1c2128;
  --line: #30363d;
  --line2: #21262d;
  --fg: #e6edf3;
  --dim: #8b949e;
  --dim2: #6e7681;
  --accent: #58a6ff;
  --ok: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
}

html, body { height: 100%; }
body {
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  overflow: hidden;
}

#map { position: absolute; inset: 0; background: #0d1117; }
.leaflet-tile-pane.inverted { filter: grayscale(1) invert(0.92); }
#map.light { background: #eef2f4; }

/* ---------- generic panel chrome ---------- */
.panel {
  position: absolute;
  z-index: 1000;
  background: rgba(22, 27, 34, 0.94);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
}

/* ---------- left list ---------- */
#list-panel {
  top: 12px; left: 12px; bottom: 12px;
  width: 300px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#list-panel h1 {
  font-size: 15px; font-weight: 700; color: #f0f6fc;
  padding: 14px 14px 2px;
  display: flex; align-items: center; gap: 8px;
}
#list-panel h1 .pin-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: linear-gradient(135deg, #58a6ff, #2ea44e);
  flex: 0 0 auto;
}
#list-panel .sub { padding: 0 14px 10px; font-size: 11px; color: var(--dim2); }

#filters { padding: 4px 10px 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 11px; font-weight: 600;
  color: var(--dim);
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  cursor: pointer;
  user-select: none;
  transition: all .15s;
  display: inline-flex; align-items: center; gap: 5px;
}
.chip .n { font-weight: 500; color: var(--dim2); font-size: 10px; }
.chip:hover { color: var(--fg); border-color: #484f58; }
.chip.on { color: #fff; border-color: transparent; }
.chip.on[data-cat="robotics"] { background: #1f6feb; }
.chip.on[data-cat="tourist"]  { background: #238636; }
.chip.on[data-cat="transport"]{ background: #9e6a03; }
.chip.on[data-cat="nemo"]     { background: #bc4c00; }
.chip.on[data-cat="all"]      { background: #484f58; }

#poi-list { flex: 1; overflow-y: auto; padding: 0 8px 10px; }
#poi-list::-webkit-scrollbar { width: 8px; }
#poi-list::-webkit-scrollbar-thumb { background: #30363d; border-radius: 4px; }
.group-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--dim2);
  padding: 12px 8px 4px;
}
.row {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px; border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
}
.row:hover { background: var(--panel2); border-color: var(--line2); }
.row .mini {
  width: 26px; height: 26px; border-radius: 50%;
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  background: #fff;
  border: 2px solid var(--line);
}
.row .mini img { width: 100%; height: 100%; object-fit: contain; }
.row .mini svg { width: 15px; height: 15px; }
.row .names { min-width: 0; }
.row .nm { font-size: 12.5px; font-weight: 600; color: #e6edf3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .zh { font-size: 10.5px; color: var(--dim2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- top-right controls ---------- */
#controls { top: 12px; right: 12px; display: flex; gap: 8px; z-index: 1000; position: absolute; }
.ctl-btn {
  background: rgba(22, 27, 34, 0.94);
  border: 1px solid var(--line);
  color: var(--fg);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12.5px; font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  backdrop-filter: blur(6px);
}
.ctl-btn:hover { background: var(--panel2); border-color: #484f58; }
.ctl-btn.on { border-color: var(--accent); color: var(--accent); }

/* ---------- route panel ---------- */
#route-panel {
  left: 50%; transform: translateX(-50%);
  bottom: 16px;
  width: min(560px, calc(100vw - 24px));
  padding: 12px 14px;
  display: none;
}
#route-panel.show { display: block; }
#route-panel h3 {
  font-size: 13px; color: #f0f6fc; margin-bottom: 6px;
  display: flex; align-items: center; gap: 8px;
}
#route-panel h3 .rp-status { font-size: 10.5px; font-weight: 500; color: var(--dim2); }
#stops { display: flex; flex-direction: column; gap: 4px; margin: 6px 0; }
.stop-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--fg);
  background: var(--panel2);
  border: 1px solid var(--line2);
  border-radius: 6px;
  padding: 4px 8px;
}
.stop-row .num {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); color: #04121f;
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.stop-row .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stop-row .rm {
  background: none; border: none; color: var(--dim2);
  font-size: 13px; cursor: pointer; padding: 0 4px;
}
.stop-row .rm:hover { color: var(--bad); }
#route-summary { font-size: 12.5px; color: var(--dim); margin-top: 4px; }
#route-summary b { color: #f0f6fc; font-weight: 700; }
#route-summary .warn { color: var(--warn); }
.route-actions { display: flex; gap: 8px; margin-top: 8px; }
.route-actions button {
  flex: 1;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--panel2); color: var(--fg);
}
.route-actions button:hover { background: var(--line2); }
.route-actions #rp-clear { color: var(--bad); border-color: #f8514944; }
.route-actions #rp-clear:hover { background: #3d1214; }
#rp-toggle-done { background: #238636; border-color: #238636; color: #fff; }

/* ---------- markers ---------- */
.mk {
  width: 42px; height: 42px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: #fff;
  border: 3px solid var(--c, #58a6ff);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.55);
  cursor: pointer;
  transition: transform .12s ease;
  position: relative;
}
.mk:hover { transform: scale(1.14); z-index: 9999; }
.mk img { width: 100%; height: 100%; object-fit: contain; padding: 5px; border-radius: 50%; }
.mk svg { width: 20px; height: 20px; }
.mk.mono { background: var(--c, #58a6ff); }
.mk.mono span { font-size: 14px; font-weight: 800; color: #fff; letter-spacing: -0.5px; }
.mk.glyph { background: var(--c, #2ea44e); }
.mk.glyph svg { width: 21px; height: 21px; }
.mk .badge-dot {
  position: absolute; top: -1px; right: -1px;
  width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid #0d1117;
  background: var(--c, #58a6ff);
}

/* route stop markers */
.stop-mk {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: #04121f;
  font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

/* ---------- popup ---------- */
.leaflet-popup-content-wrapper {
  background: var(--panel);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.6);
}
.leaflet-popup-tip { background: var(--panel); border: 1px solid var(--line); }
.leaflet-popup-content { margin: 0; width: 292px !important; }
.leaflet-popup-close-button { color: var(--dim) !important; padding: 8px 8px 0 0 !important; font-size: 16px !important; }
.pop { padding: 12px 14px 10px; }
.pop .head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 9px; }
.pop .head .logo {
  width: 40px; height: 40px; border-radius: 10px;
  background: #fff; border: 1px solid var(--line);
  flex: 0 0 auto; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.pop .head .logo img { width: 100%; height: 100%; object-fit: contain; }
.pop .head .logo svg { width: 22px; height: 22px; }
.pop .head .logo.mono { background: var(--c, #58a6ff); }
.pop .head .logo.mono span { color: #fff; font-weight: 800; font-size: 14px; }
.pop .ttl { font-size: 14.5px; font-weight: 700; color: #f0f6fc; line-height: 1.25; }
.pop .ttl .zh { display: block; font-size: 11.5px; font-weight: 500; color: var(--dim); margin-top: 1px; }
.pop .cat { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--c); margin-bottom: 8px; }
.pop .photo { border-radius: 8px; overflow: hidden; border: 1px solid var(--line2); margin-bottom: 8px; position: relative; background: #010409; }
.pop .photo img { display: block; width: 100%; height: 150px; object-fit: cover; cursor: zoom-in; }
.pop .thumbs { display: flex; gap: 5px; margin-bottom: 9px; }
.pop .thumbs img {
  width: 56px; height: 38px; object-fit: cover;
  border-radius: 5px; border: 2px solid transparent;
  cursor: pointer; opacity: .75;
}
.pop .thumbs img:hover { opacity: 1; }
.pop .thumbs img.sel { border-color: var(--accent); opacity: 1; }
.pop .desc { font-size: 12px; color: #c9d1d9; line-height: 1.55; margin-bottom: 9px; }
.pop .links { display: flex; gap: 10px; margin-bottom: 8px; font-size: 11px; }
.pop .links a { color: var(--accent); text-decoration: none; }
.pop .links a:hover { text-decoration: underline; }
.pop .acts { display: flex; gap: 7px; margin-bottom: 6px; }
.pop .acts button {
  flex: 1;
  background: var(--panel2); border: 1px solid var(--line);
  color: var(--fg); border-radius: 6px;
  font-size: 11px; font-weight: 600; padding: 5px 8px; cursor: pointer;
}
.pop .acts button:hover { background: var(--line2); border-color: #484f58; }
.pop .credit { font-size: 9.5px; color: var(--dim2); line-height: 1.4; }

/* lightbox for popup photos */
#lightbox {
  position: fixed; inset: 0; z-index: 5000;
  background: rgba(1, 4, 9, 0.88);
  display: none; align-items: center; justify-content: center;
  cursor: zoom-out;
}
#lightbox.show { display: flex; }
#lightbox img { max-width: 92vw; max-height: 88vh; border-radius: 10px; box-shadow: 0 12px 48px rgba(0,0,0,.7); }

/* ---------- leaflet tweaks ---------- */
.leaflet-container { font: inherit; }
.leaflet-bar a, .leaflet-bar a:hover {
  background: var(--panel); color: var(--fg);
  border-bottom: 1px solid var(--line2);
}
.leaflet-bar a:hover { background: var(--panel2); }
.leaflet-bar { border: 1px solid var(--line) !important; box-shadow: 0 4px 14px rgba(0,0,0,.4) !important; border-radius: 8px !important; overflow: hidden; }
.leaflet-control-attribution {
  background: rgba(13, 17, 23, 0.82) !important;
  color: var(--dim2) !important;
  font-size: 9.5px !important;
  border-radius: 6px 0 0 0;
  padding: 3px 8px !important;
}
.leaflet-control-attribution a { color: var(--dim) !important; }
#map.light .leaflet-control-attribution { background: rgba(255,255,255,.85) !important; color: #57606a !important; }
.leaflet-tooltip {
  background: var(--panel); border: 1px solid var(--line); color: var(--fg);
  border-radius: 6px; font-size: 11.5px; font-weight: 600; padding: 3px 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
}
.leaflet-tooltip::before { display: none; }

/* mobile */
#list-toggle { display: none; }
@media (max-width: 768px) {
  #list-panel {
    top: 10px; left: 10px; right: 10px; bottom: auto;
    width: auto; max-height: 46vh;
    transform: translateY(calc(-100% - 14px));
    transition: transform .2s ease;
  }
  #list-panel.open { transform: none; }
  #list-toggle {
    display: flex; align-items: center; gap: 7px;
    position: absolute; top: 10px; left: 10px; z-index: 1001;
  }
  #controls { top: 10px; right: 10px; flex-wrap: wrap; justify-content: flex-end; max-width: 60vw; }
  #route-panel { bottom: 10px; }
  .leaflet-popup-content { width: min(292px, calc(100vw - 40px)) !important; }
}
