* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --walk-color: #4CAF50;
  --bike-color: #2196F3;
  --car-color: #FF5722;
  --bg: #f5f6fa;
  --card-bg: #ffffff;
  --text: #333;
  --text-secondary: #888;
  --border: #e8e8e8;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --radius: 10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--text);
  background: var(--bg);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Search Bar ── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--card-bg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  z-index: 1000;
  flex-shrink: 0;
}

.search-inputs {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 480px;
}

.input-group {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border-radius: 8px;
  padding: 6px 12px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-start { background: #1976D2; }
.dot-end { background: #D32F2F; }

.input-group input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  outline: none;
  color: var(--text);
}

.input-group input::placeholder {
  color: var(--text-secondary);
}

#search-btn {
  padding: 10px 24px;
  background: #1976D2;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}

#search-btn:hover { background: #1565C0; }
#search-btn:active { transform: scale(0.97); }
#search-btn:disabled {
  background: #90CAF9;
  cursor: not-allowed;
}

.search-error {
  color: #D32F2F;
  font-size: 12px;
  position: absolute;
  bottom: -20px;
  left: 20px;
}

/* ── Main Layout ── */
.main-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.map-container {
  flex: 1;
  position: relative;
}

/* ── Route Panel ── */
.route-panel {
  width: 360px;
  background: var(--card-bg);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-header h2 {
  font-size: 16px;
  font-weight: 700;
}

/* ── Route Cards ── */
.route-cards {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.placeholder-text {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  padding: 40px 20px;
}

.route-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  margin-bottom: 10px;
  background: var(--bg);
  border-radius: var(--radius);
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.route-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: 0 4px 4px 0;
  transition: background 0.3s ease;
}

.route-card.walk::before { background: var(--walk-color); }
.route-card.bike::before { background: var(--bike-color); }
.route-card.car::before { background: var(--car-color); }

.route-card:hover {
  border-color: #ddd;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.route-card.active {
  background: white;
  box-shadow: var(--shadow);
}

.route-card.active.walk { border-color: var(--walk-color); }
.route-card.active.bike { border-color: var(--bike-color); }
.route-card.active.car { border-color: var(--car-color); }

.route-card.dimmed {
  opacity: 0.4;
  transform: scale(0.98);
}

.card-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.walk .card-icon { background: rgba(76, 175, 80, 0.12); }
.bike .card-icon { background: rgba(33, 150, 243, 0.12); }
.car .card-icon { background: rgba(255, 87, 34, 0.12); }

.card-info {
  flex: 1;
  min-width: 0;
}

.card-label {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.card-stats {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

.card-stat {
  display: flex;
  align-items: center;
  gap: 3px;
}

.card-stat .stat-value {
  color: var(--text);
  font-weight: 600;
}

.card-arrow {
  color: var(--text-secondary);
  font-size: 16px;
  transition: transform 0.3s ease;
}

.route-card.active .card-arrow {
  transform: rotate(90deg);
}

/* ── Route Detail ── */
.route-detail {
  border-top: 1px solid var(--border);
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  background: var(--card-bg);
}

.route-detail.open {
  max-height: 500px;
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.detail-header h3 {
  font-size: 14px;
  font-weight: 600;
  flex: 1;
}

.detail-close {
  width: 28px;
  height: 28px;
  border: none;
  background: var(--bg);
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background 0.2s;
}

.detail-close:hover {
  background: #ddd;
}

.detail-steps {
  padding: 12px 16px;
  overflow-y: auto;
  max-height: 400px;
}

.step-item {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  position: relative;
}

.step-item:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 11px;
  top: 32px;
  bottom: -8px;
  width: 2px;
  background: var(--border);
}

.step-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
  color: white;
  z-index: 1;
}

.step-content {
  flex: 1;
}

.step-instruction {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
}

.step-meta {
  font-size: 11px;
  color: var(--text-secondary);
}

/* ── Loading state ── */
.loading {
  text-align: center;
  padding: 30px;
  color: var(--text-secondary);
}

.loading::after {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: #1976D2;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Card entrance animation ── */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.route-card {
  animation: slideUp 0.4s ease both;
}

.route-card:nth-child(2) { animation-delay: 0.08s; }
.route-card:nth-child(3) { animation-delay: 0.16s; }
