:root {
  --c-ice: #e2001a;
  --c-ic: #f08300;
  --c-n: #7a3e9d;
  --c-re: #205aa7;
  --c-rb: #3fa9e1;
  --c-s: #00955f;
  --panel-bg: rgba(255, 255, 255, 0.94);
  --text: #1c2330;
  --muted: #6b7382;
  --shadow: 0 2px 14px rgba(20, 30, 50, 0.18);
  --radius: 10px;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  color: var(--text);
}

#map {
  position: fixed;
  inset: 0;
  background: #e9eef2;
}

.panel {
  position: fixed;
  z-index: 1000;
  background: var(--panel-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(4px);
}

/* ---------- Suchpanel ---------- */
.search-panel {
  top: 14px;
  left: 14px;
  width: 320px;
  max-width: calc(100vw - 28px);
  padding: 14px 16px 12px;
}

.search-panel h1 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: 0.01em;
}

.subtitle {
  margin: 2px 0 10px;
  font-size: 0.78rem;
  color: var(--muted);
}

.search-wrap { position: relative; }

#search {
  width: 100%;
  padding: 9px 34px 9px 12px;
  font-size: 0.95rem;
  border: 1px solid #c9d0da;
  border-radius: 8px;
  outline: none;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#search:focus {
  border-color: var(--c-re);
  box-shadow: 0 0 0 3px rgba(32, 90, 167, 0.15);
}

.clear-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: none;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.clear-btn:hover { color: var(--text); background: #eef1f5; }

.suggestions {
  list-style: none;
  margin: 6px 0 0;
  padding: 4px;
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid #dde2e9;
  border-radius: 8px;
  background: #fff;
}

.suggestions li {
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.suggestions li:hover,
.suggestions li.active { background: #eef3fa; }

.suggestions .cat-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}

.suggestions .conn-count {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--muted);
}

.station-info {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #e3e7ed;
  font-size: 0.85rem;
  animation: fade-in 0.35s ease;
}

.station-info .station-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.station-info .station-stats {
  color: var(--muted);
  margin-top: 2px;
}

/* ---------- Relation (Zugliste) ---------- */
.relation {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #e3e7ed;
  animation: fade-in 0.35s ease;
}

.relation-head {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.relation-title {
  flex: 1;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.35;
}

.rel-arrow { margin: 0 5px; color: var(--muted); }

.relation-head .clear-btn {
  position: static;
  transform: none;
  flex: none;
}

.relation-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  max-height: 300px;
  overflow-y: auto;
  font-size: 0.82rem;
}

.relation-list li {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 2px;
  border-bottom: 1px solid #eef1f5;
}

.relation-list li:last-child { border-bottom: none; }

.rel-time { font-weight: 600; font-variant-numeric: tabular-nums; }
.rel-arr  { color: var(--muted); font-variant-numeric: tabular-nums; }
.rel-days { margin-left: auto; color: var(--muted); font-size: 0.75rem; text-align: right; }

.promote-btn {
  margin-top: 8px;
  width: 100%;
  padding: 7px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  background: #eef1f5;
  border: 1px solid #d7dde5;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.promote-btn:hover { background: #e2e8f0; }

.relation-list li[data-train] { cursor: pointer; border-radius: 6px; transition: background 0.12s; }
.relation-list li[data-train]:hover { background: #eef3fa; }

.trip-days {
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
}

.trip-list li { border-bottom: none; padding: 3px 2px; }
.trip-list .trip-before { opacity: 0.5; }
.trip-list .trip-origin span:last-child,
.trip-list .trip-dest span:last-child { font-weight: 700; }

/* ---------- Legende ---------- */
.legend {
  left: 14px;
  bottom: 38px;
  padding: 10px 14px;
  font-size: 0.82rem;
}

.legend h2 {
  margin: 0 0 6px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.legend label {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2px 0;
  cursor: pointer;
  user-select: none;
}

.legend input { accent-color: var(--text); }

.swatch {
  display: inline-block;
  width: 22px;
  height: 4px;
  border-radius: 2px;
}
.swatch-ice { background: var(--c-ice); }
.swatch-ic  { background: var(--c-ic); }
.swatch-n   { background: var(--c-n); }
.swatch-re  { background: var(--c-re); }
.swatch-rb  { background: var(--c-rb); }
.swatch-s   { background: var(--c-s); }

/* ---------- Fußzeile ---------- */
.credits {
  right: 14px;
  bottom: 14px;
  padding: 5px 10px;
  font-size: 0.7rem;
  color: var(--muted);
  border-radius: 6px;
}
.credits a { color: inherit; }

/* ---------- Karte: Linien & Marker ---------- */
.origin-marker { position: relative; }

.origin-dot {
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: #1c2330;
  border: 2.5px solid #fff;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.35);
}

.origin-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(28, 35, 48, 0.45);
  animation: pulse 1.8s ease-out infinite;
}

@keyframes pulse {
  0%   { opacity: 0.7; transform: scale(1); }
  70%  { opacity: 0;   transform: scale(3.2); }
  100% { opacity: 0;   transform: scale(3.2); }
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

.dest-tooltip {
  font-family: inherit;
  font-size: 0.8rem;
  line-height: 1.45;
  border: none;
  box-shadow: var(--shadow);
  border-radius: 8px;
  padding: 8px 10px;
}

.dest-tooltip .tt-name { font-weight: 600; }
.dest-tooltip .tt-meta { color: var(--muted); }
.dest-tooltip .tt-lines { margin-top: 2px; }

.line-badge {
  display: inline-block;
  padding: 1px 5px;
  margin: 1px 3px 1px 0;
  border-radius: 4px;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
}

/* ---------- Mobil ---------- */
@media (max-width: 540px) {
  .search-panel { width: calc(100vw - 28px); }
  .legend { bottom: 56px; font-size: 0.76rem; padding: 8px 12px; }
  .credits { left: 14px; right: auto; max-width: calc(100vw - 28px); }
}
