:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #0f9f8a;
  --accent-soft: #e7f7f3;
  --warn: #b45309;
  --danger: #b91c1c;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

button {
  appearance: none;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 8px 12px;
  font: inherit;
  cursor: pointer;
}

button.secondary {
  background: #eef2f6;
  color: var(--text);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.app {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  grid-template-rows: auto 1fr;
  height: 100%;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.topbar-brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.topbar-brand h1 {
  margin: 0;
  font-size: 20px;
}

.topbar-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  overflow: auto;
  background: var(--bg);
  border-right: 1px solid var(--line);
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  box-shadow: var(--shadow);
}

.card.grow {
  flex: 1;
  min-height: 220px;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.section-title-row .section-title {
  margin-bottom: 0;
}

.mono {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
  word-break: break-all;
}

.body-text {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.hint.error {
  color: var(--danger);
}

.hint.warn {
  color: var(--warn);
}

.hidden {
  display: none !important;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
  cursor: pointer;
  text-align: left;
}

.item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.item .title {
  font-weight: 700;
  margin-bottom: 4px;
}

.item .meta {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.badge {
  color: var(--accent);
  font-weight: 600;
}

.schedule {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.schedule span {
  background: #f3f4f6;
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 12px;
}

.stations {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.station {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 13px;
}

.station .idx {
  width: 20px;
  color: var(--muted);
  flex: none;
}

.map-wrap {
  position: relative;
  min-height: 320px;
}

#map {
  width: 100%;
  height: 100%;
}

.map-legend {
  position: absolute;
  z-index: 500;
  left: 12px;
  bottom: 12px;
  display: flex;
  gap: 12px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}

.dot.stop {
  background: #6b7280;
}

.legend-pin,
.legend-bus {
  display: inline-block;
  vertical-align: -2px;
  margin-right: 4px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.legend-pin {
  width: 10px;
  height: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 26 32'%3E%3Cpath d='M13 1c6.075 0 11 4.813 11 10.75C24 19.5 13 31 13 31S2 19.5 2 11.75C2 5.813 6.925 1 13 1z' fill='%232563eb'/%3E%3Ccircle cx='13' cy='11.5' r='3.8' fill='%23fff'/%3E%3C/svg%3E");
}

.legend-bus {
  width: 14px;
  height: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3E%3Ccircle cx='15' cy='15' r='14' fill='%23fff' stroke='%230f9f8a' stroke-width='2'/%3E%3Crect x='6.5' y='8' width='17' height='12.5' rx='3.2' fill='%230f9f8a'/%3E%3Crect x='8.2' y='9.8' width='4.2' height='3.6' rx='0.8' fill='%23eef9ff'/%3E%3Crect x='13.4' y='9.8' width='4.2' height='3.6' rx='0.8' fill='%23eef9ff'/%3E%3Ccircle cx='11' cy='22.2' r='2.1' fill='%23111827'/%3E%3Ccircle cx='19.5' cy='22.2' r='2.1' fill='%23111827'/%3E%3C/svg%3E");
}

.map-marker {
  background: transparent;
  border: 0;
}

.empty {
  color: var(--muted);
  font-size: 13px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.toggle input {
  margin: 0;
}

.overlay-lines {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.overlay-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.overlay-line input {
  margin: 0;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex: none;
}

@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 48vh 1fr;
  }

  .panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .map-wrap {
    min-height: 42vh;
  }
}
