:root {
  --bi-bg: rgba(12, 18, 28, 0.82);
  --bi-border: rgba(255, 255, 255, 0.12);
  --bi-text: #f4f7fb;
  --bi-muted: rgba(244, 247, 251, 0.65);
  --bi-accent: #e8a574;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--bi-text);
}

#map {
  width: 100%;
  height: 100%;
  background: #1a2332;
}

.bi-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.85rem 1.25rem;
  background: linear-gradient(180deg, rgba(8, 12, 20, 0.92) 0%, rgba(8, 12, 20, 0.55) 100%);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--bi-border);
}

.bi-back {
  color: var(--bi-accent);
  text-decoration: none;
  font-size: 0.88rem;
  white-space: nowrap;
}

.bi-back:hover {
  text-decoration: underline;
}

.bi-title-block h1 {
  font-family: "Noto Serif SC", serif;
  font-size: 1.15rem;
  margin: 0;
  font-weight: 700;
}

.bi-title-block p {
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
  color: var(--bi-muted);
}

.bi-stats {
  margin-left: auto;
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.stat-chip {
  background: var(--bi-bg);
  border: 1px solid var(--bi-border);
  border-radius: 10px;
  padding: 0.4rem 0.75rem;
  min-width: 88px;
  text-align: center;
}

.stat-chip strong {
  display: block;
  font-size: 1.05rem;
  color: var(--bi-accent);
}

.stat-chip span {
  font-size: 0.72rem;
  color: var(--bi-muted);
}

.bi-panel {
  position: fixed;
  left: 14px;
  top: 88px;
  bottom: 14px;
  width: min(300px, calc(100vw - 28px));
  z-index: 1000;
  background: var(--bi-bg);
  border: 1px solid var(--bi-border);
  border-radius: 14px;
  backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.bi-panel-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--bi-border);
  font-size: 0.88rem;
}

.bi-panel-head strong {
  flex: 1;
}

.bi-mini-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--bi-border);
  color: var(--bi-text);
  border-radius: 6px;
  padding: 0.2rem 0.45rem;
  font-size: 0.72rem;
  cursor: pointer;
}

.bi-mini-btn:hover {
  background: rgba(232, 165, 116, 0.2);
}

.legend-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.65rem;
}

.legend-row {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.45rem 0.4rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.legend-row:hover,
.legend-row.active {
  background: rgba(255, 255, 255, 0.08);
}

.legend-row.dim {
  opacity: 0.35;
}

.legend-swatch {
  width: 28px;
  height: 5px;
  border-radius: 3px;
  margin-top: 0.35rem;
  flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
}

.legend-text {
  flex: 1;
  min-width: 0;
}

.legend-text .date {
  font-weight: 700;
  font-size: 0.82rem;
}

.legend-text .label {
  font-size: 0.75rem;
  color: var(--bi-muted);
  line-height: 1.35;
}

.legend-text .km {
  font-size: 0.68rem;
  color: var(--bi-accent);
}

.bi-panel-foot {
  padding: 0.65rem 0.85rem;
  border-top: 1px solid var(--bi-border);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.layer-toggle {
  font-size: 0.78rem;
  color: var(--bi-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}

.bi-detail {
  position: fixed;
  right: 14px;
  bottom: 14px;
  width: min(340px, calc(100vw - 28px));
  z-index: 1001;
  background: var(--bi-bg);
  border: 1px solid var(--bi-border);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.bi-detail-close {
  position: absolute;
  top: 0.5rem;
  right: 0.55rem;
  background: transparent;
  border: none;
  color: var(--bi-text);
  font-size: 1.25rem;
  cursor: pointer;
}

.bi-detail h3 {
  font-family: "Noto Serif SC", serif;
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  padding-right: 1.5rem;
}

.bi-detail p {
  margin: 0.25rem 0;
  font-size: 0.82rem;
  color: var(--bi-muted);
  line-height: 1.5;
}

.bi-detail a {
  color: var(--bi-accent);
  font-size: 0.82rem;
}

.leaflet-popup-content-wrapper {
  border-radius: 10px;
  font-size: 13px;
}

.city-label {
  background: rgba(12, 18, 28, 0.88);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 11px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.city-label.hub {
  border-color: var(--bi-accent);
  color: var(--bi-accent);
  font-weight: 700;
}

.hub-star {
  font-size: 22px;
  filter: drop-shadow(0 0 6px rgba(232, 165, 116, 0.8));
}

@media (max-width: 768px) {
  .bi-topbar {
    flex-wrap: wrap;
    padding-top: 0.65rem;
  }

  .bi-stats {
    width: 100%;
    margin-left: 0;
  }

  .bi-panel {
    top: auto;
    height: 42vh;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    border-radius: 14px 14px 0 0;
  }

  .bi-detail {
    right: 0;
    left: 0;
    bottom: 42vh;
    width: 100%;
    border-radius: 14px 14px 0 0;
  }
}
