:root {
  --bg: #0f1419;
  --surface: #1a2129;
  --surface-2: #232c37;
  --surface-3: #2c3742;
  --border: #313c48;
  --text: #e8edf2;
  --text-dim: #9aa7b4;
  --accent: #14b8a6;
  --accent-2: #0ea5e9;
  --origin: #22c55e;
  --dest: #ef4444;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --font: "Vazirmatn", system-ui, sans-serif;
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.app {
  display: grid;
  grid-template-columns: 400px 1fr;
  height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 20px;
  gap: 16px;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 8px; }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  font-size: 26px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(20, 184, 166, 0.35);
}
.brand h1 { font-size: 19px; font-weight: 700; }
.brand p { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.panel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

/* ===== Search ===== */
.search-panel { display: flex; flex-direction: column; gap: 10px; position: relative; }
.field {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  position: relative;
  transition: border-color .15s;
}
.field:focus-within { border-color: var(--accent); }
.field input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 13px 0;
  outline: none;
}
.field input::placeholder { color: var(--text-dim); }
.dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.dot-origin { background: var(--origin); box-shadow: 0 0 0 3px rgba(34,197,94,.2); }
.dot-dest { background: var(--dest); box-shadow: 0 0 0 3px rgba(239,68,68,.2); }
.pin-btn {
  background: none; border: none; cursor: pointer;
  font-size: 16px; opacity: .7; transition: opacity .15s, transform .15s;
}
.pin-btn:hover { opacity: 1; transform: scale(1.15); }
.pin-btn.active { opacity: 1; filter: drop-shadow(0 0 6px var(--accent)); }

.swap-btn {
  position: absolute;
  left: 22px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); cursor: pointer; z-index: 5;
  font-size: 14px;
}
.swap-btn:hover { background: var(--accent); border-color: var(--accent); }

.suggest {
  position: absolute;
  list-style: none;
  top: 100%; left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 4px;
  z-index: 1000;
  max-height: 240px; overflow-y: auto;
  box-shadow: var(--shadow);
}
.suggest li {
  padding: 10px 12px;
  font-size: 13px; cursor: pointer;
  border-bottom: 1px solid var(--border);
  line-height: 1.5;
}
.suggest li:last-child { border-bottom: none; }
.suggest li:hover { background: var(--surface-3); }

.profile-row { display: flex; gap: 10px; }
.profile-chip {
  flex: 1;
  display: flex; flex-direction: column; gap: 4px;
  font-size: 11px; color: var(--text-dim);
}
.profile-chip select, .profile-chip input {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 9px;
  font-family: var(--font);
  font-size: 13px;
  outline: none;
}

.analyze-btn {
  position: relative;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none; border-radius: var(--radius-sm);
  color: #fff; font-family: var(--font); font-size: 15px; font-weight: 700;
  padding: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .12s, box-shadow .12s;
}
.analyze-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(14,165,233,.35); }
.analyze-btn:disabled { opacity: .6; cursor: wait; transform: none; }
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hint { font-size: 11px; color: var(--text-dim); line-height: 1.7; }

/* ===== Weather ===== */
.weather-panel { display: flex; flex-direction: column; gap: 12px; }
.weather-top { display: flex; align-items: center; gap: 14px; }
.weather-temp { font-size: 30px; font-weight: 700; }
.weather-meta { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--text-dim); }
.weather-badge {
  margin-right: auto;
  padding: 5px 12px; border-radius: 20px;
  font-size: 12px; font-weight: 700;
}
.weather-note { font-size: 12px; color: var(--text-dim); line-height: 1.7; }
.weather-hours { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.weather-hours::-webkit-scrollbar { height: 5px; }
.weather-hours::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 8px; }
.hour-chip {
  flex-shrink: 0;
  background: var(--surface-3); border-radius: 10px;
  padding: 8px 10px; text-align: center; min-width: 54px;
}
.hour-chip .h { font-size: 11px; color: var(--text-dim); }
.hour-chip .t { font-size: 14px; font-weight: 700; margin-top: 3px; }

/* ===== Routes list ===== */
.routes { display: flex; flex-direction: column; gap: 12px; }
.route-card {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: border-color .15s, transform .12s;
}
.route-card:hover { transform: translateY(-2px); }
.route-card.active { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(20,184,166,.15); }
.route-card-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
}
.route-name { font-weight: 700; font-size: 14px; }
.rec-tag {
  font-size: 10px; font-weight: 700;
  background: rgba(20,184,166,.15); color: var(--accent);
  padding: 3px 8px; border-radius: 20px;
}
.alt-tag {
  background: rgba(148,163,184,.15); color: var(--muted);
}
.diff-badge {
  margin-right: auto;
  font-size: 11px; font-weight: 700;
  padding: 4px 12px; border-radius: 20px; color: #fff;
}
.route-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 12px; }
.stat { display: flex; align-items: center; gap: 7px; font-size: 12.5px; }
.stat .ico { font-size: 14px; opacity: .85; }
.stat .val { font-weight: 700; }
.stat .lbl { color: var(--text-dim); }
.access-row { display: flex; gap: 8px; margin-top: 12px; }
.access-pill {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; padding: 5px 9px; border-radius: 8px;
  background: var(--surface-3);
}
.access-pill .ic { font-size: 13px; }
.acc-good { color: #4ade80; }
.acc-moderate { color: #fbbf24; }
.acc-poor { color: #f87171; }
.route-reasons { margin-top: 10px; font-size: 11px; color: var(--text-dim); line-height: 1.7; }
.route-reasons li { margin-right: 14px; }

.surface-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.surface-pill {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; padding: 4px 9px; border-radius: 8px;
  background: rgba(234,88,12,.12); color: #fdba74;
}
.surface-pill.steps { background: rgba(220,38,38,.14); color: #fca5a5; }

/* ===== Map ===== */
.main { position: relative; }
#map { width: 100%; height: 100%; background: #0a0e12; z-index: 1; }
.leaflet-container { font-family: var(--font); background: #0a0e12; }
.leaflet-popup-content-wrapper { background: var(--surface); color: var(--text); border-radius: 10px; }
.leaflet-popup-tip { background: var(--surface); }

.marker-pin {
  width: 26px; height: 26px; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
}
.marker-origin { background: var(--origin); }
.marker-dest { background: var(--dest); }

/* ===== Detail sheet ===== */
.detail-sheet {
  position: absolute;
  left: 16px; right: 16px; bottom: 16px;
  max-width: 720px; margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  z-index: 500;
  animation: sheetUp .25s ease;
}
@keyframes sheetUp { from { transform: translateY(20px); opacity: 0; } }
.sheet-close {
  position: absolute; left: 14px; top: 14px;
  background: var(--surface-3); border: none; color: var(--text);
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer; font-size: 13px;
}
.sheet-header { font-weight: 700; margin-bottom: 14px; padding-left: 36px; }
.sheet-header small { display: block; font-weight: 400; color: var(--text-dim); font-size: 12px; margin-top: 3px; }

.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tab {
  background: var(--surface-3); border: none; color: var(--text-dim);
  padding: 8px 16px; border-radius: 8px; cursor: pointer; font-family: var(--font); font-size: 13px;
}
.tab.active { background: var(--accent); color: #fff; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

#elev-chart { width: 100%; display: block; }
.elev-legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; color: var(--text-dim); }
.elev-legend b { color: var(--text); }

.nav-controls { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.voice-btn {
  background: var(--surface-3); border: 1px solid var(--border); color: var(--text);
  font-family: var(--font); font-size: 13px; font-weight: 700;
  padding: 9px 16px; border-radius: 10px; cursor: pointer;
  transition: background .15s;
}
.voice-btn:hover { background: var(--accent); border-color: var(--accent); }
.voice-btn.playing { background: var(--dest); border-color: var(--dest); }
.voice-hint { font-size: 11px; color: var(--text-dim); }

.steps { list-style: none; max-height: 240px; overflow-y: auto; }
.steps li {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 11px 4px; border-bottom: 1px solid var(--border); font-size: 13px;
  cursor: pointer; border-radius: 8px; transition: background .15s;
}
.steps li:hover { background: var(--surface-2); }
.steps li.speaking { background: rgba(20,184,166,.14); }
.steps li:last-child { border: none; }
.step-num {
  width: 24px; height: 24px; flex-shrink: 0;
  background: var(--surface-3); border-radius: 50%;
  display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--accent);
}
.step-text { flex: 1; line-height: 1.6; }
.step-dist { color: var(--text-dim); font-size: 11px; margin-top: 2px; }

.start-nav-btn {
  width: 100%; margin-top: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none; border-radius: var(--radius-sm);
  color: #fff; font-family: var(--font); font-weight: 700; font-size: 14px;
  padding: 13px; cursor: pointer;
}

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface-3); border: 1px solid var(--border);
  padding: 12px 20px; border-radius: 12px; font-size: 13px;
  box-shadow: var(--shadow); z-index: 2000;
  animation: sheetUp .2s ease;
}
.toast.error { border-color: var(--dest); color: #fca5a5; }

/* ===== Responsive ===== */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { max-height: 52vh; }
  .detail-sheet { left: 8px; right: 8px; bottom: 8px; padding: 14px; }
}

.empty-routes { color: var(--text-dim); font-size: 13px; text-align: center; padding: 20px; line-height: 1.8; }
