:root {
  --bg: #ffffff;
  --fg: #1d2420;
  --muted: #6b746f;
  --border: #d9dfdb;
  --accent: #1f6f43;
  --here: #1f9d55;
  --soon: #e8890c;
  --later: #7d8590;
  --error: #c62828;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Noto Sans TC", "PingFang TC", sans-serif;
}

body {
  display: flex;
  flex-direction: column;
}

#bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px;
  padding-top: max(8px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

#bar .row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: center;
}

#bar h1 {
  margin: 0;
  font-size: 18px;
  color: var(--accent);
}

#bar label {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
}

#bar select, #bar input, #bar button {
  font: inherit;
  font-size: 15px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
}

#bar button {
  margin-left: auto;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

#stage {
  flex: 1;
  position: relative;
}

#map {
  position: absolute;
  inset: 0;
}

#bar input:invalid {
  border-color: var(--error);
}

#status {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 12px;
  z-index: 1000;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
  font-size: 14px;
}

@media (min-width: 720px) {
  #bar {
    flex-direction: row;
    align-items: center;
    gap: 8px 16px;
  }

  #bar .row {
    display: contents;
  }

  #bar #locate {
    order: 1;
  }

  #status {
    left: 50%;
    right: auto;
    width: min(480px, calc(100% - 24px));
    transform: translateX(-50%);
  }
}

#status.error {
  border-color: var(--error);
  color: var(--error);
}

#legend {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 12px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}

#summary { margin-left: auto; }

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: -1px;
}
.dot.here { background: var(--here); }
.dot.soon { background: var(--soon); }
.dot.later { background: var(--later); }

.stop-icon { background: none; border: none; }

.pill {
  position: absolute;
  left: 0;
  bottom: 0;
  transform: translate(-50%, 0);
  white-space: nowrap;
  padding: 3px 7px;
  border-radius: 12px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
}

.pill::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-bottom: 0;
  border-top-color: inherit;
}

.pill.here { background: var(--here); border-top-color: var(--here); }
.pill.soon { background: var(--soon); border-top-color: var(--soon); }
.pill.later { background: var(--later); border-top-color: var(--later); }

.pill small {
  font-weight: 400;
  opacity: .9;
}

.popup h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.popup ul {
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
}

.popup li {
  padding: 4px 0;
  border-top: 1px solid var(--border);
  font-size: 13px;
}

.popup .tag {
  display: inline-block;
  padding: 0 6px;
  border-radius: 8px;
  color: #fff;
  font-size: 12px;
  margin-right: 4px;
}
.popup .tag.here { background: var(--here); }
.popup .tag.soon { background: var(--soon); }
.popup .tag.later { background: var(--later); }

.popup .meta {
  color: var(--muted);
  font-size: 12px;
}

.popup a.nav {
  display: block;
  text-align: center;
  padding: 8px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
}
