:root {
  --bg: #0f172a;
  --panel-bg: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --accent: #d62839;
  --border: #e2e8f0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

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

#app {
  display: flex;
  height: 100vh;
  width: 100vw;
}

#panel {
  width: 380px;
  flex-shrink: 0;
  background: var(--panel-bg);
  padding: 1.5rem;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.08);
  overflow-y: auto;
  z-index: 500;
}

h1 {
  margin: 0 0 0.15rem;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.hidden {
  display: none;
}

.mode-toggle {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.mode-btn {
  flex: 1;
  padding: 0.45rem 0.5rem;
  font-size: 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: none;
  cursor: pointer;
  color: var(--muted);
}

.mode-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.search-box {
  position: relative;
}

#search-input {
  width: 100%;
  padding: 0.65rem 0.8rem;
  font-size: 1rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s;
}

#search-input:focus {
  border-color: var(--accent);
}

.suggestions {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0.25rem;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  max-height: 260px;
  overflow-y: auto;
}

.suggestions.hidden {
  display: none;
}

.suggestions li {
  padding: 0.55rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.92rem;
}

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

.status {
  min-height: 1.2rem;
  margin-top: 0.75rem;
  font-size: 0.88rem;
  color: var(--muted);
}

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

.result-panel {
  margin-top: 1rem;
}

.result-panel.hidden {
  display: none;
}

.result-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.result-header h2 {
  font-size: 1.1rem;
  margin: 0.75rem 0 0;
}

#refresh-btn {
  border: 1px solid var(--border);
  background: none;
  border-radius: 6px;
  padding: 0.3rem 0.55rem;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--muted);
  white-space: nowrap;
}

#refresh-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#refresh-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.result-meta {
  margin: 0.15rem 0 0.75rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.city-alternatives {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 0.85rem;
}

.city-alternatives.hidden {
  display: none;
}

.city-chip {
  border: 1px solid var(--border);
  background: none;
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--muted);
}

.city-chip.active {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.connections-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.city-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}

.city-row:hover {
  border-color: var(--accent);
}

.tier-badge {
  display: inline-block;
  background: var(--border);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  margin-right: 0.4rem;
  vertical-align: middle;
}

.feed-dot {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  margin-right: 0.4rem;
  vertical-align: middle;
}

.name {
  font-weight: 500;
}

.line {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.duration {
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

.station-rows {
  list-style: none;
  margin: 0.3rem 0 0;
  padding: 0 0 0 0.75rem;
  border-left: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.station-rows.hidden {
  display: none;
}

.station-rows li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.82rem;
  cursor: pointer;
  border-radius: 6px;
}

.station-rows li:hover {
  background: #f6f6f6;
}

.network-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.network-legend li {
  display: flex;
  align-items: center;
  font-size: 0.85rem;
}

#map {
  flex: 1;
  height: 100%;
}

.station-tooltip {
  font-size: 0.8rem;
}

@media (max-width: 720px) {
  #app {
    flex-direction: column;
  }
  #panel {
    width: 100%;
    max-height: 45vh;
  }
  #map {
    flex: 1;
  }
}
