:root {
  /* Okabe-Ito-Töne: lesen sich als Grün/Gelb/Rot, bleiben aber auch bei Rot-Grün-Schwäche unterscheidbar */
  --z1: #009e73;
  --z2: #f0e442;
  --z3: #d55e00;
  --z4: #8a8a8a;
  --brand: #b71c1c;
  --bg: #ffffff;
  --fg: #1d1d1f;
  --muted: #5f6368;
  --line: #e3e3e6;
  --hover: #f4f5f7;
  --accent: #1565c0;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #18191b;
    --fg: #ececee;
    --muted: #a3a6ab;
    --line: #2e3034;
    --hover: #23252a;
    --accent: #64a8ff;
  }
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--fg);
  background: var(--bg);
}

/* ---------- Kopfzeile ---------- */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 8px 12px;
  padding-top: calc(8px + env(safe-area-inset-top));
  padding-left: calc(12px + env(safe-area-inset-left));
  padding-right: calc(12px + env(safe-area-inset-right));
  background: var(--brand);
  color: #fff;
}

.title {
  margin: 0;
  font-size: 18px;
  white-space: nowrap;
}

.mode {
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.mode.manual { background: #ffd54f; color: #3e2723; }

.btn-locate {
  margin-left: auto;
  padding: 8px 14px;
  border: 2px solid #fff;
  border-radius: 8px;
  background: #fff;
  color: var(--brand);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.btn-locate.attention {
  background: #ffd54f;
  border-color: #ffd54f;
  color: #3e2723;
  box-shadow: 0 0 0 3px rgba(255, 213, 79, 0.45);
}

@media (max-width: 520px) {
  .btn-locate { width: 100%; margin-left: 0; }
}

/* ---------- Meldungen ---------- */
.message {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 12px;
  background: #fff3cd;
  color: #4d3800;
  border-bottom: 1px solid #f0d78c;
}

.message[hidden] { display: none; }
.message.error { background: #fde2e1; color: #6b0f0c; border-color: #f3b4b1; }
.message span { flex: 1; }

.message-close {
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

/* ---------- Layout: Handy Karte oben / Liste unten, PC nebeneinander ---------- */
.layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.map {
  flex: 0 0 45%;
  min-height: 220px;
  transition: flex-basis 0.25s ease;
}

.panel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom);
  transition: flex-basis 0.25s ease;
}

.list-toggle {
  position: relative;
  z-index: 500;
  width: 100%;
  padding: 8px 14px;
  border: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  color: var(--accent);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.list-toggle::before {
  content: "▼";
  display: inline-block;
  margin-right: 7px;
  font-size: 11px;
  transition: transform 0.25s ease;
}

@media (max-width: 899px) {
  .layout.list-collapsed .map { flex: 1 1 auto; }
  .layout.list-collapsed .panel {
    flex: 0 1 0;
    overflow: hidden;
    padding-bottom: 0;
    visibility: hidden;
  }
  .layout.list-collapsed .list-toggle::before { transform: rotate(180deg); }
}

@media (min-width: 900px) {
  .layout { flex-direction: row; }
  .map { flex: 1 1 auto; min-height: 0; }
  .panel { flex: 0 0 420px; border-left: 1px solid var(--line); }
  .list-toggle { display: none; }
}

/* ---------- Liste ---------- */
.summary {
  padding: 10px 14px;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}

.summary .sub {
  display: block;
  font-weight: 400;
  color: var(--muted);
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.station {
  position: relative;
  padding: 10px 14px 10px 20px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.station::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  background: var(--zone);
}

.station:hover, .station:focus-visible { background: var(--hover); outline: none; }
.station.active { background: var(--hover); }

.station.z1 { --zone: var(--z1); }
.station.z2 { --zone: var(--z2); }
.station.z3 { --zone: var(--z3); }
.station.z4 { --zone: var(--z4); }

.station-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.station-dist { font-size: 17px; font-weight: 700; }

.zone-tag {
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.25);
  background: var(--zone);
  color: #111;
  font-size: 12px;
  font-weight: 700;
}

.station.z1 .zone-tag, .station.z3 .zone-tag, .station.z4 .zone-tag { color: #fff; }

.station-addr { margin-top: 2px; }
.station-meta, .station-op { color: var(--muted); font-size: 14px; }

.btn-nav {
  display: inline-block;
  margin-top: 6px;
  padding: 5px 12px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.empty {
  padding: 14px;
  color: var(--muted);
}

/* ---------- Legende ---------- */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding: 10px 14px 14px;
  font-size: 13px;
  color: var(--muted);
}

.legend .hint { flex-basis: 100%; margin: 4px 0 0; }

.dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 5px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.35);
  vertical-align: -1px;
}

.dot.z1 { background: var(--z1); }
.dot.z2 { background: var(--z2); }
.dot.z3 { background: var(--z3); }

/* ---------- Karte ---------- */
.pin-icon { background: none; border: 0; }

/* Tropfenform: Quadrat mit einer spitzen Ecke, um 45° gedreht, Spitze zeigt nach unten */
.pin-icon div {
  width: 26px;
  height: 26px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: #1e88e5; /* gleiches Blau wie der GPS-Punkt, damit der Pin nicht wie eine rote Zone aussieht */
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.popup h3 { margin: 0 0 4px; font-size: 15px; }
.popup p { margin: 2px 0; }
.popup .btn-nav { color: #fff; }
