:root {
  --panel: rgba(255, 255, 255, 0.94);
  --panel-border: rgba(15, 23, 42, 0.1);
  --text: #111827;
  --muted: #6b7280;
  --accent: #0f766e;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC",
    "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: #f2f2f2;
  letter-spacing: 0.01em;
}

#map {
  width: 100%;
  height: 100%;
}

.leaflet-container {
  background: #f2f2f2;
  font-family: inherit;
}

.leaflet-tile-pane {
  filter: none;
  opacity: 1;
}

.leaflet-control-zoom a {
  width: 32px !important;
  height: 32px !important;
  line-height: 32px !important;
  border: 1px solid rgba(15, 23, 42, 0.1) !important;
  color: #374151 !important;
  background: rgba(255, 255, 255, 0.94) !important;
}

.leaflet-control-attribution {
  font-size: 10px;
  color: #6b7280;
  background: rgba(255, 255, 255, 0.72);
}

.panel {
  position: absolute;
  z-index: 500;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.panel-left {
  top: 14px;
  left: 14px;
  width: min(268px, calc(100vw - 28px));
  padding: 12px;
}

.search input {
  width: 100%;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 9px 10px;
  font-size: 13px;
  outline: none;
}

.search input:focus {
  border-color: #9ca3af;
}

.suggest {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  max-height: 160px;
  overflow: auto;
}

.suggest li {
  padding: 7px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: #374151;
}

.suggest li:hover {
  background: #f3f4f6;
}

.row {
  display: flex;
  gap: 6px;
  margin: 10px 0 0;
}

.btn,
.toggle {
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #374151;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
}

.toggle.active {
  background: #111827;
  border-color: #111827;
  color: #fff;
}

.legend {
  display: none;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #eef2f7;
}

body.has-origin .legend {
  display: block;
}

.legend-bar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  height: 10px;
}

.legend-swatch {
  display: block;
  height: 100%;
  border-radius: 2px;
}

.legend-labels {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  margin-top: 5px;
  font-size: 10px;
  color: var(--muted);
  text-align: center;
}

#result {
  margin-top: 10px;
  font-size: 13px;
}

#result:empty {
  margin: 0;
}

.result-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.result-line strong {
  font-size: 15px;
  font-weight: 600;
}

.result-line span {
  color: var(--muted);
  font-size: 12px;
}

.counts {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.dest {
  margin-top: 6px;
  font-size: 12px;
  color: #334155;
}

.leaflet-tooltip.station-tip {
  background: #111827;
  color: #fff;
  border: none;
  border-radius: 6px;
  box-shadow: none;
  padding: 6px 8px;
  font-size: 12px;
}

.leaflet-tooltip.station-tip::before {
  border-top-color: #111827;
}

.leaflet-tooltip.origin-label {
  font-size: 13px;
  font-weight: 600;
  padding: 5px 9px;
  white-space: nowrap;
  pointer-events: none;
}

.leaflet-tooltip.origin-label::before {
  border-right-color: #111827;
  border-top-color: transparent;
}

@media (max-width: 720px) {
  .panel-left {
    top: 10px;
    left: 10px;
    right: 10px;
    width: auto;
    padding: 10px;
    max-height: min(42vh, 320px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .search input {
    font-size: 16px; /* 避免 iOS 自动放大输入框 */
    padding: 10px 12px;
  }

  .row {
    flex-wrap: wrap;
  }

  .btn,
  .toggle {
    min-height: 36px;
    padding: 8px 12px;
    font-size: 13px;
  }

  .suggest li {
    padding: 10px 8px;
    font-size: 14px;
  }

  .leaflet-control-zoom {
    margin-bottom: 18px !important;
  }

  .leaflet-tooltip.station-tip {
    font-size: 13px;
    padding: 7px 9px;
  }
}
