:root {
  --accent-re: #0a66ff;
  --accent-rb: #1f9d55;
  --accent-s: #8b5cf6;
  --bg: #f4f4f7;
  --card-bg: #ffffff;
  --text: #1c1c1e;
  --text-secondary: #6b6b70;
  --border: #e3e3e8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  padding: 24px 20px 16px;
  text-align: center;
}
.topbar h1 { margin: 0; font-size: 1.8rem; }
.subtitle { color: var(--text-secondary); margin: 4px 0 0; }

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px 60px;
}

.controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  position: sticky;
  top: 0;
  background: var(--bg);
  padding: 12px 0;
  z-index: 5;
}
.controls input, .controls select {
  flex: 1 1 160px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 1rem;
  background: var(--card-bg);
}

.line-list { display: flex; flex-direction: column; gap: 10px; }

.line-card {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  cursor: pointer;
  transition: transform 0.08s ease;
}
.line-card:hover { transform: translateY(-1px); }

.line-header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 8px;
  color: white;
  font-weight: 700;
  font-size: 0.95rem;
}
.badge.RE { background: var(--accent-re); }
.badge.RB { background: var(--accent-rb); }
.badge.S { background: var(--accent-s); }

.note-tag {
  font-size: 0.75rem;
  color: var(--text-secondary);
}
.region-tag {
  font-size: 0.7rem;
  font-weight: 600;
  background: rgba(255,149,0,0.15);
  color: #b45900;
  padding: 2px 8px;
  border-radius: 20px;
}

.route { font-weight: 600; margin-top: 6px; }
.operator, .vehicles { color: var(--text-secondary); font-size: 0.9rem; margin-top: 2px; }

.empty { text-align: center; color: var(--text-secondary); margin-top: 40px; }

footer {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.8rem;
  padding: 20px;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}
/* Das [hidden]-Attribut und unsere eigene display-Regel haben dieselbe
   CSS-Spezifität; ohne dieses :not([hidden]) würde "display: flex" das
   Verstecken per hidden-Attribut immer überschreiben. */
.overlay:not([hidden]) {
  display: flex;
}
@media (min-width: 640px) {
  .overlay { align-items: center; }
}

.detail-card {
  background: var(--card-bg);
  width: 100%;
  max-width: 640px;
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 16px 16px 0 0;
  padding: 20px;
  position: relative;
}
@media (min-width: 640px) {
  .detail-card { border-radius: 16px; }
}

.close-button {
  position: absolute;
  top: 12px;
  right: 12px;
  border: none;
  background: var(--border);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
}

.detail-section { margin-top: 20px; }
.detail-section h3 { margin-bottom: 8px; }

.vehicle-row { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.vehicle-row img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; flex-shrink: 0; background: var(--border); }
.vehicle-row .vname { font-weight: 600; }
.vehicle-row .vcontext, .vehicle-row .vcredit { font-size: 0.8rem; color: var(--text-secondary); }

.stop-list { list-style: none; padding: 0; margin: 0; }
.stop-list li {
  padding: 6px 0 6px 20px;
  position: relative;
  border-left: 2px solid var(--border);
  margin-left: 4px;
}
.stop-list li::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 12px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-secondary);
}
.stop-list li.endpoint { font-weight: 700; }
.stop-list li.endpoint::before { background: var(--accent-re); width: 10px; height: 10px; left: -6px; }
