:root {
  --tram: #00985f; /* HSL tram green */
  --bus: #007ac9; /* HSL bus blue */
  --bg: #11161c;
  --surface: rgba(20, 26, 33, 0.92);
  --border: #2a3540;
  --text: #e8eef4;
  --dim: #93a3b3;
  --ok: #3ddc84;
  --warn: #ffb020;
  --bad: #ff5c5c;
  --late: #ff8a5c;
  --early: #5cc8ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

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

/* Keep the OSM tiles from glowing against the dark chrome. */
.leaflet-tile-pane {
  filter: brightness(0.78) saturate(0.85) contrast(1.05);
}

.hidden {
  display: none !important;
}

/* ── top bar ─────────────────────────────────────────────────────────────── */

.topbar {
  position: absolute;
  z-index: 1000;
  top: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 24px rgb(0 0 0 / 35%);
}

.topbar h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  white-space: nowrap;
}

.status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--dim);
  white-space: nowrap;
}

.sep {
  opacity: 0.4;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
  flex: none;
}
.dot.on {
  background: var(--ok);
}
.dot.off {
  background: var(--bad);
}

.btn {
  font: inherit;
  font-size: 12px;
  color: var(--text);
  background: #1b232c;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 10px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover {
  border-color: var(--tram);
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--dim);
  padding: 4px 7px;
}
.btn.ghost:hover {
  color: var(--text);
}

/* ── nearest-trams panel ─────────────────────────────────────────────────── */

.panel {
  position: absolute;
  z-index: 1000;
  top: 12px;
  right: 12px;
  bottom: 12px;
  width: 300px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 24px rgb(0 0 0 / 35%);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 10px 12px;
  border-bottom: 1px solid var(--border);
}

.panel-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  flex: 1;
}

.radius select {
  font: inherit;
  font-size: 12px;
  color: var(--text);
  background: #1b232c;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 4px 6px;
}

.panel-show {
  position: absolute;
  z-index: 1000;
  top: 12px;
  right: 12px;
}

.note {
  margin: 0;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--warn);
  border-bottom: 1px solid var(--border);
}

.list {
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  flex: 1;
}

.list .empty {
  padding: 16px 12px;
  color: var(--dim);
  font-size: 12px;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-bottom: 1px solid rgb(42 53 64 / 55%);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.row:hover {
  background: rgb(0 152 95 / 12%);
}

.line {
  flex: none;
  min-width: 30px;
  padding: 3px 6px;
  border-radius: 6px;
  background: var(--tram);
  color: #04150e;
  font-weight: 700;
  font-size: 13px;
  text-align: center;
}

.line.bus {
  background: var(--bus);
  color: #f2f9ff;
}

.row-main {
  flex: 1;
  min-width: 0;
}

.dest {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta {
  display: block;
  font-size: 11px;
  color: var(--dim);
}

.dist {
  flex: none;
  font-variant-numeric: tabular-nums;
  color: var(--dim);
  font-size: 12px;
}

.late {
  color: var(--late);
}
.early {
  color: var(--early);
}

/* ── map markers ─────────────────────────────────────────────────────────── */

.tram-marker {
  position: relative;
  width: 30px;
  height: 30px;
}

.tram-badge {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--tram);
  color: #04150e;
  font-weight: 700;
  font-size: 12px;
  border: 2px solid rgb(255 255 255 / 85%);
  box-shadow: 0 2px 6px rgb(0 0 0 / 45%);
}

.tram-marker.bus .tram-badge {
  background: var(--bus);
  color: #f2f9ff;
}

/* Heading arrow, rotated per vehicle via a CSS custom property. */
.tram-arrow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  transform: translate(-50%, -50%) rotate(var(--hdg, 0deg));
}
.tram-arrow::before {
  content: "";
  position: absolute;
  left: -5px;
  top: -25px;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 8px solid rgb(255 255 255 / 90%);
}

.tram-marker.stale .tram-badge {
  background: #5a6a76;
  color: #dfe8ef;
}

.me-marker {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #3d9bff;
  border: 3px solid #fff;
  box-shadow: 0 0 0 4px rgb(61 155 255 / 25%);
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #161d25;
  color: var(--text);
  border: 1px solid var(--border);
}
.leaflet-popup-content {
  margin: 10px 12px;
  font-size: 13px;
}
.leaflet-popup-content b {
  color: #fff;
}
.leaflet-container a.leaflet-popup-close-button {
  color: var(--dim);
}

@media (max-width: 720px) {
  .panel {
    top: auto;
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    max-height: 45vh;
  }
  .topbar {
    right: 12px;
    flex-wrap: wrap;
  }
}
