*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%; height: 100%; overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: #0a0a0a; color: #fff;
  user-select: none; -webkit-user-select: none;
  overscroll-behavior: none;
}

#map { position: absolute; inset: 0; background: #1a1a1a; }
.maplibregl-ctrl-attrib { font-size: 10px !important; }
.maplibregl-ctrl-bottom-right { z-index: 2 !important; }

.hidden { display: none !important; }

/* ---------- Search ---------- */
#search-bar { position: absolute; top: 16px; left: 16px; right: 84px; z-index: 10; }
#search-bar.hidden { display: none; }

#search-input {
  width: 100%; height: 56px; padding: 0 24px;
  font-size: 18px; border: none; border-radius: 28px;
  background: rgba(20,20,20,0.95); color: #fff;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  outline: none;
}
#search-input::placeholder { color: rgba(255,255,255,0.5); }
#search-input:focus { box-shadow: 0 0 0 2px #4a90e2, 0 8px 32px rgba(0,0,0,0.4); }

#suggestions {
  margin-top: 8px;
  background: rgba(20,20,20,0.97);
  border-radius: 16px;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  overflow: hidden auto;
  max-height: 60vh;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.suggestion { padding: 16px 20px; border-bottom: 1px solid rgba(255,255,255,0.08); cursor: pointer; }
.suggestion:active { background: rgba(74,144,226,0.3); }
.suggestion:last-child { border-bottom: none; }
.suggestion-name { font-size: 16px; font-weight: 600; margin-bottom: 2px; }
.suggestion-detail { font-size: 13px; color: rgba(255,255,255,0.6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Preview panel ---------- */
#preview-panel {
  display: none;
  position: absolute; bottom: 16px; left: 16px; right: 16px; z-index: 10;
  background: rgba(20,20,20,0.97); border-radius: 24px; padding: 20px;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
#preview-panel.show { display: block; }
#preview-destination { font-size: 18px; font-weight: 600; margin-bottom: 6px; }
#preview-stats { display: flex; gap: 10px; font-size: 14px; color: rgba(255,255,255,0.7); margin-bottom: 16px; align-items: center; }
#preview-stats .dot { opacity: 0.5; }
#preview-actions { display: flex; gap: 12px; }

.btn { flex: 1; height: 56px; border: none; border-radius: 28px; font-size: 17px; font-weight: 600; cursor: pointer; transition: transform 0.05s; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: #4a90e2; color: #fff; }
.btn-secondary { background: rgba(255,255,255,0.1); color: #fff; }

/* ---------- Active nav ---------- */
#nav-panel { display: none; position: absolute; top: 0; left: 0; right: 0; z-index: 10; }
#nav-panel.show { display: block; }

#next-turn {
  background: linear-gradient(180deg, rgba(15,15,15,0.98), rgba(15,15,15,0.92));
  padding: 20px 20px 16px;
  padding-top: max(20px, env(safe-area-inset-top));
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}
#next-turn-row { display: flex; align-items: center; gap: 16px; }
#maneuver-icon { width: 64px; height: 64px; flex-shrink: 0; }
#maneuver-icon svg { width: 100%; height: 100%; display: block; }
#next-turn-text { flex: 1; min-width: 0; }
#distance-to-turn { font-size: 36px; font-weight: 700; line-height: 1; letter-spacing: -0.02em; }
#instruction { font-size: 18px; margin-top: 4px; color: rgba(255,255,255,0.92); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#then-row { font-size: 13px; color: rgba(255,255,255,0.55); margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,0.08); display: none; }
#then-row.show { display: block; }

#trip-footer {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 10;
  background: linear-gradient(0deg, rgba(15,15,15,0.98), rgba(15,15,15,0.92));
  padding: 16px 20px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  display: none; align-items: center; gap: 12px;
}
#trip-footer.show { display: flex; }
.trip-stat { flex: 1; text-align: center; min-width: 0; }
.trip-stat-value { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.trip-stat-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: rgba(255,255,255,0.55); margin-top: 2px; }

#end-nav-btn { background: #dc2626; color: #fff; border: none; width: 56px; height: 56px; border-radius: 28px; font-size: 14px; font-weight: 600; cursor: pointer; flex-shrink: 0; }
#end-nav-btn:active { background: #b91c1c; }

/* ---------- Controls ---------- */
#controls { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); z-index: 5; display: flex; flex-direction: column; gap: 12px; }
.ctrl-btn { width: 52px; height: 52px; border-radius: 26px; background: rgba(20,20,20,0.92); border: none; color: #fff; font-size: 22px; cursor: pointer; backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); box-shadow: 0 4px 16px rgba(0,0,0,0.3); }
.ctrl-btn:active { background: rgba(74,144,226,0.4); }
.ctrl-btn.active { background: rgba(74,144,226,0.85); color: #fff; box-shadow: 0 4px 16px rgba(74,144,226,0.5); }

/* ---------- Toast / off-route ---------- */
#toast { position: absolute; top: 88px; left: 50%; transform: translateX(-50%); z-index: 20; background: rgba(20,20,20,0.95); padding: 12px 20px; border-radius: 24px; font-size: 14px; backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); display: none; max-width: 90vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#toast.show { display: block; }

#off-route { display: none; position: absolute; top: 130px; left: 16px; right: 16px; z-index: 15; background: #d97706; color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 14px; text-align: center; font-weight: 600; }
#off-route.show { display: block; }

/* User location marker */
.user-dot {
  width: 24px; height: 24px; border-radius: 50%;
  background: #3b82f6; border: 3px solid #fff;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.4), 0 2px 8px rgba(0,0,0,0.4);
}
